| | |
| | | import React, {Component} from 'react' |
| | | import { ConfigProvider } from 'antd' |
| | | import { connect } from 'react-redux' |
| | | import enUS from 'antd/es/locale/en_US' |
| | | import zhCN from 'antd/es/locale/zh_CN' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Header from '@/components/header' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import Sidemenu from '@/components/sidemenu' |
| | | import Tabview from '@/components/tabview' |
| | | import { resetDebug, modifyDataManager, initRolesPermission } from '@/store/action' |
| | | import QueryLog from '@/components/querylog' |
| | | import ImgScale from '@/components/imgScale' |
| | | |
| | | import './index.scss' |
| | | // import './index.scss' |
| | | |
| | | const _locale = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS |
| | | const Tabview = asyncComponent(() => import('@/components/tabview')) |
| | | const Breadview = asyncComponent(() => import('@/components/breadview')) |
| | | |
| | | class Main extends Component { |
| | | state = { |
| | | userId: sessionStorage.getItem('UserID') |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | if (sessionStorage.getItem('dataM') === 'true') { |
| | | this.props.modifyDataManager(true) |
| | | } |
| | | if (sessionStorage.getItem('debug') === 'true') { |
| | | this.props.resetDebug() |
| | | } |
| | | if (sessionStorage.getItem('role_id')) { |
| | | let roles = sessionStorage.getItem('role_id') |
| | | roles = roles.split(',') |
| | | |
| | | this.props.initRolesPermission(roles) |
| | | if (!this.state.userId) { |
| | | this.props.history.replace('/login') |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('resetSelectLine', this.resetParentParam) |
| | | |
| | | if (window.GLOB.sysType !== 'cloud') { |
| | | Object.defineProperty(window, 'debugger', { |
| | | configurable: true, |
| | | enumerable: true, |
| | | set(value) { |
| | | if (value + '' === 'false') { |
| | | window.GLOB.debugger = false |
| | | } else { |
| | | window.GLOB.debugger = true |
| | | } |
| | | } |
| | | }) |
| | | |
| | | Object.defineProperty(window, 'debug', { |
| | | configurable: true, |
| | | enumerable: true, |
| | | set(value) { |
| | | if (value + '' === 'false') { |
| | | window.GLOB.debugger = false |
| | | window.GLOB.breakpoint = false |
| | | sessionStorage.removeItem('breakpoint') |
| | | } else { |
| | | window.GLOB.debugger = true |
| | | window.GLOB.breakpoint = value + '' |
| | | sessionStorage.setItem('breakpoint', value) |
| | | } |
| | | MKEmitter.emit('debugChange') |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | MKEmitter.removeListener('resetSelectLine', this.resetParentParam) |
| | | } |
| | | |
| | | resetParentParam = (MenuID, id, data) => { |
| | | window.GLOB.CacheData.set(MenuID, {...data, $BID: id}) |
| | | } |
| | | |
| | | render () { |
| | | const navBar = window.GLOB.navBar |
| | | |
| | | if (!this.state.userId) return null |
| | | |
| | | return ( |
| | | <div className="flex-container"> |
| | | <ConfigProvider locale={_locale}> |
| | | <Header key="header"/> |
| | | <Sidemenu key="sidemenu"/> |
| | | <Tabview key="tabview"/> |
| | | </ConfigProvider> |
| | | <div className="mk-main-view"> |
| | | <Header key="header"/> |
| | | {navBar === 'shutter' ? <Sidemenu key="sidemenu"/> : null} |
| | | {navBar === 'shutter' || navBar === 'menu_board_navigation' ? |
| | | <Tabview key="tabview"/> : |
| | | <Breadview key="breadview"/>} |
| | | {window.GLOB.systemType === 'production' ? <QueryLog /> : null} |
| | | <ImgScale /> |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | const mapStateToProps = () => { |
| | | return {} |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | resetDebug: () => dispatch(resetDebug()), |
| | | initRolesPermission: (roles) => dispatch(initRolesPermission(roles)), |
| | | modifyDataManager: (dataManager) => dispatch(modifyDataManager(dataManager)) |
| | | } |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(Main) |
| | | export default Main |