From 2bccb9ec7bdefe23292a22bc153463cfa1479a49 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 21 六月 2024 16:25:42 +0800 Subject: [PATCH] 2024-06-21 --- src/views/mkiframe/index.jsx | 65 +++++++++++++++++++++++++++----- 1 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/views/mkiframe/index.jsx b/src/views/mkiframe/index.jsx index 3f11727..329ef36 100644 --- a/src/views/mkiframe/index.jsx +++ b/src/views/mkiframe/index.jsx @@ -1,6 +1,5 @@ import React, {Component} from 'react' -import { Spin, notification, ConfigProvider } from 'antd' -import zhCN from 'antd/es/locale/zh_CN' +import { Spin, notification } from 'antd' import Api from '@/api' import asyncComponent from '@/utils/asyncLoadComponent' @@ -19,6 +18,8 @@ type: 'CustomPage' } + reloading = false + UNSAFE_componentWillMount() { const { params, path } = this.props.match const { menuId, loginUid, bid } = params @@ -32,8 +33,10 @@ let values = event.newValue values = JSON.parse(values) - window.GLOB.mkThdMenus = values.mkThdMenus window.GLOB.mkActions = values.mkActions + values.mkThdMenus && values.mkThdMenus.forEach(item => { + window.GLOB.mkThdMenus.set(item.MenuID, item) + }) } else if (event.key === 'menuUpdate') { let vals = event.newValue.split(',') let MenuId = vals[1] @@ -52,8 +55,28 @@ if (window.GLOB.mkActions && window.GLOB.mkActions.loaded) { this.setState({loading: false}) - } else { + } else if (sessionStorage.getItem('UserID')) { this.getPermRole() + } else { + Api.getTouristMsg().then(res => { + if (res.status) { + sessionStorage.setItem('UserID', res.UserID) + sessionStorage.setItem('LoginUID', res.LoginUID) + sessionStorage.setItem('User_Name', res.UserName) + sessionStorage.setItem('Full_Name', res.FullName) + sessionStorage.setItem('avatar', res.icon || '') + sessionStorage.setItem('dataM', res.dataM ? 'true' : '') + sessionStorage.setItem('debug', res.debug || '') + sessionStorage.setItem('role_id', res.role_id || '') + sessionStorage.setItem('departmentcode', res.departmentcode || '') + sessionStorage.setItem('organization', res.organization || '') + sessionStorage.setItem('mk_user_type', res.mk_user_type || '') + this.getPermRole() + } else { + sessionStorage.clear() + this.props.history.replace('/login') + } + }) } }, 20) } else if (sessionStorage.getItem('UserID')) { @@ -89,6 +112,10 @@ componentDidMount () { MKEmitter.addListener('modifyTabs', this.modifyTabs) MKEmitter.addListener('closeTabView', this.closeTabView) + + if (window.GLOB.forcedUpdate) { + MKEmitter.addListener('reloadTabs', this.reloadTabs) + } if (window.GLOB.sysType !== 'cloud') { Object.defineProperty(window, 'debugger', { @@ -130,7 +157,24 @@ return } MKEmitter.removeListener('modifyTabs', this.modifyTabs) + MKEmitter.removeListener('reloadTabs', this.reloadTabs) MKEmitter.removeListener('closeTabView', this.closeTabView) + } + + reloadTabs = () => { + if (this.reloading) return + + this.reloading = true + + Api.getAppVersion(true).then(() => { + window.location.reload() + }, (message) => { + notification.error({ + top: 92, + message: message || '绯荤粺閰嶇疆鏇存柊澶辫触锛�', + duration: 10 + }) + }) } modifyTabs = (tab) => { @@ -161,7 +205,10 @@ let historys = sessionStorage.getItem('page_historys') historys = historys ? JSON.parse(historys) : [] - if (historys.length === 0) return + if (historys.length === 0) { + window.close() + return + } let tab = historys.shift() @@ -219,11 +266,9 @@ return ( <div className="main-iframe"> - <ConfigProvider locale={zhCN}> - {loading ? <Spin size="large" /> : null} - {!loading && type === 'CustomPage' ? <CustomPage MenuID={MenuId} param={{$BID: BID}} changeTemp={this.changeTemp}/> : null} - {!loading && type === 'BaseTable' ? <BaseTable MenuID={MenuId} param={{$BID: BID}} changeTemp={this.changeTemp}/> : null} - </ConfigProvider> + {loading ? <Spin size="large" /> : null} + {!loading && type === 'CustomPage' ? <CustomPage MenuID={MenuId} param={{$BID: BID}} changeTemp={this.changeTemp}/> : null} + {!loading && type === 'BaseTable' ? <BaseTable MenuID={MenuId} param={{$BID: BID}} changeTemp={this.changeTemp}/> : null} <ImgScale /> </div> ) -- Gitblit v1.8.0