king
2024-04-29 50b49c1b760489c3430fc382656d57c5fbbab07c
src/components/breadview/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import { BackTop, Breadcrumb, notification} from 'antd'
import { HomeOutlined, RightOutlined, RedoOutlined } from '@ant-design/icons'
import { BackTop, Breadcrumb, notification, Modal } from 'antd'
import { HomeOutlined, RightOutlined, RedoOutlined, LoadingOutlined } from '@ant-design/icons'
import moment from 'moment'
import 'moment/locale/zh-cn'
@@ -22,8 +22,38 @@
class BreadView extends Component {
  state = {
    tabview: null, // 标签
    hasNavBar: window.GLOB.navBar === 'linkage_navigation'
    tabview: null,
    hasNavBar: window.GLOB.navBar === 'linkage_navigation',
    visible: false
  }
  reloading = false
  UNSAFE_componentWillMount () {
    let home = {
      MenuID: 'home_page_id',
      MenuName: '首页',
      type: 'Home'
    }
    this.setState({tabview: home})
  }
  componentDidMount () {
    MKEmitter.addListener('modifyTabs', this.modifyTabs)
    if (window.GLOB.forcedUpdate) {
      MKEmitter.addListener('reloadTabs', this.reloadTabs)
    }
  }
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('reloadTabs', this.reloadTabs)
    MKEmitter.removeListener('modifyTabs', this.modifyTabs)
  }
  refreshTabview = () => {
@@ -105,15 +135,6 @@
    }
  }
  UNSAFE_componentWillMount () {
    let home = {
      MenuID: 'home_page_id',
      MenuName: '首页',
      type: 'Home'
    }
    this.setState({tabview: home})
  }
  gotoHome = () => {
    let home = {
      MenuID: 'home_page_id',
@@ -134,22 +155,48 @@
    }
  }
  componentDidMount () {
    MKEmitter.addListener('modifyTabs', this.modifyTabs)
  }
  reloadTabs = () => {
    if (this.reloading) return
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('modifyTabs', this.modifyTabs)
    this.reloading = true
    let time = new Date().getTime()
    this.setState({visible: true})
    Api.getAppVersion(true).then((list) => {
      let _time = new Date().getTime()
      let delay = _time - time
      delay = delay < 3000 ? 3000 - delay : 0
      setTimeout(() => {
        this.setState({visible: false})
        this.reloading = false
        Modal.success({
          title: '更新成功。',
        })
        if (list && list.length && list.includes(this.state.tabview.MenuID)) {
          MKEmitter.emit('reloadMenuView', this.state.tabview.MenuID)
        }
      }, delay)
    }, (message) => {
      let _time = new Date().getTime()
      let delay = _time - time
      delay = delay < 3000 ? 3000 - delay : 0
      setTimeout(() => {
        this.setState({visible: false})
        this.reloading = false
        Modal.error({
          title: message || '系统配置更新失败!',
        })
      }, delay)
    })
  }
  render () {
    const { tabview, hasNavBar } = this.state
    const { tabview, hasNavBar, visible } = this.state
    return (
      <section id="mk-tabgroup-wrap" className="mk-breadview-wrap">
@@ -175,6 +222,21 @@
            </div>
          </div>
        </BackTop>
        <Modal
          visible={visible}
          width={400}
          closable={false}
          centered={true}
          footer={null}
          destroyOnClose
        >
          <div className="mk-menus-update">
            <div className="tip">
              系统更新中,请稍后
            </div>
            <LoadingOutlined />
          </div>
        </Modal>
      </section>
    )
  }