king
2023-08-27 da64ab0923bf8817fc8599a6e37b953ce38f64c8
src/views/design/header/index.jsx
@@ -1,22 +1,14 @@
import React, {Component} from 'react'
import { withRouter } from 'react-router-dom'
import {connect} from 'react-redux'
import { Dropdown, Menu, Modal, notification, Switch, Button, Popover } from 'antd'
import { MenuFoldOutlined, SettingOutlined, AppstoreOutlined, DownOutlined, HomeOutlined, ApiOutlined, PlusOutlined, EditOutlined, MenuOutlined, DatabaseOutlined } from '@ant-design/icons'
import moment from 'moment'
import asyncComponent from '@/utils/asyncComponent'
import {
  modifyMenuTree,
  modifyMainMenu,
  resetEditLevel,
  logout
} from '@/store/action'
import Api from '@/api'
import options from '@/store/options.js'
import Utils from '@/utils/utils.js'
import avatar from '@/assets/img/avatar.jpg'
import MainLogo from '@/assets/img/main-logo.png'
import asyncComponent from '@/utils/asyncComponent'
import MKEmitter from '@/utils/events.js'
import './index.scss'
@@ -44,7 +36,6 @@
      content: '',
      onOk() {
        sessionStorage.clear()
        _this.props.logout()
        _this.props.history.replace('/login')
      },
      onCancel() {}
@@ -64,12 +55,12 @@
    // 获取主菜单
    let _param = {
      func: 's_get_pc_menus',
      systemType: options.sysType,
      systemType: window.GLOB.sysType,
      pro_sys: window.GLOB.systemType === 'production' ? 'Y' : '',
      debug: 'Y'
    }
    let result = await Api.getSystemConfig(_param)
    let result = await Api.getCloudConfig(_param)
    // 登录超时
    if (!result) return
@@ -189,6 +180,7 @@
  }
  changeEditState = () => {
    sessionStorage.removeItem('isEditState')
    this.props.history.replace('/main')
    window.location.reload()
  }
@@ -214,7 +206,7 @@
      this.setState({
        loading: true
      })
      Api.getSystemConfig(param).then(res => {
      Api.getCloudConfig(param).then(res => {
        if (res.status) {
          this.setState({
            loading: false,
@@ -319,7 +311,7 @@
      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
      param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证
      
      Api.getSystemConfig(param).then(res => {
      Api.getCloudConfig(param).then(res => {
        let msgs = []
        if (!res.status) {
          notification.warning({
@@ -336,7 +328,6 @@
  }
  
  UNSAFE_componentWillMount () {
    sessionStorage.setItem('isEditState', 'true')
    document.body.className = ''
    
    // 组件加载时,获取菜单数据
@@ -357,7 +348,7 @@
    if (window.GLOB.systemType !== 'production') {
      setTimeout(() => {
        Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
        Api.getCloudConfig({func: 'sPC_Get_Roles_sModular'}).then(res => {
          if (res.status) {
            let _permFuncField = []
            let _sysRoles = []
@@ -388,7 +379,8 @@
      }, 100)
      setTimeout(() => {
        this.setSystemFuncs()
        // positecgroup
        // this.setSystemFuncs()
        this.getSmStemp()
      }, 500)
    }
@@ -405,11 +397,11 @@
  }
  gotoDoc = () => {
    if (options.sysType === 'local' && window.GLOB.mainSystemApi) {
    if (window.GLOB.sysType === 'local' && window.GLOB.mainSystemApi) {
      let ssodomain = window.GLOB.mainSystemApi.replace('/webapi/dostars', '')
      let url = `${ssodomain}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`
      window.open(url)
    } else if (options.sysType === 'SSO' || options.sysType === 'cloud') {
    } else if (window.GLOB.sysType === 'SSO' || window.GLOB.sysType === 'cloud') {
      window.open(`${window.location.href.replace(/\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
    }
  }
@@ -511,7 +503,7 @@
              <Switch size="small" style={{marginLeft: '7px'}} disabled={!!editLevel} checked={true} onChange={this.changeEditState} />
            </Menu.Item>
            <Menu.Item key="doc" onClick={this.gotoDoc}>文档中心</Menu.Item>
            {options.sysType !== 'cloud' ? <Menu.Item style={{padding: 0}} key="verup">
            {window.GLOB.sysType !== 'cloud' ? <Menu.Item style={{padding: 0}} key="verup">
              <VersionsUp />
            </Menu.Item> : null}
            <Menu.Item key="logout" onClick={this.logout}>退出</Menu.Item>
@@ -543,21 +535,4 @@
  }
}
const mapStateToProps = (state) => {
  return {
    menuTree: state.menuTree,
    mainMenu: state.mainMenu,
    editLevel: state.editLevel
  }
}
const mapDispatchToProps = (dispatch) => {
  return {
    modifyMenuTree: (menuTree) => dispatch(modifyMenuTree(menuTree)),
    modifyMainMenu: (mainMenu) => dispatch(modifyMainMenu(mainMenu)),
    resetEditLevel: (level) => dispatch(resetEditLevel(level)),
    logout: () => dispatch(logout())
  }
}
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header))
export default withRouter(Header)