From f07c42a322f41e14ef5b1bf8f2fd66fc5d338cdd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 28 六月 2023 18:17:09 +0800
Subject: [PATCH] 2023-06-28

---
 src/views/mkiframe/index.jsx |   90 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 88 insertions(+), 2 deletions(-)

diff --git a/src/views/mkiframe/index.jsx b/src/views/mkiframe/index.jsx
index e443da7..b2f079b 100644
--- a/src/views/mkiframe/index.jsx
+++ b/src/views/mkiframe/index.jsx
@@ -3,6 +3,7 @@
 
 import Api from '@/api'
 import asyncComponent from '@/utils/asyncLoadComponent'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const CustomPage = asyncComponent(() => import('@/tabviews/custom'))
@@ -17,9 +18,33 @@
   }
 
   UNSAFE_componentWillMount() {
-    const { menuId, loginUid, bid } = this.props.match.params
+    const { params, path } = this.props.match
+    const { menuId, loginUid, bid } = params
 
-    if (sessionStorage.getItem('UserID')) {
+    if (/^\/view\//.test(path)) {
+      localStorage.setItem('getSysPermission', window.GLOB.appkey)
+    
+      window.addEventListener('storage', function(event) {
+        if (event.key === 'sysPermissions' && event.newValue) {
+          let values = event.newValue
+          values = JSON.parse(values)
+
+          window.GLOB.mkThdMenus = values.mkThdMenus
+          window.GLOB.mkActions = values.mkActions
+        }
+      })
+
+      setTimeout(() => {
+        localStorage.removeItem('getSysPermission')
+        localStorage.removeItem('sysPermissions')
+
+        if (window.GLOB.mkActions) {
+          this.setState({loading: false})
+        } else {
+          this.getPermRole()
+        }
+      }, 20)
+    } else if (sessionStorage.getItem('UserID')) {
       this.getPermRole()
     } else {
       sessionStorage.setItem('LoginUID', loginUid)
@@ -49,6 +74,67 @@
     this.setState({BID: bid || '', MenuId: menuId})
   }
 
+  componentDidMount () {
+    MKEmitter.addListener('modifyTabs', this.modifyTabs)
+    MKEmitter.addListener('closeTabView', this.closeTabView)
+  }
+
+  /**
+   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊
+   */
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+    MKEmitter.removeListener('modifyTabs', this.modifyTabs)
+    MKEmitter.removeListener('closeTabView', this.closeTabView)
+  }
+
+  modifyTabs = (tab) => {
+    const { MenuId, BID } = this.state
+
+    let _menuId = tab.MenuID
+    let _BID = tab.param && tab.param.$BID ? tab.param.$BID : ''
+
+    let historys = sessionStorage.getItem('page_historys')
+    historys = historys ? JSON.parse(historys) : []
+
+    historys.push({MenuId: MenuId, BID: BID})
+
+    sessionStorage.setItem('page_historys', JSON.stringify(historys))
+
+    this.setState({
+      MenuId: _menuId,
+      BID: _BID,
+      loading: true
+    }, () => {
+      this.setState({
+        loading: false
+      })
+    })
+  }
+
+  closeTabView = () => {
+    let historys = sessionStorage.getItem('page_historys')
+    historys = historys ? JSON.parse(historys) : []
+
+    if (historys.length === 0) return
+
+    let tab = historys.shift()
+
+    sessionStorage.setItem('page_historys', JSON.stringify(historys))
+    
+    this.setState({
+      MenuId: tab.MenuId,
+      BID: tab.BID,
+      loading: true
+    }, () => {
+      this.setState({
+        loading: false
+      })
+    })
+  }
+
   getPermRole = () => {
     Api.getSystemConfig({
       func: 's_Get_TrdMenu_Role',

--
Gitblit v1.8.0