From 5f69e3bf213ccc377dc118b89bb8db348eafbc1d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 24 十二月 2024 22:36:03 +0800 Subject: [PATCH] 2024-12-24 --- src/index.js | 77 +++++++++++++++++++++----------------- 1 files changed, 43 insertions(+), 34 deletions(-) diff --git a/src/index.js b/src/index.js index 3aea357..969f8b0 100644 --- a/src/index.js +++ b/src/index.js @@ -12,14 +12,23 @@ 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) + } fetch('../options.json') @@ -52,6 +61,7 @@ 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.mkHS = false GLOB.debugger = false @@ -156,6 +166,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涓嬩笉鎵撳嵃鑴氭湰 @@ -167,6 +181,11 @@ } if (GLOB.cloudServiceApi) { GLOB.mainSystemApi = GLOB.cloudServiceApi + } + + if (config.systemRun === 'backend') { + config.systemRun = '' // hs 涓嶄娇鐢ㄥ悗绔浛鎹� + GLOB.backend = true } } @@ -183,14 +202,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 @@ -345,36 +364,26 @@ GLOB.memberLevel = 0 } - if (config.devTools === false) { - sessionStorage.removeItem('breakpoint') - GLOB.debugger = false - - let getVal = () => { - let _i = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight - let _h = window.outerHeight - _i - 200 - let _w = window.outerWidth - window.innerWidth - 100 - - return Math.max(_h, _w) - } - - if (getVal() > 0) { - document.body.innerHTML = '<div style="text-align: center; font-size: 30px; padding-top: 40vh;">鏈郴缁熺姝娇鐢ㄦ帶鍒跺彴锛岃鍏抽棴鎺у埗鍙伴噸鏂板埛鏂帮紒</div>' - return + if (config.systemRun === 'backend') { + if (sessionStorage.getItem('systemRun') === 'front') { + GLOB.debugger = true } else { - let timer = null - window.addEventListener('resize', () => { - timer && clearTimeout(timer) - - if (getVal() > 0) { - timer = setTimeout(() => { - document.body.innerHTML = '<div style="text-align: center; font-size: 30px; padding-top: 40vh;">鏈郴缁熺姝娇鐢ㄦ帶鍒跺彴锛岃鍏抽棴鎺у埗鍙伴噸鏂板埛鏂帮紒</div>' - }, 100) - } + GLOB.debugger = false + Object.defineProperty(window, 'backend', { + writable: false, + value: true }) } } + if (config.debugger === 'forbid') { + sessionStorage.removeItem('breakpoint') + GLOB.debugger = false - if (GLOB.sysType === 'cloud') { + Object.defineProperty(GLOB, 'debugger', { + writable: false, + value: GLOB.debugger + }) + } else if (GLOB.sysType === 'cloud') { Object.defineProperty(GLOB, 'debugger', { writable: false, value: GLOB.debugger -- Gitblit v1.8.0