From a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 15 八月 2023 14:22:03 +0800 Subject: [PATCH] 2023-08-15 --- src/tabviews/home/index.jsx | 66 +++++++++++++++++++++------------ 1 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx index dfb3f7d..a6a8a60 100644 --- a/src/tabviews/home/index.jsx +++ b/src/tabviews/home/index.jsx @@ -1,6 +1,5 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { connect } from 'react-redux' import { notification, Spin } from 'antd' import Api from '@/api' @@ -24,18 +23,30 @@ componentDidMount () { this.loadHomeConfig() - if (this.props.permMenus.length > 0 && JSON.stringify(this.props.permAction) !== '{}') { - this.setState({ - waiting: false - }) + + this.check(0) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return } } - UNSAFE_componentWillReceiveProps (nextProps) { - if (nextProps.permMenus.length > 0 && JSON.stringify(nextProps.permAction) !== '{}') { + check = (times) => { + times++ + + if ((window.GLOB.mkThdMenus.length > 0 && window.GLOB.mkActions.loaded) || times > 50) { this.setState({ waiting: false }) + } else { + setTimeout(() => { + this.check(times) + }, 200) } } @@ -47,10 +58,27 @@ Api.getCacheConfig(_param).then(result => { if (result.status) { if (result.LongParam) { - this.setState({ - loading: false, - view: 'custom' - }) + let config = '' + + try { // 閰嶇疆淇℃伅瑙f瀽 + config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + } catch (e) { + console.warn('Parse Failure') + config = '' + } + + if (!config || !config.enabled) { + this.setState({ + loading: false, + waiting: false, + view: 'default' + }) + } else { + this.setState({ + loading: false, + view: 'custom' + }) + } } else { this.setState({ loading: false, @@ -61,6 +89,7 @@ } else { this.setState({ loading: false, + waiting: false, view: 'default' }) notification.warning({ @@ -78,22 +107,11 @@ 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 />) } } } -const mapStateToProps = (state) => { - return { - permAction: state.permAction, - permMenus: state.permMenus - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(Home) \ No newline at end of file +export default Home \ No newline at end of file -- Gitblit v1.8.0