king
2025-03-05 f1a4a2e83a5a3a3f8636c0d85a3a02471c5b07e7
src/index.js
@@ -12,15 +12,37 @@
import '@/assets/css/viewstyle.scss'
if (!localStorage.getItem('SessionUid')) {
  localStorage.setItem('SessionUid', (() => {
  let sid = (() => {
    let uuid = []
    let _options = '0123456789abcdefghigklmnopqrstuv'
    for (let i = 0; i < 32; i++) {
      uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
    }
    return uuid.join('')
  })())
  })()
  if (/_mk_sid=[0-9a-z]{32}/.test(document.cookie)) {
    sid = document.cookie.match(/_mk_sid=[0-9a-z]{32}/)[0].split('=')[1]
  } else {
    document.cookie = '_mk_sid=' + sid
  }
  localStorage.setItem('SessionUid', sid)
}
sessionStorage.setItem('UserID', localStorage.getItem('UserID') || '')
sessionStorage.setItem('LoginUID', localStorage.getItem('LoginUID') || '')
sessionStorage.setItem('User_Name', localStorage.getItem('User_Name') || '')
sessionStorage.setItem('Full_Name', localStorage.getItem('Full_Name') || '')
sessionStorage.setItem('avatar', localStorage.getItem('avatar') || '')
sessionStorage.setItem('dataM', localStorage.getItem('dataM') || '')
sessionStorage.setItem('localDataM', localStorage.getItem('localDataM') || '')
sessionStorage.setItem('debug', localStorage.getItem('debug') || '')
sessionStorage.setItem('role_id', localStorage.getItem('role_id') || '')
sessionStorage.setItem('departmentcode', localStorage.getItem('departmentcode') || '')
sessionStorage.setItem('organization', localStorage.getItem('organization') || '')
sessionStorage.setItem('mk_user_type', localStorage.getItem('mk_user_type') || '')
fetch('../options.json')
  .then(response => response.json())
@@ -37,6 +59,8 @@
      }
    }
    config.keepPwd = config.keepPwd || config.keepPassword
    let GLOB = {}
    GLOB.appId = config.appId || ''
    GLOB.lineColor = config.lineColor || ''
@@ -44,13 +68,14 @@
    GLOB.probation = false
    GLOB.watermark = config.watermark + '' !== 'false'
    GLOB.transfer = config.transfer + '' === 'true'
    GLOB.keepKey = config.keepPassword + '' !== 'false'
    GLOB.nginx = config.nginx + '' === 'true'
    GLOB.keepKey = config.keepPwd + '' !== 'false'
    GLOB.vispwd = config.keepPwd + '' !== 'invisible'
    GLOB.WXAppID = config.WXAppID || ''
    GLOB.WXminiAppID = config.WXminiAppID || ''
    GLOB.WXMerchID = config.WXMerchID || ''
    GLOB.WXNotice = config.WXNotice + '' === 'true'
    GLOB.SysNotice = config.SysNotice + '' === 'true'
    GLOB.execType = config.execType === 'x' ? 'x' : ''
    GLOB.accessToken = {}
    GLOB.mkHS = false
    GLOB.debugger = false
    GLOB.dataFormat = false
@@ -60,7 +85,7 @@
    GLOB.defLang = ''
    if (config.WXApps) {
      config.WXApps = config.WXApps.filter(app => app.appId && app.appName && ['public', 'miniProgram'].includes(app.appType))
      config.WXApps = config.WXApps.filter(app => app.appId && app.appName && ['public', 'miniProgram', 'merchant'].includes(app.appType))
      if (config.WXApps.length) {
        GLOB.WXApps = config.WXApps
      }
@@ -106,16 +131,20 @@
      GLOB.systemType = 'production'
    } else if (GLOB.sysType === 'local') {
      GLOB.probation = true
      GLOB.debugger = true
      // GLOB.debugger = true
      GLOB.systemType = ''
      GLOB.upStatus = config.updateStatus + '' !== 'false'
      // GLOB.mainSystemApi = 'https://cloud.positecgroup.com/webapi/dostars'
      GLOB.mainSystemApi = 'https://cloud.positecgroup.com/webapi/dostars'
      GLOB.mainSystemApi = 'https://sso.mk9h.cn/cloud/webapi/dostars'
      if (!/^https/.test(window.location.protocol)) { // https转换
        GLOB.mainSystemApi = 'http://sso.mk9h.cn/cloud/webapi/dostars'
      if (config.style_appkey) {
        GLOB.style_appkey = config.style_appkey
      }
      // GLOB.mainSystemApi = 'https://sso.mk9h.cn/cloud/webapi/dostars'
      // if (!/^https/.test(window.location.protocol)) { // https转换
      //   GLOB.mainSystemApi = 'http://sso.mk9h.cn/cloud/webapi/dostars'
      // }
      if (GLOB.watermark) {
        GLOB.dataFormat = true
@@ -154,6 +183,10 @@
      
        GLOB.mainSystemApi = systemApi
      }
      if (config.errorLog === 'true' && /#\/(login|main|billprint|docprint|tab|iframe|view|ssologin)/.test(window.location.href)) {
        GLOB.errorLog = true
      }
    }
    if (/#\/hs$/.test(window.location.href)) { // hs下不打印脚本
@@ -166,6 +199,11 @@
      if (GLOB.cloudServiceApi) {
        GLOB.mainSystemApi = GLOB.cloudServiceApi
      }
      if (config.systemRun === 'backend') {
        config.systemRun = '' // hs 不使用后端替换
        GLOB.backend = true
      }
    }
    if (process.env.NODE_ENV === 'production') { // 用于校验是否存在开发权限
@@ -174,6 +212,7 @@
      GLOB.host = window.location.host + (_service ? '_' + _service : '')
      GLOB.baseurl = document.location.origin + '/' + GLOB.service
      GLOB.linkurl = GLOB.baseurl + 'index.html'
      GLOB.location = document.location.origin
    } else {
      GLOB.location = config.host
      GLOB.service = config.service
@@ -181,14 +220,14 @@
      GLOB.baseurl = GLOB.location + '/' + GLOB.service
      GLOB.linkurl = GLOB.baseurl + 'index.html'
      GLOB.dataFormat = false
      let mark = sessionStorage.getItem('system_mark')
      let _mark = `sys_${GLOB.service.replace('/', '') || 'service'}`
      if (mark && mark !== _mark) {
        sessionStorage.clear()
      }
      sessionStorage.setItem('system_mark', _mark)
    }
    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 (config.mainkey && GLOB.sysType !== 'cloud' && config.mainkey !== options.cakey) {
      GLOB.localkey = GLOB.appkey
@@ -250,7 +289,7 @@
    document.body.className = className
    if (/^https/.test(window.location.protocol)) { // https转换
    if (/^https/.test(window.location.protocol) || (process.env.NODE_ENV !== 'production' && /^https/.test(config.host))) { // https转换
      let meta = document.createElement('meta')
      meta.content = 'upgrade-insecure-requests'
      meta.httpEquiv = 'Content-Security-Policy'
@@ -343,7 +382,26 @@
      GLOB.memberLevel = 0
    }
    if (GLOB.sysType === 'cloud') {
    if (config.systemRun === 'backend') {
      if (sessionStorage.getItem('systemRun') === 'front') {
        GLOB.debugger = true
      } else {
        GLOB.debugger = false
        Object.defineProperty(window, 'backend', {
          writable: false,
          value: true
        })
      }
    }
    if (config.debugger === 'forbid') {
      sessionStorage.removeItem('breakpoint')
      GLOB.debugger = false
      Object.defineProperty(GLOB, 'debugger', {
        writable: false,
        value: GLOB.debugger
      })
    } else if (GLOB.sysType === 'cloud') {
      Object.defineProperty(GLOB, 'debugger', {
        writable: false,
        value: GLOB.debugger
@@ -385,7 +443,6 @@
        document.getElementById('root')
      )
    }
  })
serviceWorker.unregister()