| | |
| | | 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, |
| | |
| | | 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 = { |
| | |
| | | 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 |
| | |
| | | componentDidMount () { |
| | | // 获取系统的版本信息,延时查询 |
| | | setTimeout(() => { |
| | | Api.getAppVersion().then(res => { |
| | | this.setState({ |
| | | oriVersion: res.oldVersion, |
| | | newVersion: res.newVersion |
| | | }) |
| | | }, () => {}) |
| | | Api.getAppVersion().then(() => {}, () => {}) |
| | | }, 1000) |
| | | } |
| | | |
| | |
| | | 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 = () => { |
| | |
| | | |
| | | 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"> |
| | |
| | | ))} |
| | | </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> |
| | | ) |