king
2022-08-06 cbeffcc0902631909c0373f274752a97ddaf2d4e
src/components/header/index.jsx
@@ -14,7 +14,7 @@
  initMenuPermission,
  logout
} from '@/store/action'
import asyncComponent from '@/utils/asyncComponent'
import asyncComponent from '@/utils/asyncSpinComponent'
import Api from '@/api'
import MKEmitter from '@/utils/events.js'
import options from '@/store/options.js'
@@ -38,7 +38,8 @@
    visible: false, // 修改密码模态框
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    confirmLoading: false,
    userName: sessionStorage.getItem('User_Name'),
    userName: '',
    fullName: '',
    logourl: window.GLOB.mainlogo,
    appVersion: window.GLOB.appVersion,
    loginVisible: false,
@@ -66,6 +67,8 @@
  }
  resetPwdSubmit = () => {
    if (!this.formRef) return
    this.formRef.handleConfirm().then(res => {
      this.setState({
        confirmLoading: true
@@ -398,12 +401,31 @@
  }
  loginSubmit = () => {
    if (!this.loginRef) return
    this.setState({
      loginLoading: true
    })
    this.loginRef.handleConfirm().then(param => {
      Api.getusermsg(param.username, param.password, true).then(res => {
        if (res.status) {
          this.setState({
            loginLoading: false
          })
          if (res.modifydate) {
            let s = (new Date().getTime() - new Date(res.modifydate).getTime()) / (1000 * 24 * 60 * 60)
            if (!isNaN(s) && s > 90) {
              Modal.warning({
                width: 520,
                title: <span>系统检测到您的账户存在风险,请及时到<a target="_blank" rel="noopener noreferrer" href="https://cloud.mk9h.cn/admin/index.html">云中心</a>修改密码!</span>,
                okText: '知道了'
              })
              return
            }
          }
          sessionStorage.setItem('CloudUserID', res.UserID)
          sessionStorage.setItem('CloudLoginUID', res.LoginUID)
          sessionStorage.setItem('CloudUserName', res.UserName)
@@ -609,6 +631,15 @@
  UNSAFE_componentWillMount () {
    // 组件加载时,获取菜单数据
    this.getRolesMenu()
    let fullName = sessionStorage.getItem('Full_Name') || ''
    let userName = sessionStorage.getItem('User_Name') || ''
    if (fullName.toLowerCase() === userName.toLowerCase()) {
      userName = ''
    }
    this.setState({fullName, userName})
  }
  componentDidMount () {
@@ -643,7 +674,7 @@
      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') {
      window.open(`${window.location.href.replace(/\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
      window.open(`${window.location.href.replace(/\/admin(.*)|\/index.html(.*)|\/#(.*)/ig, '')}/doc/index.html#?appkey=${window.GLOB.appkey}&LoginUID=${sessionStorage.getItem('LoginUID')}`)
    }
  }
@@ -838,7 +869,7 @@
          <div>
            <img src={this.state.avatar || avatar} alt=""/>
            <span>
              <span className="username">{this.state.userName}</span> <DownOutlined />
              <span className="username"><span>{this.state.fullName}</span>{this.state.userName ? <span>{this.state.userName}</span> : null}</span> <DownOutlined />
            </span>
          </div>
        </Dropdown>