From 2dc12c551cd60f2e3c976ed608d260b1d78ce759 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 20 七月 2020 18:02:20 +0800 Subject: [PATCH] mob init --- src/index.js | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index f5185c1..d90e636 100644 --- a/src/index.js +++ b/src/index.js @@ -1,17 +1,36 @@ 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 App from './App'; import * as serviceWorker from './serviceWorker'; -ReactDOM.render( - <React.StrictMode> - <App /> - </React.StrictMode>, - document.getElementById('root') -); +const render = Component => { + ReactDOM.render( + <Provider store={store}> + <Component/> + </Provider>, + document.getElementById('root') + ) +} -// If you want your app to work offline and load faster, you can change -// unregister() to register() below. Note this comes with some pitfalls. -// Learn more about service workers: https://bit.ly/CRA-PWA +fetch(`./${process.env.NODE_ENV === 'production' ? 'build/' : ''}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.lineColor = config.lineColor || '' + window.GLOB.filter = config.filter || '' + window.GLOB.appkey = config.appkey + + render(Route) + }) + serviceWorker.unregister(); -- Gitblit v1.8.0