From a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 15 八月 2023 14:22:03 +0800
Subject: [PATCH] 2023-08-15

---
 src/components/header/index.jsx |   51 +++++++++++++++++++++++++++++++--------------------
 1 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 5ddbc2a..c9d7275 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -15,7 +15,6 @@
 import asyncComponent from '@/utils/asyncComponent'
 import Api from '@/api'
 import MKEmitter from '@/utils/events.js'
-import options from '@/store/options.js'
 import Utils from '@/utils/utils.js'
 import avatar from '@/assets/img/avatar.jpg'
 import './index.scss'
@@ -91,7 +90,7 @@
 
   getRolesMenu () {
     // 鑾峰彇涓昏彍鍗曞弬鏁�
-    let _param = {func: 's_get_pc_menus', systemType: options.sysType}
+    let _param = {func: 's_get_pc_menus', systemType: window.GLOB.sysType}
     _param.pro_sys = window.GLOB.systemType === 'production' ? 'Y' : ''
     
     Api.getSystemConfig(_param).then(result => {
@@ -107,10 +106,10 @@
       const { menulist, thdMenuList } = this.getMenulist(result)
 
       let systems = []
-      if ((options.sysType === 'local' || options.sysType === 'SSO') && result.sys_list) {
+      if ((window.GLOB.sysType === 'local' || window.GLOB.sysType === 'SSO') && result.sys_list) {
         systems = result.sys_list
 
-        if (options.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) {
+        if (window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production' && systems.length > 10) {
           systems.length = 10
         }
       }
@@ -135,12 +134,9 @@
 
       window.GLOB.mkThdMenus = [...thdMenuList, {MenuID: 'home_page_id', EasyCode: '', MenuName: 'home', type: 'CustomPage'}]
 
-      if (_menu) { // 寤舵椂鎵撳紑锛岄槻姝㈡爣绛剧粍鏈畬鎴愬姞杞�
-        setTimeout(() => {
-          MKEmitter.emit('modifyTabs', _menu)
-        }, 200)
+      if (_menu) {
+        this.openTab(_menu, 0)
       }
-      MKEmitter.emit('mkMenuLoaded')
     })
     
     // 鑾峰彇瑙掕壊鏉冮檺, edition_type 鎺ュ彛鐗堟湰鎺у埗 ''銆�'Y'銆�'A'
@@ -167,10 +163,24 @@
           })
         }
 
-        MKEmitter.emit('mkActionLoaded')
         window.GLOB.mkActions = _permAction
       })
     }, 50)
+  }
+
+  openTab = (menu, times) => {
+    if (times > 50) return
+    times++
+
+    let tabgroup = document.getElementById('mk-tabgroup-wrap')
+
+    if (window.GLOB.mkActions.loaded && tabgroup) {
+      MKEmitter.emit('modifyTabs', menu)
+    } else {
+      setTimeout(() => {
+        this.openTab(times)
+      }, 200)
+    }
   }
 
   getMenulist = (result) => {
@@ -303,8 +313,6 @@
         loginVisible: true
       })
     } else {
-      sessionStorage.setItem('isEditState', 'true')
-
       this.props.modifyMainMenu(null)
 
       this.props.history.replace('/design')
@@ -345,12 +353,11 @@
           sessionStorage.setItem('cloudDataM', res.dataM ? 'true' : '')
           sessionStorage.setItem('cloudRole_id', res.role_id || '')
 
-          sessionStorage.setItem('isEditState', 'true')
-
+          let _url = window.location.href.split('#')[0] + 'cloud'
           if (param.remember) {
-            let _url = window.location.href.split('#')[0] + 'cloud'
-
             localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: param.password}))))
+          } else {
+            localStorage.setItem(_url, window.btoa(window.encodeURIComponent(JSON.stringify({time: new Date().getTime(), username: param.username, password: ''}))))
           }
 
           this.props.modifyMainMenu(null)
@@ -463,8 +470,12 @@
       } else if (e.key === 'getSysPermission' && e.newValue === window.GLOB.appkey) {
         localStorage.setItem('sysPermissions', JSON.stringify({mkThdMenus: window.GLOB.mkThdMenus, mkActions: window.GLOB.mkActions}))
       } else if (e.key === 'menuUpdate') {
-        let menuId = e.newValue.split(',')[1]
-        if (menuId) {
+        let vals = e.newValue.split(',')
+        let menuId = vals[1]
+        let position = vals[2] || ''
+        if (position === 'menu') {
+          MKEmitter.emit('reloadMenuView', menuId)
+        } else if (menuId) {
           Api.getAppVersion(menuId).then(() => {
             MKEmitter.emit('reloadMenuView', menuId)
           })
@@ -487,11 +498,11 @@
   }
 
   gotoDoc = () => {
-    if (options.sysType === 'local' && window.GLOB.mainSystemApi) {
+    if (window.GLOB.sysType === 'local' && window.GLOB.mainSystemApi) {
       let ssodomain = window.GLOB.mainSystemApi.replace('/webapi/dostars', '')
       let url = `${ssodomain}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`
       window.open(url)
-    } else if (options.sysType === 'SSO' || options.sysType === 'cloud') {
+    } else if (window.GLOB.sysType === 'SSO' || window.GLOB.sysType === 'cloud') {
       window.open(`${window.location.href.replace(/\/admin(.*)|\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
     }
   }

--
Gitblit v1.8.0