king
2023-08-17 c7aece35a62b6e91fd98a625bf0e53f64bfbd18d
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)
    }
  }
@@ -45,24 +56,36 @@
      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,
            waiting: false,
            view: 'default'
          })
      let view = 'default'
      if (result.status && result.LongParam) {
        let config = ''
        try { // 配置信息解析
          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,
@@ -85,15 +108,4 @@
  }
}
const mapStateToProps = (state) => {
  return {
    permAction: state.permAction,
    permMenus: state.permMenus
  }
}
const mapDispatchToProps = () => {
  return {}
}
export default connect(mapStateToProps, mapDispatchToProps)(Home)
export default Home