king
2021-03-01 c45a375e5b4ce0e33c7fc8a1aecdad67d60acc9e
src/index.js
@@ -4,7 +4,7 @@
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,7 +45,6 @@
  )
}
if (sessionStorage.getItem('loginError')) {
  try {
    let res = JSON.parse(sessionStorage.getItem('loginError'))
@@ -56,10 +57,12 @@
sessionStorage.setItem('role_id', sessionStorage.getItem('localRole_id') || '')
sessionStorage.setItem('dataM', sessionStorage.getItem('localDataM') || '')
fetch(`./options.json`)
// 测试系统文件置于admin中
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
@@ -134,6 +137,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')
    if (_systemMsg) {
@@ -152,6 +159,7 @@
        GLOB.webSite = _systemMsg.webSite
        GLOB.style = _systemMsg.style
        GLOB.showline = _systemMsg.showline || ''
        GLOB.navBar = _systemMsg.navBar || 'sidemenu'
        if (GLOB.favicon) {
          let link = document.querySelector("link[rel*='icon']") || document.createElement('link')
@@ -160,8 +168,8 @@
          link.href = GLOB.favicon
          document.getElementsByTagName('head')[0].appendChild(link)
        }
        if (GLOB.style && options.styles[GLOB.style]) {
          document.body.className = options.styles[GLOB.style] + ' ' + (GLOB.showline === 'false' ? 'hidden-split-line' : '')
        if (GLOB.style && styles[GLOB.style]) {
          document.body.className = styles[GLOB.style] + ' ' + (GLOB.showline === 'false' ? 'hidden-split-line' : '')
        }
      } catch {
        console.warn('Parse Failure')
@@ -179,7 +187,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'
@@ -189,10 +197,6 @@
      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]
    }
    Object.defineProperty(GLOB, 'appId', {