|
1 | 1 | import { createBrowserRouter, RouterProvider } from 'react-router-dom'; |
2 | 2 | import { HelmetProvider } from 'react-helmet-async'; |
| 3 | +import Box from '@mui/material/Box'; |
| 4 | +import CircularProgress from '@mui/material/CircularProgress'; |
3 | 5 | import { Layout, AppDataProvider } from './components/Layout'; |
4 | 6 | import { ErrorBoundary } from './components/ErrorBoundary'; |
5 | 7 | import { HomePage } from './pages/HomePage'; |
6 | 8 | import { SpecPage } from './pages/SpecPage'; |
7 | 9 | import { NotFoundPage } from './pages/NotFoundPage'; |
8 | 10 |
|
| 11 | +const LazyFallback = () => ( |
| 12 | + <Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: '50vh' }}> |
| 13 | + <CircularProgress size={32} /> |
| 14 | + </Box> |
| 15 | +); |
| 16 | + |
9 | 17 | const router = createBrowserRouter([ |
10 | 18 | { |
11 | 19 | path: '/', |
12 | 20 | element: <Layout />, |
13 | 21 | children: [ |
14 | 22 | { index: true, element: <HomePage /> }, |
15 | | - { path: 'catalog', lazy: () => import('./pages/CatalogPage').then(m => ({ Component: m.CatalogPage })) }, |
16 | | - { path: 'legal', lazy: () => import('./pages/LegalPage').then(m => ({ Component: m.LegalPage })) }, |
17 | | - { path: 'mcp', lazy: () => import('./pages/McpPage').then(m => ({ Component: m.McpPage })) }, |
| 23 | + { path: 'catalog', lazy: () => import('./pages/CatalogPage').then(m => ({ Component: m.CatalogPage, HydrateFallback: LazyFallback })) }, |
| 24 | + { path: 'legal', lazy: () => import('./pages/LegalPage').then(m => ({ Component: m.LegalPage, HydrateFallback: LazyFallback })) }, |
| 25 | + { path: 'mcp', lazy: () => import('./pages/McpPage').then(m => ({ Component: m.McpPage, HydrateFallback: LazyFallback })) }, |
18 | 26 | { path: ':specId', element: <SpecPage /> }, |
19 | 27 | { path: ':specId/:library', element: <SpecPage /> }, |
20 | 28 | { path: '*', element: <NotFoundPage /> }, |
21 | 29 | ], |
22 | 30 | }, |
23 | 31 | // Fullscreen interactive view (outside Layout but inside AppDataProvider) |
24 | | - { path: 'interactive/:specId/:library', lazy: () => import('./pages/InteractivePage').then(m => ({ Component: m.InteractivePage })) }, |
| 32 | + { path: 'interactive/:specId/:library', lazy: () => import('./pages/InteractivePage').then(m => ({ Component: m.InteractivePage, HydrateFallback: LazyFallback })) }, |
25 | 33 | // Hidden debug dashboard (outside Layout - no header/footer) |
26 | | - { path: 'debug', lazy: () => import('./pages/DebugPage').then(m => ({ Component: m.DebugPage })) }, |
| 34 | + { path: 'debug', lazy: () => import('./pages/DebugPage').then(m => ({ Component: m.DebugPage, HydrateFallback: LazyFallback })) }, |
27 | 35 | { path: '*', element: <NotFoundPage /> }, |
28 | 36 | ]); |
29 | 37 |
|
|
0 commit comments