| | |
| | | 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' |
| | |
| | | } |
| | | return uuid.join('') |
| | | })()) |
| | | } |
| | | |
| | | const render = Component => { |
| | | ReactDOM.render( |
| | | <Component/>, |
| | | document.getElementById('root') |
| | | ) |
| | | } |
| | | |
| | | fetch('../options.json') |
| | |
| | | GLOB.upStatus = false |
| | | GLOB.navBar = 'shutter' // 默认为百叶窗 |
| | | GLOB.style = 'bg_black_style_blue' |
| | | GLOB.defLang = '' |
| | | |
| | | if (langs[config.defaultLang]) { |
| | | GLOB.defLang = config.defaultLang |
| | | } |
| | | |
| | | GLOB.sysType = options.sysType |
| | | if (GLOB.sysType !== 'cloud') { |
| | |
| | | } |
| | | } |
| | | |
| | | 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) { |
| | |
| | | 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 |
| | | |
| | | 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 (lang !== 'zh-CN') { |
| | | GLOB.WXNotice = false |
| | | } |
| | | |
| | | if (config.mainkey && GLOB.sysType !== 'cloud' && config.mainkey !== options.cakey) { |
| | | GLOB.localkey = GLOB.appkey |
| | | GLOB.appkey = config.mainkey |
| | | } |
| | | |
| | | let lang = localStorage.getItem(_href + 'lang') || (config.defaultLang !== 'en-US' ? 'zh-CN' : 'en-US') |
| | | sessionStorage.setItem('lang', lang) |
| | | |
| | | if (localStorage.getItem(_href + 'files') === md5(_href + 'files')) { |
| | | let d = localStorage.getItem(_href + 'filesDate') |
| | | 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) |
| | |
| | | d = d.slice(0, 4) + '-' + d.slice(4, 6) + '-' + d.slice(6) |
| | | GLOB.storeDate = Math.ceil((new Date(d).getTime() - new Date().getTime()) / 86400000) |
| | | } |
| | | } |
| | | |
| | | GLOB.dict = {} |
| | | |
| | | 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 = {} // 按钮权限集 |
| | |
| | | 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() |