king
2021-09-08 6d71b3fac75a35e8ebf08e71ba40c5be8a586024
src/components/header/index.jsx
@@ -4,7 +4,7 @@
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import moment from 'moment'
import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Input, Badge } from 'antd'
import { Dropdown, Menu, Icon, Modal, Form, notification, Switch, Input } from 'antd'
import {
  toggleCollapse,
@@ -22,12 +22,14 @@
import enUS from '@/locales/en-US/main.js'
import Utils from '@/utils/utils.js'
import avatar from '@/assets/img/avatar.jpg'
import asyncComponent from '@/utils/asyncComponent'
import Resetpwd from './resetpwd'
import LoginForm from './loginform'
import './index.scss'
const { confirm } = Modal
const { Search } = Input
const VersionsUp = asyncComponent(() => import('./versions'))
class Header extends Component {
  static propTpyes = {
@@ -46,8 +48,6 @@
    systems: [],
    searchkey: '',
    thdMenuList: [],
    oriVersion: '',
    newVersion: '',
    debug: sessionStorage.getItem('debug') === 'true',
    navBar: ['linkage_navigation', 'linkage', 'menu_board', 'menu_board_navigation'].includes(window.GLOB.navBar) ? 'topmenu' : '',
    menuType: window.GLOB.navBar
@@ -596,12 +596,7 @@
  componentDidMount () {
    // 获取系统的版本信息,延时查询
    setTimeout(() => {
      Api.getAppVersion().then(res => {
        this.setState({
          oriVersion: res.oldVersion,
          newVersion: res.newVersion
        })
      }, () => {})
      Api.getAppVersion().then(() => {}, () => {})
    }, 1000)
  }
@@ -616,38 +611,6 @@
    this.setState = () => {
      return
    }
  }
  verup = () => {
    const { oriVersion, newVersion } = this.state
    const _this = this
    confirm({
      title: this.state.dict['main.verup'],
      content: `最新版本${newVersion},当前版本${oriVersion}`,
      onOk() {
        return new Promise(resolve => {
          if (!window.GLOB.WebSql) {
            notification.warning({
              top: 92,
              message: '升级失败,请刷新页面重试!',
              duration: 2
            })
            resolve()
          } else {
            Api.updateAppVersion(newVersion)
            notification.success({
              top: 92,
              message: '升级成功!',
              duration: 2
            })
            _this.setState({oriVersion: newVersion})
            resolve()
          }
        })
      },
      onCancel() {}
    })
  }
  gotoDoc = () => {
@@ -702,7 +665,7 @@
  render () {
    const { mainMenu, collapse } = this.props
    const { thdMenuList, searchkey, oriVersion, newVersion, debug, menulist, navBar, menuType } = this.state
    const { thdMenuList, searchkey, debug, menulist, navBar, menuType } = this.state
    const menu = (
      <Menu className="header-dropdown">
@@ -717,9 +680,9 @@
          ))}
        </Menu.SubMenu> : null}
        <Menu.Item key="doc" onClick={this.gotoDoc}>{this.state.dict['main.doc']}</Menu.Item>
        {oriVersion ? <Menu.Item key="verup" onClick={this.verup}>
          <Badge dot={oriVersion !== newVersion}>{this.state.dict['main.verup']}</Badge>
        </Menu.Item> : null}
        <Menu.Item style={{padding: 0}} key="verup">
          <VersionsUp debug={debug} />
        </Menu.Item>
        <Menu.Item key="logout" onClick={this.logout}>{this.state.dict['main.logout']}</Menu.Item>
      </Menu>
    )