diff --git a/src/App.tsx b/src/App.tsx index d883e77..6b410b0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,49 +1,58 @@ import { BrowserRouter as Router, Navigate, Route, Routes } from 'react-router-dom' -import { memo } from 'react' -import { ConfigProvider } from 'antd' +import { lazy, memo, Suspense } from 'react' import locale from 'antd/lib/locale/ru_RU' +import { ConfigProvider } from 'antd' import { RootPathContext } from '@asb/context' +import { UserOutlet } from '@components/outlets' +import SuspenseFallback from '@components/SuspenseFallback' import { getUserToken, NoAccessComponent } from '@utils' 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/App.less' //OpenAPI.BASE = 'http://localhost:3000' OpenAPI.TOKEN = async () => getUserToken() ?? '' -OpenAPI.HEADERS = {'Content-Type': 'application/json'} +OpenAPI.HEADERS = { 'Content-Type': 'application/json' } export const App = memo(() => ( - - - } /> - } /> + }> + + + } /> + } /> - {/* Public pages */} - } /> - } /> + {/* Public pages */} + } /> + } /> - {/* Admin pages */} - } /> + {/* User pages */} + }> + {/* Admin pages */} + } /> - {/* User pages */} - } /> - } /> - } /> - } /> - - + {/* Client pages */} + } /> + } /> + } /> + } /> + + + + )) diff --git a/src/pages/SuspenseFallback.tsx b/src/components/SuspenseFallback.tsx old mode 100755 new mode 100644 similarity index 100% rename from src/pages/SuspenseFallback.tsx rename to src/components/SuspenseFallback.tsx diff --git a/src/pages/AccessDenied.jsx b/src/pages/public/AccessDenied.jsx old mode 100755 new mode 100644 similarity index 100% rename from src/pages/AccessDenied.jsx rename to src/pages/public/AccessDenied.jsx diff --git a/src/pages/Login.jsx b/src/pages/public/Login.jsx old mode 100755 new mode 100644 similarity index 100% rename from src/pages/Login.jsx rename to src/pages/public/Login.jsx diff --git a/src/pages/Register.jsx b/src/pages/public/Register.jsx old mode 100755 new mode 100644 similarity index 100% rename from src/pages/Register.jsx rename to src/pages/public/Register.jsx diff --git a/src/utils/functions/permissions.tsx b/src/utils/functions/permissions.tsx index 274a9c5..baa749d 100644 --- a/src/utils/functions/permissions.tsx +++ b/src/utils/functions/permissions.tsx @@ -4,7 +4,7 @@ import { Navigate, useParams } from 'react-router-dom' import { getUserLogin, getUserPermissions } from '@utils' import { isDev } from '@utils' -import AccessDenied from '@pages/AccessDenied' +import AccessDenied from '@pages/public/AccessDenied' export type Role = string export type Permission = string