forked from ddrilling/asb_cloud_front
* Публичные старницы перемещены в общую директорию
* SuspenseFallback перемещён в компоненты * Добавлена ленивая загрузка основных страниц
This commit is contained in:
parent
9c2b0ecd26
commit
60118f9327
63
src/App.tsx
63
src/App.tsx
@ -1,49 +1,58 @@
|
|||||||
import { BrowserRouter as Router, Navigate, Route, Routes } from 'react-router-dom'
|
import { BrowserRouter as Router, Navigate, Route, Routes } from 'react-router-dom'
|
||||||
import { memo } from 'react'
|
import { lazy, memo, Suspense } from 'react'
|
||||||
import { ConfigProvider } from 'antd'
|
|
||||||
import locale from 'antd/lib/locale/ru_RU'
|
import locale from 'antd/lib/locale/ru_RU'
|
||||||
|
import { ConfigProvider } from 'antd'
|
||||||
|
|
||||||
import { RootPathContext } from '@asb/context'
|
import { RootPathContext } from '@asb/context'
|
||||||
|
import { UserOutlet } from '@components/outlets'
|
||||||
|
import SuspenseFallback from '@components/SuspenseFallback'
|
||||||
import { getUserToken, NoAccessComponent } from '@utils'
|
import { getUserToken, NoAccessComponent } from '@utils'
|
||||||
import { OpenAPI } from '@api'
|
import { OpenAPI } from '@api'
|
||||||
|
|
||||||
import AdminPanel from '@pages/AdminPanel'
|
|
||||||
import Well from '@pages/Well'
|
|
||||||
import Login from '@pages/Login'
|
|
||||||
import Cluster from '@pages/Cluster'
|
|
||||||
import Deposit from '@pages/Deposit'
|
|
||||||
import Register from '@pages/Register'
|
|
||||||
import FileDownload from '@pages/FileDownload'
|
|
||||||
|
|
||||||
import '@styles/App.less'
|
const Login = lazy(() => import('@pages/public/Login'))
|
||||||
|
const Register = lazy(() => import('@pages/public/Register'))
|
||||||
|
const FileDownload = lazy(() => import('@pages/FileDownload'))
|
||||||
|
|
||||||
|
const AdminPanel = lazy(() => import('@pages/AdminPanel'))
|
||||||
|
const Deposit = lazy(() => import('@pages/Deposit'))
|
||||||
|
const Cluster = lazy(() => import('@pages/Cluster'))
|
||||||
|
const Well = lazy(() => import('@pages/Well'))
|
||||||
|
|
||||||
import '@styles/include/antd_theme.less'
|
import '@styles/include/antd_theme.less'
|
||||||
|
import '@styles/App.less'
|
||||||
|
|
||||||
//OpenAPI.BASE = 'http://localhost:3000'
|
//OpenAPI.BASE = 'http://localhost:3000'
|
||||||
OpenAPI.TOKEN = async () => getUserToken() ?? ''
|
OpenAPI.TOKEN = async () => getUserToken() ?? ''
|
||||||
OpenAPI.HEADERS = {'Content-Type': 'application/json'}
|
OpenAPI.HEADERS = { 'Content-Type': 'application/json' }
|
||||||
|
|
||||||
export const App = memo(() => (
|
export const App = memo(() => (
|
||||||
<ConfigProvider locale={locale}>
|
<ConfigProvider locale={locale}>
|
||||||
<RootPathContext.Provider value={''}>
|
<RootPathContext.Provider value={''}>
|
||||||
<Router>
|
<Suspense fallback={<SuspenseFallback style={{ minHeight: '100vh' }} />}>
|
||||||
<Routes>
|
<Router>
|
||||||
<Route index element={<Navigate to={Deposit.getKey()} replace />} />
|
<Routes>
|
||||||
<Route path={'*'} element={<NoAccessComponent />} />
|
<Route index element={<Navigate to={'deposit'} replace />} />
|
||||||
|
<Route path={'*'} element={<NoAccessComponent />} />
|
||||||
|
|
||||||
{/* Public pages */}
|
{/* Public pages */}
|
||||||
<Route path={Login.route} element={<Login />} />
|
<Route path={'/login'} element={<Login />} />
|
||||||
<Route path={Register.route} element={<Register />} />
|
<Route path={'/register'} element={<Register />} />
|
||||||
|
|
||||||
{/* Admin pages */}
|
{/* User pages */}
|
||||||
<Route path={AdminPanel.route} element={<AdminPanel />} />
|
<Route element={<UserOutlet />}>
|
||||||
|
{/* Admin pages */}
|
||||||
|
<Route path={'/admin/*'} element={<AdminPanel />} />
|
||||||
|
|
||||||
{/* User pages */}
|
{/* Client pages */}
|
||||||
<Route path={Deposit.route} element={<Deposit />} />
|
<Route path={'/file_download/:idWell/:idFile/*'} element={<FileDownload />} />
|
||||||
<Route path={Cluster.route} element={<Cluster />} />
|
<Route path={'/deposit/*'} element={<Deposit />} />
|
||||||
<Route path={Well.route} element={<Well />} />
|
<Route path={'/cluster/:idCluster'} element={<Cluster />} />
|
||||||
<Route path={FileDownload.route} element={<FileDownload />} />
|
<Route path={'/well/:idWell/*'} element={<Well />} />
|
||||||
</Routes>
|
</Route>
|
||||||
</Router>
|
</Routes>
|
||||||
|
</Router>
|
||||||
|
</Suspense>
|
||||||
</RootPathContext.Provider>
|
</RootPathContext.Provider>
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
))
|
))
|
||||||
|
0
src/pages/SuspenseFallback.tsx → src/components/SuspenseFallback.tsx
Executable file → Normal file
0
src/pages/SuspenseFallback.tsx → src/components/SuspenseFallback.tsx
Executable file → Normal file
0
src/pages/AccessDenied.jsx → src/pages/public/AccessDenied.jsx
Executable file → Normal file
0
src/pages/AccessDenied.jsx → src/pages/public/AccessDenied.jsx
Executable file → Normal file
0
src/pages/Login.jsx → src/pages/public/Login.jsx
Executable file → Normal file
0
src/pages/Login.jsx → src/pages/public/Login.jsx
Executable file → Normal file
0
src/pages/Register.jsx → src/pages/public/Register.jsx
Executable file → Normal file
0
src/pages/Register.jsx → src/pages/public/Register.jsx
Executable file → Normal file
@ -4,7 +4,7 @@ import { Navigate, useParams } from 'react-router-dom'
|
|||||||
import { getUserLogin, getUserPermissions } from '@utils'
|
import { getUserLogin, getUserPermissions } from '@utils'
|
||||||
import { isDev } from '@utils'
|
import { isDev } from '@utils'
|
||||||
|
|
||||||
import AccessDenied from '@pages/AccessDenied'
|
import AccessDenied from '@pages/public/AccessDenied'
|
||||||
|
|
||||||
export type Role = string
|
export type Role = string
|
||||||
export type Permission = string
|
export type Permission = string
|
||||||
|
Loading…
Reference in New Issue
Block a user