|
| 1 | +import { lazy, Suspense } from 'react' |
1 | 2 | import { Navigate, Route, Routes } from 'react-router-dom' |
2 | 3 | import AuthGate from './components/AuthGate' |
3 | 4 | import Layout from './components/Layout' |
4 | | -import Accounts from './pages/Accounts' |
| 5 | +import RouteErrorBoundary from './components/RouteErrorBoundary' |
| 6 | +import StateShell from './components/StateShell' |
5 | 7 | import Dashboard from './pages/Dashboard' |
6 | | -import Operations from './pages/Operations' |
7 | | -import Proxies from './pages/Proxies' |
8 | | -import SchedulerBoard from './pages/SchedulerBoard' |
9 | | -import Settings from './pages/Settings' |
10 | | -import Guide from './pages/Guide' |
11 | | -import ApiReference from './pages/ApiReference' |
12 | | -import APIKeys from './pages/APIKeys' |
13 | | -import Usage from './pages/Usage' |
14 | | -import ImageStudio from './pages/ImageStudio' |
15 | | -import PromptFilter from './pages/PromptFilter' |
| 8 | + |
| 9 | +const Accounts = lazy(() => import('./pages/Accounts')) |
| 10 | +const Operations = lazy(() => import('./pages/Operations')) |
| 11 | +const Proxies = lazy(() => import('./pages/Proxies')) |
| 12 | +const SchedulerBoard = lazy(() => import('./pages/SchedulerBoard')) |
| 13 | +const Settings = lazy(() => import('./pages/Settings')) |
| 14 | +const Guide = lazy(() => import('./pages/Guide')) |
| 15 | +const ApiReference = lazy(() => import('./pages/ApiReference')) |
| 16 | +const APIKeys = lazy(() => import('./pages/APIKeys')) |
| 17 | +const Usage = lazy(() => import('./pages/Usage')) |
| 18 | +const ImageStudio = lazy(() => import('./pages/ImageStudio')) |
| 19 | +const PromptFilter = lazy(() => import('./pages/PromptFilter')) |
16 | 20 |
|
17 | 21 | export default function App() { |
18 | 22 | return ( |
19 | 23 | <AuthGate> |
20 | 24 | <Layout> |
21 | | - <Routes> |
22 | | - <Route path="/" element={<Dashboard />} /> |
23 | | - <Route path="/accounts" element={<Accounts />} /> |
24 | | - <Route path="/api-keys" element={<APIKeys />} /> |
25 | | - <Route path="/proxies" element={<Proxies />} /> |
26 | | - <Route path="/images" element={<Navigate to="/images/studio" replace />} /> |
27 | | - <Route path="/images/:view" element={<ImageStudio />} /> |
28 | | - <Route path="/prompt-filter" element={<Navigate to="/prompt-filter/overview" replace />} /> |
29 | | - <Route path="/prompt-filter/:view" element={<PromptFilter />} /> |
30 | | - <Route path="/ops" element={<Operations />} /> |
31 | | - <Route path="/ops/scheduler" element={<SchedulerBoard />} /> |
32 | | - <Route path="/usage" element={<Usage />} /> |
33 | | - <Route path="/settings" element={<Settings />} /> |
34 | | - <Route path="/docs" element={<Guide />} /> |
35 | | - <Route path="/api-reference" element={<ApiReference />} /> |
36 | | - </Routes> |
| 25 | + <RouteErrorBoundary> |
| 26 | + <Suspense fallback={<StateShell variant="page" loading>{null}</StateShell>}> |
| 27 | + <Routes> |
| 28 | + <Route path="/" element={<Dashboard />} /> |
| 29 | + <Route path="/accounts" element={<Accounts />} /> |
| 30 | + <Route path="/api-keys" element={<APIKeys />} /> |
| 31 | + <Route path="/proxies" element={<Proxies />} /> |
| 32 | + <Route path="/images" element={<Navigate to="/images/studio" replace />} /> |
| 33 | + <Route path="/images/:view" element={<ImageStudio />} /> |
| 34 | + <Route path="/prompt-filter" element={<Navigate to="/prompt-filter/overview" replace />} /> |
| 35 | + <Route path="/prompt-filter/:view" element={<PromptFilter />} /> |
| 36 | + <Route path="/ops" element={<Operations />} /> |
| 37 | + <Route path="/ops/scheduler" element={<SchedulerBoard />} /> |
| 38 | + <Route path="/usage" element={<Usage />} /> |
| 39 | + <Route path="/settings" element={<Settings />} /> |
| 40 | + <Route path="/docs" element={<Guide />} /> |
| 41 | + <Route path="/api-reference" element={<ApiReference />} /> |
| 42 | + </Routes> |
| 43 | + </Suspense> |
| 44 | + </RouteErrorBoundary> |
37 | 45 | </Layout> |
38 | 46 | </AuthGate> |
39 | 47 | ) |
|
0 commit comments