| | |
| | | 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(); |