From 72419e2f826031a158173f46d723a672064e37cd Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 31 八月 2021 22:42:51 +0800 Subject: [PATCH] 2021-08-31 --- src/tabviews/home/index.jsx | 35 +++++++++++++++++++++++++++++++---- 1 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx index 26fbcd0..ae14a8f 100644 --- a/src/tabviews/home/index.jsx +++ b/src/tabviews/home/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { connect } from 'react-redux' import { notification, Spin } from 'antd' import Api from '@/api' @@ -17,11 +18,25 @@ state = { loading: true, background: sessionStorage.getItem('home_background'), + waiting: true, view: '' } componentDidMount () { this.loadHomeConfig() + if (this.props.permMenus.length > 0 && JSON.stringify(this.props.permAction) !== '{}') { + this.setState({ + waiting: false + }) + } + } + + UNSAFE_componentWillReceiveProps (nextProps) { + if (nextProps.permMenus.length > 0 && JSON.stringify(nextProps.permAction) !== '{}') { + this.setState({ + waiting: false + }) + } } loadHomeConfig = () => { @@ -39,6 +54,7 @@ } else { this.setState({ loading: false, + waiting: false, view: 'default' }) } @@ -57,16 +73,27 @@ } render() { - const { loading, view, background } = this.state + const { loading, waiting, view, background } = this.state - if (loading) { + 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 />) } } } -export default Home \ No newline at end of file +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 -- Gitblit v1.8.0