| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { lazy, Suspense } from 'react';
- import { createBrowserRouter, type RouteObject } from 'react-router-dom';
- import PanelLayout from '@/layouts/PanelLayout';
- const IndexPage = lazy(() => import('@/pages/index/IndexPage'));
- const InboundsPage = lazy(() => import('@/pages/inbounds/InboundsPage'));
- const ClientsPage = lazy(() => import('@/pages/clients/ClientsPage'));
- const NodesPage = lazy(() => import('@/pages/nodes/NodesPage'));
- const SettingsPage = lazy(() => import('@/pages/settings/SettingsPage'));
- const XrayPage = lazy(() => import('@/pages/xray/XrayPage'));
- const ApiDocsPage = lazy(() => import('@/pages/api-docs/ApiDocsPage'));
- function withSuspense(node: React.ReactNode) {
- return <Suspense fallback={null}>{node}</Suspense>;
- }
- const routes: RouteObject[] = [
- {
- path: '/',
- element: <PanelLayout />,
- children: [
- { index: true, element: withSuspense(<IndexPage />) },
- { path: 'inbounds', element: withSuspense(<InboundsPage />) },
- { path: 'clients', element: withSuspense(<ClientsPage />) },
- { path: 'nodes', element: withSuspense(<NodesPage />) },
- { path: 'settings', element: withSuspense(<SettingsPage />) },
- { path: 'xray', element: withSuspense(<XrayPage />) },
- { path: 'api-docs', element: withSuspense(<ApiDocsPage />) },
- ],
- },
- ];
- function computeBasename() {
- const raw = (typeof window !== 'undefined' && window.X_UI_BASE_PATH) || '/';
- const trimmed = raw.replace(/\/+$/, '');
- return `${trimmed}/panel`;
- }
- export const router = createBrowserRouter(routes, {
- basename: computeBasename(),
- });
|