From 29432c9167e3fcdf83f35d0bb9dbe9acb7c7ffbf Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 22 六月 2021 14:35:23 +0800 Subject: [PATCH] 2021-06-22 --- src/index.js | 74 ++++++++++++++++++++---------------- 1 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/index.js b/src/index.js index 7e310fb..fcc809d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,10 @@ import React from 'react' import ReactDOM from 'react-dom' import Route from './router' -import {Provider} from 'react-redux' +import { Provider } from 'react-redux' import store from '@/store' import * as serviceWorker from './serviceWorker' -import options from '@/store/options.js' +import options, { styles } from '@/store/options.js' import '@/assets/css/main.scss' import '@/assets/css/action.scss' import '@/assets/css/minkeicon.css' @@ -12,6 +12,8 @@ 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) { // 缂栬緫椤甸潰鍒锋柊鏃讹紝璺宠浆鑷充富椤� + window.location.replace(window.location.href.replace(/design/ig, 'main')) } options.sysType = window.atob(options.sysType.replace('$mk', '')) @@ -43,21 +45,37 @@ ) } +if (sessionStorage.getItem('loginError')) { + try { + let res = JSON.parse(sessionStorage.getItem('loginError')) + console.info(res.request) + console.info(res.response) + } catch {} +} sessionStorage.removeItem('isEditState') +sessionStorage.removeItem('loginError') +sessionStorage.setItem('role_id', sessionStorage.getItem('localRole_id') || '') +sessionStorage.setItem('dataM', sessionStorage.getItem('localDataM') || '') -// fetch(`./${process.env.NODE_ENV === 'production' ? 'build/' : ''}options.json`) -fetch(`./options.json`) +// 鏂扮郴缁熸枃浠剁疆浜巃dmin涓� ../options.json + +fetch('./options.json') .then(response => response.json()) .catch(() => { - console.warn('绯荤粺閰嶇疆淇℃伅鑾峰彇澶辫触锛岃鑱旂郴绠$悊鍛橈紒') + document.getElementById('root').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh;">绯荤粺閰嶇疆淇℃伅鑾峰彇澶辫触锛岃鑱旂郴绠$悊鍛橈紒</div>' }) .then(config => { if (!config) return - + let GLOB = {} GLOB.appId = config.appId || '' GLOB.lineColor = config.lineColor || '' - GLOB.filter = config.filter || '' + + if (config.externalDatabase !== false && config.externalDatabase !== 'false' && config.externalDatabase !== undefined) { + GLOB.externalDatabase = config.externalDatabase ? `[${config.externalDatabase}]..` : '' + } else { + GLOB.externalDatabase = null + } // 鍙湁涓氬姟绯荤粺鎵嶅彲浠ヨ缃负姝e紡绯荤粺 if (options.sysType === 'local' && (config.systemType === 'official' || config.systemType === 'production')) { @@ -86,24 +104,6 @@ } if (config.mainSystemApi) { let systemApi = config.mainSystemApi - - // if (/^(http|https):\/\//ig.test(systemApi)) { - // let _systemApi = /^(http|https):\/\/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62}|(:[0-9]{1,4}))+\.?/ig.exec(systemApi) - - // systemApi = _systemApi ? _systemApi[0] : '' - // } else { - // systemApi = '' - // } - - // // 涓氬姟绯荤粺杩炴帴浜戠鏃讹紝鏍煎紡鍖栧鐞� - // if (systemApi && systemApi === /^(http|https):\/\/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62}|(:[0-9]{1,4}))+\.?/ig.exec(options.cloudServiceApi)[0]) { - // GLOB.dataFormat = true - // } - - // if (systemApi) { - // systemApi = systemApi + '/webapi/dostars' - // } - // 涓氬姟绯荤粺涓嶅厑璁歌繛鎺ヤ簯绔紝涓氬姟绯荤粺杩炴帴sso.mk9h.cn鏃讹紝鏁版嵁铏氬寲澶勭悊 if (systemApi && systemApi.indexOf('cloud.mk9h.cn') > -1) { systemApi = '' @@ -116,6 +116,10 @@ } let _href = window.location.href.split('#')[0] + + if (localStorage.getItem(_href + 'lang')) { + sessionStorage.setItem('lang', localStorage.getItem(_href + 'lang')) + } let _systemMsg = localStorage.getItem(_href + 'system') @@ -134,6 +138,8 @@ GLOB.doclogo = _systemMsg.doclogo GLOB.webSite = _systemMsg.webSite GLOB.style = _systemMsg.style + GLOB.showline = _systemMsg.showline || '' + GLOB.navBar = _systemMsg.navBar || '' if (GLOB.favicon) { let link = document.querySelector("link[rel*='icon']") || document.createElement('link') @@ -142,6 +148,9 @@ link.href = GLOB.favicon document.getElementsByTagName('head')[0].appendChild(link) } + if (GLOB.style && styles[GLOB.style]) { + document.body.className = styles[GLOB.style] + ' ' + (GLOB.showline === 'false' ? 'hidden-split-line' : '') + } } catch { console.warn('Parse Failure') } @@ -149,7 +158,7 @@ document.title = GLOB.platTitle || '' - if (GLOB.filter === 'true') { + if (config.filter === 'true') { let html = document.getElementsByTagName('html')[0] if (html) { @@ -158,7 +167,7 @@ } if (process.env.NODE_ENV === 'production') { // 鐢ㄤ簬鏍¢獙鏄惁瀛樺湪寮�鍙戞潈闄� - let _service = window.location.href.replace(/\/index.html(.*)|\/#(.*)/ig, '').replace(new RegExp(document.location.origin + '/?', 'ig'), '') + let _service = window.location.href.replace(/(\/admin)?\/index.html(.*)|(\/admin)?\/#(.*)/ig, '').replace(new RegExp(document.location.origin + '/?', 'ig'), '') GLOB.linkurl = _href if (!/index.html/ig.test(GLOB.linkurl)) { GLOB.linkurl = GLOB.linkurl + 'index.html' @@ -166,12 +175,8 @@ GLOB.service = _service ? _service + '/' : '' } else { GLOB.linkurl = '' - GLOB.location = 'http://qingqiumarket.cn/' - GLOB.service = 'mkwms/' - } - - if (GLOB.style && options.styles[GLOB.style]) { - document.getElementById('root').className = options.styles[GLOB.style] + GLOB.location = config.host + GLOB.service = config.service } Object.defineProperty(GLOB, 'appId', { @@ -203,6 +208,9 @@ value: GLOB }) + window.GLOB.CacheMap = new Map() // 缂撳瓨閰嶇疆淇℃伅 + window.GLOB.UserCacheMap = new Map() // 缂撳瓨鐢ㄦ埛鑷畾涔夎缃� + render(Route) }) -- Gitblit v1.8.0