king
2022-01-17 92224e3d5e03f223bf2fb4b0eb88b74e790d8da9
src/index.js
@@ -10,9 +10,7 @@
import '@/assets/css/minkeicon.css'
import '@/assets/css/viewstyle.scss'
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  window.location.replace(window.location.href.split(/(index.html)+/ig)[0] + 'mob/index.html')
} else if (window.location.href.indexOf('#/design') > -1) { // 编辑页面刷新时,跳转至主页
if (window.location.href.indexOf('#/design') > -1) { // 编辑页面刷新时,跳转至主页
  window.location.replace(window.location.href.replace(/design/ig, 'main'))
}
@@ -50,7 +48,7 @@
    let res = JSON.parse(sessionStorage.getItem('loginError'))
    console.info(res.request)
    console.info(res.response)
  } catch {}
  } catch (e) {}
}
sessionStorage.removeItem('isEditState')
sessionStorage.removeItem('loginError')
@@ -67,10 +65,18 @@
  .then(config => {
    if (!config) return
    if (config.defaultApp) {
      if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
        window.location.replace(window.location.href.split(/(index.html)+/ig)[0].replace('admin/', '') + 'mob/index.html#/index')
        return
      }
    }
    let GLOB = {}
    GLOB.appId = config.appId || ''
    GLOB.lineColor = config.lineColor || ''
    GLOB.licenseKey = config.licenseKey || ''
    GLOB.probation = false
    if (config.externalDatabase !== false && config.externalDatabase !== 'false' && config.externalDatabase !== undefined) {
      GLOB.externalDatabase = config.externalDatabase ? `[${config.externalDatabase}]..` : ''
@@ -81,6 +87,12 @@
    // 只有业务系统才可以设置为正式系统
    if (options.sysType === 'local' && (config.systemType === 'official' || config.systemType === 'production')) {
      GLOB.systemType = 'production'
      if (config.probation && /^20\d{2}-\d{2}-\d{2}$/.test(config.probation) && new Date(config.probation).getTime() > new Date().getTime()) {
        GLOB.probation = true
      }
    } else if (options.sysType === 'local') {
      GLOB.probation = true
      GLOB.systemType = ''
    } else {
      GLOB.systemType = ''
    }
@@ -106,9 +118,15 @@
      if (config.mainSystemApi) {
        let systemApi = config.mainSystemApi
        // 业务系统不允许连接云端,业务系统连接sso.mk9h.cn时,数据虚化处理
        if (systemApi && systemApi.indexOf('cloud.mk9h.cn') > -1) {
        if (systemApi.indexOf('cloud.mk9h.cn') > -1) {
          systemApi = ''
        } else if (systemApi && systemApi.indexOf('sso.mk9h.cn') > -1 && process.env.NODE_ENV === 'production') {
        } else 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
        }
      
@@ -117,10 +135,6 @@
    }
    let _href = window.location.href.split('#')[0]
    if (localStorage.getItem(_href + 'lang')) {
      sessionStorage.setItem('lang', localStorage.getItem(_href + 'lang'))
    }
    let _systemMsg = localStorage.getItem(_href + 'system')
@@ -141,6 +155,7 @@
        GLOB.style = _systemMsg.style
        GLOB.showline = _systemMsg.showline || ''
        GLOB.navBar = _systemMsg.navBar || ''
        GLOB.appVersion = _systemMsg.app_version || ''
        if (GLOB.favicon) {
          let link = document.querySelector("link[rel*='icon']") || document.createElement('link')
@@ -152,7 +167,7 @@
        if (GLOB.style && styles[GLOB.style]) {
          document.body.className = styles[GLOB.style] + ' ' + (GLOB.showline === 'false' ? 'hidden-split-line' : '')
        }
      } catch {
      } catch (e) {
        console.warn('Parse Failure')
      }
    }
@@ -180,6 +195,19 @@
      GLOB.service = config.service
    }
    let mark = sessionStorage.getItem('system_mark')
    let _mark = `sys_${GLOB.service.replace('/', '') || 'service'}`
    if (mark && mark !== _mark) {
      sessionStorage.clear()
    }
    sessionStorage.setItem('system_mark', _mark)
    if (localStorage.getItem(_href + 'lang')) {
      sessionStorage.setItem('lang', localStorage.getItem(_href + 'lang'))
    } else {
      sessionStorage.setItem('lang', config.defaultLang !== 'en-US' ? 'zh-CN' : 'en-US')
    }
    Object.defineProperty(GLOB, 'appId', {
      writable: false,
      value: GLOB.appId