From c06e58c80240afd703d289bb1c584e08b9783383 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 13 六月 2025 20:24:25 +0800 Subject: [PATCH] 2025-06-13 --- src/components/breadview/index.jsx | 155 +++++++++++++++++++++++++++++++++++---------------- 1 files changed, 106 insertions(+), 49 deletions(-) diff --git a/src/components/breadview/index.jsx b/src/components/breadview/index.jsx index b1f59ca..340b188 100644 --- a/src/components/breadview/index.jsx +++ b/src/components/breadview/index.jsx @@ -1,12 +1,11 @@ import React, {Component} from 'react' -import { BackTop, Breadcrumb, notification} from 'antd' -import { HomeOutlined, RightOutlined, RedoOutlined } from '@ant-design/icons' +import { BackTop, Breadcrumb, notification, Modal } from 'antd' +import { HomeOutlined, RightOutlined, RedoOutlined, LoadingOutlined } from '@ant-design/icons' import moment from 'moment' import 'moment/locale/zh-cn' import asyncComponent from '@/utils/asyncLoadComponent' import NotFount from '@/components/404' -import options from '@/store/options.js' import MKEmitter from '@/utils/events.js' import Api from '@/api' import './index.scss' @@ -15,23 +14,53 @@ const CustomPage = asyncComponent(() => import('@/tabviews/custom')) const CommonTable = asyncComponent(() => import('@/tabviews/commontable')) const BaseTable = asyncComponent(() => import('@/tabviews/basetable')) -const CalendarPage = asyncComponent(() => import('@/tabviews/calendar')) const TreePage = asyncComponent(() => import('@/tabviews/treepage')) const Iframe = asyncComponent(() => import('@/tabviews/iframe')) const RoleManage = asyncComponent(() => import('@/tabviews/rolemanage')) -const FormTab = asyncComponent(() => import('@/tabviews/formtab')) + +if (sessionStorage.getItem('lang') === 'zh-CN') { + moment.locale('zh-cn') +} class BreadView extends Component { state = { - tabview: null, // 鏍囩 - hasNavBar: window.GLOB.navBar === 'linkage_navigation' + tabview: null, + hasNavBar: window.GLOB.navBar === 'linkage_navigation', + visible: false + } + + reloading = false + + UNSAFE_componentWillMount () { + let home = { + MenuID: 'home_page_id', + MenuName: window.GLOB.dict['home'] || '棣栭〉', + type: 'Home' + } + this.setState({tabview: home}) + } + + componentDidMount () { + MKEmitter.addListener('modifyTabs', this.modifyTabs) + MKEmitter.addListener('reloadTabs', this.reloadTabs) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('reloadTabs', this.reloadTabs) + MKEmitter.removeListener('modifyTabs', this.modifyTabs) } refreshTabview = () => { const { tabview } = this.state window.GLOB.CacheMap = new Map() - if (options.sysType === 'local' && window.GLOB.systemType !== 'production') { + if (window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') { let roledefer = new Promise(resolve => { Api.getSystemConfig({ func: 's_Get_TrdMenu_Role', @@ -88,47 +117,28 @@ selectcomponent = (view) => { // 鏍规嵁tab椤典腑鑿滃崟淇℃伅锛岄�夋嫨鎵�闇�鐨勭粍浠� if (view.type === 'BaseTable') { - return (<BaseTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param} changeTemp={this.changeTemp}/>) + return (<BaseTable MenuID={view.MenuID} MenuName={view.MenuName} param={view.param} changeTemp={this.changeTemp}/>) } else if (view.type === 'CustomPage') { - return (<CustomPage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param} changeTemp={this.changeTemp}/>) + return (<CustomPage MenuID={view.MenuID} MenuName={view.MenuName} param={view.param} changeTemp={this.changeTemp}/>) } else if (view.type === 'Home') { - return (<Home MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) + return (<Home MenuID={view.MenuID} MenuName={view.MenuName}/>) } else if (view.type === 'RolePermission') { - return (<RoleManage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) + return (<RoleManage MenuID={view.MenuID}/>) } else if (view.type === 'CommonTable') { - return (<CommonTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param} changeTemp={this.changeTemp}/>) + return (<CommonTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param} changeTemp={this.changeTemp}/>) } else if (view.type === 'TreePage') { - return (<TreePage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) - } else if (view.type === 'CalendarPage') { - return (<CalendarPage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) - } else if (view.type === 'FormTab') { - return (<FormTab MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) + return (<TreePage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param}/>) } else if (view.type === 'iframe') { - return (<Iframe key={view.MenuID} MenuID={view.MenuID} MenuNo={view.MenuNo} title={view.MenuName} MenuName={view.MenuName} url={window.GLOB.baseurl + 'zh-CN/' + view.LinkUrl}/>) + return (<Iframe MenuID={view.MenuID} title={view.MenuName} url={view.src}/>) } else { - return (<NotFount key={view.MenuID} />) + return (<NotFount />) } - } - - UNSAFE_componentWillMount () { - if (!sessionStorage.getItem('lang') || sessionStorage.getItem('lang') === 'zh-CN') { - moment.locale('zh-cn') - } else { - moment.locale('en') - } - - let home = { - MenuID: 'home_page_id', - MenuName: '棣栭〉', - type: 'Home' - } - this.setState({tabview: home}) } gotoHome = () => { let home = { MenuID: 'home_page_id', - MenuName: '棣栭〉', + MenuName: window.GLOB.dict['home'] || '棣栭〉', type: 'Home' } this.setState({tabview: home}) @@ -145,25 +155,57 @@ } } - componentDidMount () { - MKEmitter.addListener('modifyTabs', this.modifyTabs) - } + reloadTabs = () => { + if (this.reloading) return - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - MKEmitter.removeListener('modifyTabs', this.modifyTabs) + let time = new Date().getTime() + + let oldTime = sessionStorage.getItem('mk_reloadTabs') + + if (oldTime && time - oldTime < 180000) return + + sessionStorage.setItem('mk_reloadTabs', time) + + this.reloading = true + this.setState({visible: true}) + + Api.getAppVersion(true).then((list) => { + let _time = new Date().getTime() + let delay = _time - time + delay = delay < 3000 ? 3000 - delay : 0 + + setTimeout(() => { + this.setState({visible: false}) + this.reloading = false + + Modal.success({ + title: '鏇存柊鎴愬姛銆�', + }) + + if (list && list.length && list.includes(this.state.tabview.MenuID)) { + MKEmitter.emit('reloadMenuView', this.state.tabview.MenuID) + } + }, delay) + }, (message) => { + let _time = new Date().getTime() + let delay = _time - time + delay = delay < 3000 ? 3000 - delay : 0 + + setTimeout(() => { + this.setState({visible: false}) + this.reloading = false + Modal.error({ + title: message || '绯荤粺閰嶇疆鏇存柊澶辫触锛�', + }) + }, delay) + }) } render () { - const { tabview, hasNavBar } = this.state + const { tabview, hasNavBar, visible } = this.state return ( - <section id="mk-breadview-wrap" className="mk-breadview-wrap"> + <section id="mk-tabgroup-wrap" className="mk-breadview-wrap"> {hasNavBar && tabview ? <Breadcrumb separator=""> <Breadcrumb.Item> <HomeOutlined onClick={this.gotoHome} /> @@ -186,6 +228,21 @@ </div> </div> </BackTop> + <Modal + visible={visible} + width={400} + closable={false} + centered={true} + footer={null} + destroyOnClose + > + <div className="mk-menus-update"> + <div className="tip"> + 绯荤粺鏇存柊涓紝璇风◢鍚� + </div> + <LoadingOutlined /> + </div> + </Modal> </section> ) } -- Gitblit v1.8.0