king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
src/views/main/index.jsx
@@ -1,7 +1,4 @@
import React, {Component} from 'react'
import { ConfigProvider } from 'antd'
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'
@@ -10,36 +7,55 @@
import QueryLog from '@/components/querylog'
import ImgScale from '@/components/imgScale'
import './index.scss'
// import './index.scss'
const Tabview = asyncComponent(() => import('@/components/tabview'))
const Breadview = asyncComponent(() => import('@/components/breadview'))
const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
class Main extends Component {
  state = {
    navBar: window.GLOB.navBar
    userId: sessionStorage.getItem('UserID')
  }
  UNSAFE_componentWillMount() {
    if (!this.state.userId) {
      this.props.history.replace('/login')
    }
  }
  componentDidMount () {
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
    Object.defineProperty(window, 'debug', {
      configurable: true,
      enumerable: true,
      set(value) {
        if (value + '' === 'false') {
          window.debugger = false
          window.GLOB.breakpoint = false
          sessionStorage.removeItem('breakpoint')
        } else {
          window.debugger = true
          window.GLOB.breakpoint = value + ''
          sessionStorage.setItem('breakpoint', value)
    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
          }
        }
        MKEmitter.emit('debugChange')
      }
    })
      })
      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 () {
@@ -51,18 +67,18 @@
  }
  render () {
    const { navBar } = this.state
    const isSideMenu = !['linkage_navigation', 'linkage', 'menu_board'].includes(navBar)
    const navBar = window.GLOB.navBar
    if (!this.state.userId) return null
    return (
      <div className="mk-main-view">
        <ConfigProvider locale={_locale}>
          <Header key="header"/>
          {isSideMenu && navBar !== 'menu_board_navigation' ? <Sidemenu key="sidemenu"/> : null}
          {isSideMenu ? <Tabview key="tabview"/> : null}
          {!isSideMenu ? <Breadview key="breadview"/> : null}
          {window.GLOB.systemType === 'production' ? <QueryLog /> : null}
        </ConfigProvider>
        <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>
    )