mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
Merge pull request #1073 from logto-io/charles-log-2458-lazy-load-admin-console-routes
refactor(console): lazy loading admin console routes
This commit is contained in:
commit
b0e5ad4632
1 changed files with 61 additions and 57 deletions
|
@ -1,34 +1,36 @@
|
||||||
import { LogtoProvider } from '@logto/react';
|
import { LogtoProvider } from '@logto/react';
|
||||||
import { adminConsoleApplicationId, managementResource } from '@logto/schemas/lib/seeds';
|
import { adminConsoleApplicationId, managementResource } from '@logto/schemas/lib/seeds';
|
||||||
import { getBasename } from '@logto/shared';
|
import { getBasename } from '@logto/shared';
|
||||||
import React from 'react';
|
import React, { Suspense } from 'react';
|
||||||
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
|
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
|
||||||
import { SWRConfig } from 'swr';
|
import { SWRConfig } from 'swr';
|
||||||
|
|
||||||
import './scss/normalized.scss';
|
import './scss/normalized.scss';
|
||||||
// eslint-disable-next-line import/no-unassigned-import
|
// eslint-disable-next-line import/no-unassigned-import
|
||||||
import '@fontsource/roboto-mono';
|
import '@fontsource/roboto-mono';
|
||||||
|
import AppBoundary from '@/components/AppBoundary';
|
||||||
|
import ErrorBoundary from '@/components/ErrorBoundary';
|
||||||
|
import LogtoLoading from '@/components/LogtoLoading';
|
||||||
|
import Toast from '@/components/Toast';
|
||||||
|
import useSwrOptions from '@/hooks/use-swr-options';
|
||||||
|
import initI18n from '@/i18n/init';
|
||||||
|
|
||||||
import AppBoundary from './components/AppBoundary';
|
const AppContent = React.lazy(async () => import('@/components/AppContent'));
|
||||||
import AppContent from './components/AppContent';
|
const ApiResourceDetails = React.lazy(async () => import('@/pages/ApiResourceDetails'));
|
||||||
import ErrorBoundary from './components/ErrorBoundary';
|
const ApiResources = React.lazy(async () => import('@/pages/ApiResources'));
|
||||||
import Toast from './components/Toast';
|
const ApplicationDetails = React.lazy(async () => import('@/pages/ApplicationDetails'));
|
||||||
import useSwrOptions from './hooks/use-swr-options';
|
const Applications = React.lazy(async () => import('@/pages/Applications'));
|
||||||
import initI18n from './i18n/init';
|
const AuditLogs = React.lazy(async () => import('@/pages/AuditLogs'));
|
||||||
import ApiResourceDetails from './pages/ApiResourceDetails';
|
const Callback = React.lazy(async () => import('@/pages/Callback'));
|
||||||
import ApiResources from './pages/ApiResources';
|
const ConnectorDetails = React.lazy(async () => import('@/pages/ConnectorDetails'));
|
||||||
import ApplicationDetails from './pages/ApplicationDetails';
|
const Connectors = React.lazy(async () => import('@/pages/Connectors'));
|
||||||
import Applications from './pages/Applications';
|
const Dashboard = React.lazy(async () => import('@/pages/Dashboard'));
|
||||||
import AuditLogs from './pages/AuditLogs';
|
const GetStarted = React.lazy(async () => import('@/pages/GetStarted'));
|
||||||
import Callback from './pages/Callback';
|
const NotFound = React.lazy(async () => import('@/pages/NotFound'));
|
||||||
import ConnectorDetails from './pages/ConnectorDetails';
|
const Settings = React.lazy(async () => import('@/pages/Settings'));
|
||||||
import Connectors from './pages/Connectors';
|
const SignInExperience = React.lazy(async () => import('@/pages/SignInExperience'));
|
||||||
import Dashboard from './pages/Dashboard';
|
const UserDetails = React.lazy(async () => import('@/pages/UserDetails'));
|
||||||
import GetStarted from './pages/GetStarted';
|
const Users = React.lazy(async () => import('@/pages/Users'));
|
||||||
import NotFound from './pages/NotFound';
|
|
||||||
import Settings from './pages/Settings';
|
|
||||||
import SignInExperience from './pages/SignInExperience';
|
|
||||||
import UserDetails from './pages/UserDetails';
|
|
||||||
import Users from './pages/Users';
|
|
||||||
|
|
||||||
void initI18n();
|
void initI18n();
|
||||||
|
|
||||||
|
@ -40,43 +42,45 @@ const Main = () => {
|
||||||
<SWRConfig value={swrOptions}>
|
<SWRConfig value={swrOptions}>
|
||||||
<AppBoundary>
|
<AppBoundary>
|
||||||
<Toast />
|
<Toast />
|
||||||
<Routes>
|
<Suspense fallback={<LogtoLoading message="general.loading" />}>
|
||||||
<Route path="callback" element={<Callback />} />
|
<Routes>
|
||||||
<Route element={<AppContent />}>
|
<Route path="callback" element={<Callback />} />
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route element={<AppContent />}>
|
||||||
<Route path="get-started" element={<GetStarted />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
<Route path="applications">
|
<Route path="get-started" element={<GetStarted />} />
|
||||||
<Route index element={<Applications />} />
|
<Route path="applications">
|
||||||
<Route path=":id">
|
<Route index element={<Applications />} />
|
||||||
<Route index element={<Navigate to="settings" />} />
|
<Route path=":id">
|
||||||
<Route path="settings" element={<ApplicationDetails />} />
|
<Route index element={<Navigate to="settings" />} />
|
||||||
<Route path="advanced-settings" element={<ApplicationDetails />} />
|
<Route path="settings" element={<ApplicationDetails />} />
|
||||||
|
<Route path="advanced-settings" element={<ApplicationDetails />} />
|
||||||
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="api-resources">
|
||||||
|
<Route index element={<ApiResources />} />
|
||||||
|
<Route path=":id" element={<ApiResourceDetails />} />
|
||||||
|
</Route>
|
||||||
|
<Route path="connectors">
|
||||||
|
<Route index element={<Connectors />} />
|
||||||
|
<Route path="social" element={<Connectors />} />
|
||||||
|
<Route path=":connectorId" element={<ConnectorDetails />} />
|
||||||
|
</Route>
|
||||||
|
<Route path="users">
|
||||||
|
<Route index element={<Users />} />
|
||||||
|
<Route path=":id" element={<UserDetails />} />
|
||||||
|
</Route>
|
||||||
|
<Route path="sign-in-experience">
|
||||||
|
<Route index element={<Navigate to="experience" />} />
|
||||||
|
<Route path=":tab" element={<SignInExperience />} />
|
||||||
|
</Route>
|
||||||
|
<Route path="settings" element={<Settings />} />
|
||||||
|
<Route path="audit-logs">
|
||||||
|
<Route index element={<AuditLogs />} />
|
||||||
|
</Route>
|
||||||
|
<Route path="dashboard" element={<Dashboard />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="api-resources">
|
</Routes>
|
||||||
<Route index element={<ApiResources />} />
|
</Suspense>
|
||||||
<Route path=":id" element={<ApiResourceDetails />} />
|
|
||||||
</Route>
|
|
||||||
<Route path="connectors">
|
|
||||||
<Route index element={<Connectors />} />
|
|
||||||
<Route path="social" element={<Connectors />} />
|
|
||||||
<Route path=":connectorId" element={<ConnectorDetails />} />
|
|
||||||
</Route>
|
|
||||||
<Route path="users">
|
|
||||||
<Route index element={<Users />} />
|
|
||||||
<Route path=":id" element={<UserDetails />} />
|
|
||||||
</Route>
|
|
||||||
<Route path="sign-in-experience">
|
|
||||||
<Route index element={<Navigate to="experience" />} />
|
|
||||||
<Route path=":tab" element={<SignInExperience />} />
|
|
||||||
</Route>
|
|
||||||
<Route path="settings" element={<Settings />} />
|
|
||||||
<Route path="audit-logs">
|
|
||||||
<Route index element={<AuditLogs />} />
|
|
||||||
</Route>
|
|
||||||
<Route path="dashboard" element={<Dashboard />} />
|
|
||||||
</Route>
|
|
||||||
</Routes>
|
|
||||||
</AppBoundary>
|
</AppBoundary>
|
||||||
</SWRConfig>
|
</SWRConfig>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
|
Loading…
Add table
Reference in a new issue