From 6dd965723be9dc245105296198c25a80cfe51b54 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 27 四月 2023 10:51:50 +0800 Subject: [PATCH] 2023-04-27 --- src/tabviews/custom/index.jsx | 75 ++++++++++++++++++++++++++++++++++--- 1 files changed, 68 insertions(+), 7 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 81aec40..ff11815 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -70,8 +70,11 @@ data: null, // 鍒楄〃鏁版嵁闆� loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� visible: false, // 鏍囩椤垫帶鍒� - shortcuts: null // 蹇嵎閿� + shortcuts: null, // 蹇嵎閿� + loadinginter: false } + + stepInter = null /** * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 @@ -93,6 +96,7 @@ config = window.decodeURIComponent(window.atob(result.LongParam)) config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl) config = JSON.parse(config) + config.MenuID = MenuID } catch (e) { console.warn('Parse Failure') config = '' @@ -200,7 +204,9 @@ config.$cache = config.cacheLocal === 'true' - config.interfaces = this.formatInterSetting(config.interfaces, regs) + let initInters = [] + + config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters) config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache) // 鑾峰彇涓绘悳绱㈡潯浠� @@ -236,8 +242,17 @@ config.components = this.filterBalcony(config.components, balMap) } + if (initInters.length > 0) { + this.stepInter = { + MenuID: MenuID, + inters: initInters, + params: params + } + } + this.setState({ BID: BID, + loadinginter: this.stepInter !== null, shortcuts: shortcuts.length > 0 ? shortcuts : null, config, mainSearch @@ -251,7 +266,10 @@ ele.innerHTML = config.normalcss document.getElementsByTagName('head')[0].appendChild(ele) } - if (params.length === 0) { + + if (this.stepInter) { + + } else if (params.length === 0) { setTimeout(() => { // 寤舵椂鍔犺浇鐘舵�� this.setState({ loadingview: false @@ -943,13 +961,24 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatInterSetting = (inters, regs) => { + formatInterSetting = (inters, regs, MenuID, initInters) => { if (!inters) return [] - let interfaces = inters.filter(m => m.status === 'true') + let initlimit = false + let interfaces = inters.filter(m => { + if (m.status !== 'true') return false + + if (m.setting.loadlevel === 'init') { + initlimit = true + initInters.push(m.uuid) + } + + return true + }) let delay = 15 return interfaces.map(inter => { + inter.MenuID = MenuID inter.setting.delay = delay delay += 15 @@ -960,6 +989,10 @@ } else { inter.setting.supModule = '' } + } + + if (initlimit && inter.setting.loadlevel !== 'init') { + inter.setting.onload = 'false' } if (inter.setting.interType !== 'system') return inter @@ -1076,6 +1109,7 @@ } componentDidMount () { + MKEmitter.addListener('interFinish', this.interFinish) MKEmitter.addListener('debugChange', this.debugChange) MKEmitter.addListener('reloadMenuView', this.reloadMenuView) MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) @@ -1088,6 +1122,7 @@ this.setState = () => { return } + MKEmitter.removeListener('interFinish', this.interFinish) MKEmitter.removeListener('debugChange', this.debugChange) MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) @@ -1098,6 +1133,30 @@ this.state.config.interfaces.forEach(m => { window.GLOB.CacheData.delete(m.uuid) }) + } + } + + interFinish = (MenuID, interId) => { + if (!this.stepInter || this.stepInter.MenuID !== MenuID) return + + this.stepInter.inters = this.stepInter.inters.filter(item => item !== interId) + + if (this.stepInter.inters.length === 0) { + this.setState({loadinginter: false}) + + if (this.stepInter.params.length === 0) { + setTimeout(() => { // 寤舵椂鍔犺浇鐘舵�� + this.setState({ + loadingview: false + }) + }, 1000) + } else { + this.loadmaindata(this.stepInter.params) + } + + MKEmitter.emit('initFinish', this.stepInter.MenuID) + + this.stepInter = null } } @@ -1129,6 +1188,8 @@ }) } + this.stepInter = null + this.setState({ BID: '', // 椤甸潰璺宠浆鏃舵惡甯D loadingview: true, // 椤甸潰鍔犺浇涓� @@ -1149,9 +1210,9 @@ } getComponents = () => { - const { config, BID, data, mainSearch } = this.state + const { config, BID, data, mainSearch, loadinginter } = this.state - if (!config || !config.components) return + if (!config || !config.components || loadinginter) return return config.components.map(item => { let style = null -- Gitblit v1.8.0