king
2022-03-10 da305b2c5f325504b17e64f4cd4faf4f1427470e
src/index.js
@@ -83,44 +83,52 @@
      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 = ''
    }
    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 && GLOB.watermark) {
          GLOB.dataFormat = true
        }
      
        GLOB.mainSystemApi = systemApi