king
2022-03-21 fc241324087e605b145e8bbcc4ee3aece61dbf14
src/index.js
@@ -43,15 +43,7 @@
  )
}
if (sessionStorage.getItem('loginError')) {
  try {
    let res = JSON.parse(sessionStorage.getItem('loginError'))
    console.info(res.request)
    console.info(res.response)
  } catch (e) {}
}
sessionStorage.removeItem('isEditState')
sessionStorage.removeItem('loginError')
sessionStorage.setItem('role_id', sessionStorage.getItem('localRole_id') || '')
sessionStorage.setItem('dataM', sessionStorage.getItem('localDataM') || '')
@@ -77,6 +69,7 @@
    GLOB.lineColor = config.lineColor || ''
    GLOB.licenseKey = config.licenseKey || ''
    GLOB.probation = false
    GLOB.watermark = config.watermark !== false
    if (config.externalDatabase !== false && config.externalDatabase !== 'false' && config.externalDatabase !== undefined) {
      GLOB.externalDatabase = config.externalDatabase ? `[${config.externalDatabase}]..` : ''
@@ -90,44 +83,54 @@
      if (config.probation && /^20\d{2}-\d{2}-\d{2}$/.test(config.probation) && new Date(config.probation).getTime() > new Date().getTime()) {
        GLOB.probation = true
      }
      if (!config.mainSystemApi) {
        document.getElementById('root').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh;">系统未设置单点地址,请联系管理员!</div>'
        return
      } else if (/http(s?):\/\/sso.mk9h.cn\/cloud/ig.test(config.mainSystemApi)) {
        document.getElementById('root').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh;">正式系统不可使用 http://sso.mk9h.cn/cloud 做为单点地址,请联系管理员!</div>'
        return
      } else if (/http(s?):\/\/cloud.mk9h.cn/ig.test(config.mainSystemApi)) {
        document.getElementById('root').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh;">正式系统不可使用 http://cloud.mk9h.cn 做为单点地址,请联系管理员!</div>'
        return
      }
    } else if (options.sysType === 'local') {
      GLOB.probation = true
      GLOB.systemType = ''
      // GLOB.mainSystemApi = 'https://cloud.positecgroup.com/webapi/dostars'
      GLOB.mainSystemApi = 'http://sso.mk9h.cn/cloud/webapi/dostars'
      if (GLOB.watermark) {
        GLOB.dataFormat = true
      }
    } else {
      GLOB.systemType = ''
      GLOB.mainSystemApi = ''
    }
    GLOB.debugger = options.sysType === 'local' && GLOB.systemType !== 'production'
    if (options.sysType !== 'cloud') {
      if (config.appkey === options.cakey) {
        document.getElementById('root').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh;">不可使用云端appkey,请联系管理员!</div>'
        return
      }
    }
    if (options.sysType === 'cloud') { // cloud不可设置单点服务器地址,云端appkey为系统设置
      GLOB.appkey = options.cakey
      GLOB.mainSystemApi = ''
    } else if (options.sysType === 'SSO') { // sso不可设置单点服务器地址
      GLOB.mainSystemApi = ''
      if (config.appkey === options.cakey) {
        GLOB.appkey = ''
        console.warn('单点系统appkey不可与云端相同')
      } else {
        GLOB.appkey = config.appkey
      }
      GLOB.appkey = config.appkey
    } else if (options.sysType === 'local') { // 业务系统
      if (config.appkey === options.cakey) {
        GLOB.appkey = ''
        console.warn('业务系统appkey不可与云端相同')
      } else {
        GLOB.appkey = config.appkey
      }
      if (config.mainSystemApi) {
      GLOB.appkey = config.appkey
      if (GLOB.systemType === 'production') {
        let systemApi = config.mainSystemApi
        // 业务系统不允许连接云端,业务系统连接sso.mk9h.cn时,数据虚化处理
        if (systemApi.indexOf('cloud.mk9h.cn') > -1) {
          systemApi = ''
        } else if (/index.html/ig.test(systemApi)) {
        if (/index.html/ig.test(systemApi)) {
          systemApi = systemApi.replace(/index.html.*/ig, 'webapi/dostars')
        } else if (!/webapi\/dostars$/ig.test(systemApi)) {
          systemApi = systemApi.replace(/\/?$/, '/webapi/dostars')
        }
        if (systemApi.indexOf('sso.mk9h.cn') > -1 && process.env.NODE_ENV === 'production') {
          GLOB.dataFormat = true
        }
      
        GLOB.mainSystemApi = systemApi
@@ -189,10 +192,12 @@
        GLOB.linkurl = GLOB.linkurl + 'index.html'
      }
      GLOB.service = _service ? _service + '/' : ''
      GLOB.host = window.location.host + (_service ? '_' + _service : '')
    } else {
      GLOB.linkurl = ''
      GLOB.location = config.host
      GLOB.service = config.service
      GLOB.host = config.host.replace(/http(s)?:\/\//ig, '') + (config.service ? '_' + config.service.replace(/\//ig, '') : '')
    }
    let mark = sessionStorage.getItem('system_mark')
@@ -220,6 +225,10 @@
      writable: false,
      value: GLOB.systemType
    })
    Object.defineProperty(GLOB, 'debugger', {
      writable: false,
      value: GLOB.debugger
    })
    Object.defineProperty(GLOB, 'mainSystemApi', {
      writable: false,
      value: GLOB.mainSystemApi