king
2023-08-15 a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d
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 { // 配置信息解析
            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)
export default Home