king
2021-05-08 6afdec0062dacbded57e166230eb22cc55ced0c1
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,20 @@
  state = {
    loading: true,
    background: sessionStorage.getItem('home_background'),
    waiting: true,
    view: ''
  }
  componentDidMount () {
    this.loadHomeConfig()
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    if (nextProps.permMenus.length > 0 && JSON.stringify(nextProps.permAction) !== '{}') {
      this.setState({
        waiting: false
      })
    }
  }
  loadHomeConfig = () => {
@@ -39,6 +49,7 @@
        } else {
          this.setState({
            loading: false,
            waiting: false,
            view: 'default'
          })
        }
@@ -57,9 +68,9 @@
  }
  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}/>)
@@ -69,4 +80,15 @@
  }
}
export default Home
const mapStateToProps = (state) => {
  return {
    permAction: state.permAction,
    permMenus: state.permMenus
  }
}
const mapDispatchToProps = () => {
  return {}
}
export default connect(mapStateToProps, mapDispatchToProps)(Home)