index.tsx 1.49 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';
6
7
const Overview = lazy(() => import('./components/Overview'));
const TrialsDetail = lazy(() => import('./components/TrialsDetail'));
8
const Experiment = lazy(() => import('./components/managementExp/ExperimentManager'));
Deshui Yu's avatar
Deshui Yu committed
9
import './index.css';
10
import './static/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
20
21
22
23
24
        <Suspense
            fallback={
                <div className='loading'>
                    <img src={require('./static/img/loading.gif')} />
                </div>
            }
        >
            <Route path='/experiment' component={Experiment} 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();