index.tsx 1.58 KB
Newer Older
1
import React, { lazy, Suspense } from 'react';
2
import ReactDOM from 'react-dom';
Deshui Yu's avatar
Deshui Yu committed
3
import App from './App';
4
import { getPrefix } from './static/function';
5
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
Lijiaoa's avatar
Lijiaoa committed
6
7
8
9
10
const Overview = lazy(() => import('./components/experiment/overview/Overview'));
const TrialsDetail = lazy(() => import('./components/experiment/trialdetail/TrialsDetail'));
const ExperimentManagerIndex = lazy(() => import('./components/experimentManagement/ExperimentManagerIndex'));
import '@style/index.css';
import '@style/loading.scss';
11
import * as serviceWorker from './serviceWorker';
Deshui Yu's avatar
Deshui Yu committed
12

13
14
const path = getPrefix();

Deshui Yu's avatar
Deshui Yu committed
15
ReactDOM.render(
16
    <Router basename={path === undefined ? null : path}>
17
18
19
        <Suspense
            fallback={
                <div className='loading'>
Lijiaoa's avatar
Lijiaoa committed
20
                    <img title='loading-graph' src={(path || '') + '/loading.gif'} />
21
22
23
                </div>
            }
        >
Lijiaoa's avatar
Lijiaoa committed
24
            <Route path='/experiment' component={ExperimentManagerIndex} exact />
25
            <Switch>
26
                <App>
27
                    <Route path='/' component={Overview} exact />
28
29
                    <Route path='/oview' component={Overview} />
                    <Route path='/detail' component={TrialsDetail} />
30
                </App>
31
            </Switch>
32
        </Suspense>
33
    </Router>,
34

35
    document.getElementById('root')
Deshui Yu's avatar
Deshui Yu committed
36
);
37
38
39
40
41

// 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
serviceWorker.unregister();