From c8804ceb1fe2dea76f9949c5ea04423876ee2c81 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 28 六月 2024 14:02:47 +0800
Subject: [PATCH] 2024-06-28

---
 src/index.js |  132 ++++++++++++++++++++++++++++++++-----------
 1 files changed, 97 insertions(+), 35 deletions(-)

diff --git a/src/index.js b/src/index.js
index 2b532b4..b1f8d21 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,9 +1,12 @@
 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'
-import options, { styles } from '@/store/options.js'
+import options, { styles, langs } from '@/store/options.js'
 import '@/assets/css/main.scss'
 import '@/assets/css/action.scss'
 import '@/assets/css/viewstyle.scss'
@@ -17,13 +20,6 @@
     }
     return uuid.join('')
   })())
-}
-
-const render = Component => {
-  ReactDOM.render(
-    <Component/>,
-    document.getElementById('root')
-  )
 }
 
 fetch('../options.json')
@@ -61,6 +57,18 @@
     GLOB.upStatus = false
     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'].includes(app.appType))
+      if (config.WXApps.length) {
+        GLOB.WXApps = config.WXApps
+      }
+    }
+
+    if (langs[config.defaultLang]) {
+      GLOB.defLang = config.defaultLang
+    }
 
     GLOB.sysType = options.sysType
     if (GLOB.sysType !== 'cloud') {
@@ -160,8 +168,39 @@
       }
     }
 
-    let _href = window.location.href.split('#')[0]
-    let _systemMsg = localStorage.getItem(_href + 'system')
+    if (process.env.NODE_ENV === 'production') { // 鐢ㄤ簬鏍¢獙鏄惁瀛樺湪寮�鍙戞潈闄�
+      let _service = window.location.href.replace(/\/admin(.*)/ig, '').replace(new RegExp(document.location.origin + '/?', 'ig'), '')
+      GLOB.service = _service ? _service + '/' : ''
+      GLOB.host = window.location.host + (_service ? '_' + _service : '')
+      GLOB.baseurl = document.location.origin + '/' + GLOB.service
+      GLOB.linkurl = GLOB.baseurl + 'index.html'
+    } else {
+      GLOB.location = config.host
+      GLOB.service = config.service
+      GLOB.host = config.host.replace(/http(s)?:\/\//ig, '') + (config.service ? '_' + config.service.replace(/\//ig, '') : '')
+      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)
+    }
+
+    if (config.mainkey && GLOB.sysType !== 'cloud' && config.mainkey !== options.cakey) {
+      GLOB.localkey = GLOB.appkey
+      GLOB.appkey = config.mainkey
+    }
+
+    let lang = localStorage.getItem(window.location.href.split('#')[0] + 'lang') || GLOB.defLang || 'zh-CN'
+    sessionStorage.setItem('lang', lang)
+
+    GLOB.sysSign = GLOB.service + 'admin/' + lang + '/'
+
+    let _systemMsg = localStorage.getItem(GLOB.sysSign + 'system')
     let className = 'mk-blue-black'
 
     if (_systemMsg) {
@@ -224,35 +263,45 @@
       GLOB.filter = true
     }
 
-    if (process.env.NODE_ENV === 'production') { // 鐢ㄤ簬鏍¢獙鏄惁瀛樺湪寮�鍙戞潈闄�
-      let _service = window.location.href.replace(/\/admin(.*)/ig, '').replace(new RegExp(document.location.origin + '/?', 'ig'), '')
-      GLOB.service = _service ? _service + '/' : ''
-      GLOB.host = window.location.host + (_service ? '_' + _service : '')
-      GLOB.baseurl = document.location.origin + '/' + GLOB.service
-      GLOB.linkurl = GLOB.baseurl + 'index.html'
-    } else {
-      GLOB.location = config.host
-      GLOB.service = config.service
-      GLOB.host = config.host.replace(/http(s)?:\/\//ig, '') + (config.service ? '_' + config.service.replace(/\//ig, '') : '')
-      GLOB.baseurl = GLOB.location + '/' + GLOB.service
-      GLOB.linkurl = GLOB.baseurl + 'index.html'
-      GLOB.dataFormat = false
+    if (lang !== 'zh-CN') {
+      GLOB.WXNotice = false
+    }
 
-      let mark = sessionStorage.getItem('system_mark')
-      let _mark = `sys_${GLOB.service.replace('/', '') || 'service'}`
-      if (mark && mark !== _mark) {
-        sessionStorage.clear()
+    if (localStorage.getItem(GLOB.sysSign + 'files') === md5(GLOB.sysSign + 'files')) {
+      let d = localStorage.getItem(GLOB.sysSign + 'filesDate')
+
+      GLOB.storeFiles = true
+      GLOB.storeDate = Math.ceil((new Date(d).getTime() - new Date().getTime()) / 86400000)
+    } else if (GLOB.licenseKey && config.storeKey && config.storeKey.length === 16) {
+      let trans = {A:0, B:1, C:2, D:3, E:4, F:5, G:6, H:7, I:8, J:9}
+      let d = config.storeKey.slice(0, 8)
+
+      d = d.split('').map(k => trans[k]).join('')
+
+      let key = config.storeKey.slice(8)
+      let _key = GLOB.appId + GLOB.appkey + 'e_files_key' + d
+      _key = md5(_key.toLowerCase())
+      _key = _key.toUpperCase()
+      _key = _key.slice(-8)
+
+      if (key === _key) {
+        GLOB.storeFiles = true
+        
+        d = d.slice(0, 4) + '-' + d.slice(4, 6) + '-' + d.slice(6)
+        GLOB.storeDate = Math.ceil((new Date(d).getTime() - new Date().getTime()) / 86400000)
       }
-      sessionStorage.setItem('system_mark', _mark)
     }
 
-    if (config.mainkey && GLOB.sysType !== 'cloud' && config.mainkey !== options.cakey) {
-      GLOB.localkey = GLOB.appkey
-      GLOB.appkey = config.mainkey
-    }
+    GLOB.dict = {}
 
-    let lang = localStorage.getItem(_href + 'lang') || (config.defaultLang !== 'en-US' ? 'zh-CN' : 'en-US')
-    sessionStorage.setItem('lang', lang)
+    if (localStorage.getItem(GLOB.sysSign + 'js_trans')) {
+      let js_trans = JSON.parse(localStorage.getItem(GLOB.sysSign + 'js_trans'))
+
+      js_trans.forEach(item => {
+        if (lang !== item.lang) return
+        GLOB.dict[item.key] = item.val
+      })
+    }
 
     GLOB.mkActions = {}  // 鎸夐挳鏉冮檺闆�
 
@@ -323,7 +372,20 @@
     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