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';
Lijiaoa's avatar
Lijiaoa committed
5
import { BrowserRouter as Router, Routes, Route, Navigate } 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(
Lijiaoa's avatar
Lijiaoa committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    <Suspense
        fallback={
            <div className='loading'>
                <img title='loading-graph' src={(path ?? '') + '/loading.gif'} />
            </div>
        }
    >
        <Router basename={path ?? ''}>
            <Routes>
                <Route path='/experiment' element={<ExperimentManagerIndex />} />
                <Route element={<App />}>
                    <Route path='/oview' element={<Overview />} />
                    <Route path='/detail' element={<TrialsDetail />} />
                    <Route path='/*' element={<Navigate to='/oview' />} />
                </Route>
            </Routes>
        </Router>
    </Suspense>,
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();