From fe837c3f5cc3aec41031d0f338a424b8b7949137 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 20 十一月 2024 16:07:14 +0800
Subject: [PATCH] 2024-11-20

---
 src/index.js |   87 +++++++++++++++++++++++++++++++++----------
 1 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/src/index.js b/src/index.js
index 3fd7db9..e8d944c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,5 +1,8 @@
 import React from 'react'
 import ReactDOM from 'react-dom'
+import { ConfigProvider } from 'antd'
+import zhCN from 'antd/es/locale/zh_CN'
+
 import Route from './router'
 import md5 from 'md5'
 import * as serviceWorker from './serviceWorker'
@@ -9,21 +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('')
-  })())
-}
+  })()
 
-const render = Component => {
-  ReactDOM.render(
-    <Component/>,
-    document.getElementById('root')
-  )
+  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')
@@ -41,6 +46,8 @@
       }
     }
 
+    config.keepPwd = config.keepPwd || config.keepPassword
+
     let GLOB = {}
     GLOB.appId = config.appId || ''
     GLOB.lineColor = config.lineColor || ''
@@ -48,13 +55,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
@@ -62,6 +70,13 @@
     GLOB.navBar = 'shutter' // 榛樿涓虹櫨鍙剁獥
     GLOB.style = 'bg_black_style_blue'
     GLOB.defLang = ''
+
+    if (config.WXApps) {
+      config.WXApps = config.WXApps.filter(app => app.appId && app.appName && ['public', 'miniProgram', 'merchant'].includes(app.appType))
+      if (config.WXApps.length) {
+        GLOB.WXApps = config.WXApps
+      }
+    }
 
     if (langs[config.defaultLang]) {
       GLOB.defLang = config.defaultLang
@@ -163,6 +178,11 @@
       if (GLOB.cloudServiceApi) {
         GLOB.mainSystemApi = GLOB.cloudServiceApi
       }
+
+      if (config.systemRun === 'backend') {
+        config.systemRun = '' // hs 涓嶄娇鐢ㄥ悗绔浛鎹�
+        GLOB.backend = true
+      }
     }
 
     if (process.env.NODE_ENV === 'production') { // 鐢ㄤ簬鏍¢獙鏄惁瀛樺湪寮�鍙戞潈闄�
@@ -178,14 +198,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
@@ -340,7 +360,22 @@
       GLOB.memberLevel = 0
     }
 
-    if (GLOB.sysType === 'cloud') {
+    if (config.systemRun === 'backend') {
+      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
@@ -369,7 +404,19 @@
     window.GLOB.SyncData = new Map()     // 瀛樺偍鍚屾鏌ヨ鏁版嵁
     window.GLOB.mkThdMenus = new Map()   // 涓夌骇鑿滃崟
 
-    render(Route)
+    if (lang === 'zh-CN' || !/#\/(login|main|billprint|docprint|tab|iframe|view|ssologin)/.test(window.location.href)) { // 寮�鍙戜娇鐢ㄤ腑鏂�
+      ReactDOM.render(
+        <ConfigProvider locale={zhCN}>
+          <Route/>
+        </ConfigProvider>,
+        document.getElementById('root')
+      )
+    } else {
+      ReactDOM.render(
+        <Route/>,
+        document.getElementById('root')
+      )
+    }
   })
 
 serviceWorker.unregister()

--
Gitblit v1.8.0