From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 12 十二月 2023 21:05:37 +0800 Subject: [PATCH] 2023-12-12 --- src/tabviews/home/index.jsx | 76 ++++++++++++++++++++++++++++++-------- 1 files changed, 60 insertions(+), 16 deletions(-) diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx index b53c5bd..d8b8d6c 100644 --- a/src/tabviews/home/index.jsx +++ b/src/tabviews/home/index.jsx @@ -16,32 +16,76 @@ state = { loading: true, + background: sessionStorage.getItem('home_background'), + waiting: true, view: '' } componentDidMount () { + this.loadHomeConfig() + + this.check(0) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + check = (times) => { + times++ + + if ((window.GLOB.mkThdMenus.size > 0 && window.GLOB.mkActions.loaded) || times > 50) { + this.setState({ + waiting: false + }) + } else { + setTimeout(() => { + this.check(times) + }, 200) + } + } + + loadHomeConfig = () => { let _param = { func: 'sPC_Get_LongParam', MenuID: this.props.MenuID } Api.getCacheConfig(_param).then(result => { - if (result.status) { - if (result.LongParam) { - this.setState({ - loading: false, - view: 'custom' - }) - } else { - this.setState({ - loading: false, - view: 'default' - }) + let view = 'default' + if (result.status && result.LongParam) { + let config = '' + + try { // 閰嶇疆淇℃伅瑙f瀽 + config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + } catch (e) { + console.warn('Parse Failure') + config = '' } + + if (config && config.enabled) { + view = 'custom' + } + } + + if (view === 'default') { + this.setState({ + loading: false, + waiting: false, + view: 'default' + }) } else { this.setState({ loading: false, - view: 'default' + view: 'custom' }) + } + + if (!result.status) { notification.warning({ top: 92, message: result.message, @@ -52,12 +96,12 @@ } render() { - const { loading, view } = this.state + const { loading, waiting, view, background } = this.state - if (loading) { - return (<Spin className="home-box-spin" size="large" />) + if (loading || waiting) { + 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