import React from 'react' import ReactDOM from 'react-dom' import {Provider} from 'react-redux' import Route from './router' import store from '@/store' import './index.css' import * as serviceWorker from './serviceWorker' // import VConsole from 'vconsole/dist/vconsole.min.js' // new VConsole() const render = Component => { ReactDOM.render( , document.getElementById('root') ) } if (!localStorage.getItem('SessionUid')) { localStorage.setItem('SessionUid', (() => { let uuid = [] let _options = '0123456789abcdefghigklmnopqrstuv' for (let i = 0; i < 32; i++) { uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) } return uuid.join('') })()) } fetch(`./options.json`) .then(response => response.json()) .catch(() => { document.getElementById('root').innerHTML = '系统配置信息获取失败,请联系管理员!' document.getElementById('root').className = 'config-error' }) .then(config => { if (!config) return window.GLOB = {} window.GLOB.appId = config.appId || '' window.GLOB.mainSystemApi = config.mainSystemApi || '' window.GLOB.filter = config.filter || '' window.GLOB.appkey = config.appkey window.GLOB.systemType = 'H5' let agent = navigator.userAgent.toLowerCase() console.log(agent) if (agent.indexOf('android') > -1) { window.GLOB.systemType = 'android' } else if (agent.indexOf('iphone') > -1 || agent.indexOf('ipad') > -1) { window.GLOB.systemType = 'ios' } if (window.wx && window.wx.miniProgram && agent.match(/MicroMessenger/i) === 'micromessenger') { window.wx.miniProgram.getEnv((res) => { if (res.miniprogram) { window.GLOB.systemType = 'miniProgram' } }) } console.log('systemType: ' + window.GLOB.systemType) if (process.env.NODE_ENV === 'production') { // 用于校验是否存在开发权限 window.GLOB.service = window.location.href.replace(/\/mob(.*)/ig, '').replace(new RegExp(document.location.origin + '/?', 'ig'), '') } else { window.GLOB.service = 'mkwms/' } render(Route) }) serviceWorker.unregister()