From 60118f9327099a5a4c2fd80c3a678fb34403c78c Mon Sep 17 00:00:00 2001 From: goodmice Date: Thu, 13 Oct 2022 14:00:17 +0500 Subject: [PATCH] =?UTF-8?q?*=20=D0=9F=D1=83=D0=B1=D0=BB=D0=B8=D1=87=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D1=81=D1=82=D0=B0=D1=80=D0=BD=D0=B8=D1=86=D1=8B?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D1=8B?= =?UTF-8?q?=20=D0=B2=20=D0=BE=D0=B1=D1=89=D1=83=D1=8E=20=D0=B4=D0=B8=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D1=8E=20*=20SuspenseFallba?= =?UTF-8?q?ck=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89=D1=91=D0=BD=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D1=8B=20*=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BB=D0=B5=D0=BD=D0=B8=D0=B2=D0=B0=D1=8F=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D0=BE=D1=81=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BD=D1=8B=D1=85=20=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 63 +++++++++++-------- .../SuspenseFallback.tsx | 0 src/pages/{ => public}/AccessDenied.jsx | 0 src/pages/{ => public}/Login.jsx | 0 src/pages/{ => public}/Register.jsx | 0 src/utils/functions/permissions.tsx | 2 +- 6 files changed, 37 insertions(+), 28 deletions(-) rename src/{pages => components}/SuspenseFallback.tsx (100%) mode change 100755 => 100644 rename src/pages/{ => public}/AccessDenied.jsx (100%) mode change 100755 => 100644 rename src/pages/{ => public}/Login.jsx (100%) mode change 100755 => 100644 rename src/pages/{ => public}/Register.jsx (100%) mode change 100755 => 100644 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