From 9c6795fd3c44e46cf3955fbfd8f8eeca23acb7a9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 08 十月 2022 00:31:51 +0800 Subject: [PATCH] 2022-10-08 --- src/tabviews/home/index.jsx | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx index b53c5bd..f79eb7e 100644 --- a/src/tabviews/home/index.jsx +++ b/src/tabviews/home/index.jsx @@ -4,6 +4,7 @@ import Api from '@/api' import asyncComponent from '@/utils/asyncComponent' +import MKEmitter from '@/utils/events.js' import './index.scss' const DefaultHome = asyncComponent(() => import('./defaulthome')) @@ -16,10 +17,54 @@ state = { loading: true, + background: sessionStorage.getItem('home_background'), + waitMenu: true, + waitAction: true, view: '' } componentDidMount () { + this.loadHomeConfig() + if (window.GLOB.mkThdMenus.length > 0) { + this.setState({ + waitMenu: false + }) + } else { + MKEmitter.addListener('mkMenuLoaded', this.mkMenuLoaded) + } + if (window.GLOB.mkActions.loaded) { + this.setState({ + waitAction: false + }) + } else { + MKEmitter.addListener('mkActionLoaded', this.mkActionLoaded) + } + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('mkMenuLoaded', this.mkMenuLoaded) + MKEmitter.removeListener('mkActionLoaded', this.mkActionLoaded) + } + + mkMenuLoaded = () => { + this.setState({ + waitMenu: false + }) + } + + mkActionLoaded = () => { + this.setState({ + waitAction: false + }) + } + + loadHomeConfig = () => { let _param = { func: 'sPC_Get_LongParam', MenuID: this.props.MenuID @@ -34,6 +79,8 @@ } else { this.setState({ loading: false, + waitMenu: false, + waitAction: false, view: 'default' }) } @@ -52,12 +99,12 @@ } render() { - const { loading, view } = this.state + const { loading, waitAction, waitMenu, view, background } = this.state - if (loading) { - return (<Spin className="home-box-spin" size="large" />) + if (loading || waitAction || waitMenu) { + return (<div className="home-loading-view" style={{background: background}}><Spin className="home-box-spin" size="large" /></div>) } else if (view === 'custom') { - return (<CustomPage MenuID={this.props.MenuID}/>) + return (<CustomPage MenuID={this.props.MenuID} MenuName="棣栭〉"/>) } else { return (<DefaultHome />) } -- Gitblit v1.8.0