From 99966d855531d813197190f68e84f409f4eb1e61 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 10 三月 2022 18:50:37 +0800
Subject: [PATCH] 2022-03-10

---
 src/index.js |   45 ++++++++++++++++++++++++++-------------------
 1 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/src/index.js b/src/index.js
index c5526ea..033544f 100644
--- a/src/index.js
+++ b/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'))
 }
 
@@ -36,7 +34,7 @@
   })())
 }
 
-const render  = Component => {
+const render = Component => {
   ReactDOM.render(
     <Provider store={store}>
       <Component/>
@@ -45,15 +43,7 @@
   )
 }
 
-if (sessionStorage.getItem('loginError')) {
-  try {
-    let res = JSON.parse(sessionStorage.getItem('loginError'))
-    console.info(res.request)
-    console.info(res.response)
-  } catch (e) {}
-}
 sessionStorage.removeItem('isEditState')
-sessionStorage.removeItem('loginError')
 sessionStorage.setItem('role_id', sessionStorage.getItem('localRole_id') || '')
 sessionStorage.setItem('dataM', sessionStorage.getItem('localDataM') || '')
 
@@ -67,11 +57,19 @@
   .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
+    GLOB.watermark = config.watermark !== false
 
     if (config.externalDatabase !== false && config.externalDatabase !== 'false' && config.externalDatabase !== undefined) {
       GLOB.externalDatabase = config.externalDatabase ? `[${config.externalDatabase}]..` : ''
@@ -121,7 +119,7 @@
           systemApi = systemApi.replace(/\/?$/, '/webapi/dostars')
         }
 
-        if (systemApi.indexOf('sso.mk9h.cn') > -1 && process.env.NODE_ENV === 'production') {
+        if (systemApi.indexOf('sso.mk9h.cn') > -1 && GLOB.watermark) {
           GLOB.dataFormat = true
         }
       
@@ -130,12 +128,6 @@
     }
 
     let _href = window.location.href.split('#')[0]
-
-    if (localStorage.getItem(_href + 'lang')) {
-      sessionStorage.setItem('lang', localStorage.getItem(_href + 'lang'))
-    } else {
-      sessionStorage.setItem('lang', config.defaultLang !== 'en-US' ? 'zh-CN' : 'en-US')
-    }
 
     let _systemMsg = localStorage.getItem(_href + 'system')
 
@@ -190,10 +182,25 @@
         GLOB.linkurl = GLOB.linkurl + 'index.html'
       }
       GLOB.service = _service ? _service + '/' : ''
+      GLOB.host = window.location.host + (_service ? '_' + _service : '')
     } else {
       GLOB.linkurl = ''
       GLOB.location = config.host
       GLOB.service = config.service
+      GLOB.host = config.host.replace(/http(s)?:\/\//ig, '') + (config.service ? '_' + config.service.replace(/\//ig, '') : '')
+    }
+
+    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', {

--
Gitblit v1.8.0