king
2020-07-20 2dc12c551cd60f2e3c976ed608d260b1d78ce759
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';
const render  = Component => {
ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
    <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();