mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 19:25:05 +03:00
14c9bdff89
The router, the sidebar, the page titles and the command palette each kept their own list of the panel's pages, so a page added to one could go missing from another without any test noticing. They all read src/routes/panelRoutes.tsx now, and a contract test holds the manifest to the router, the translation bundle and the palette keywords. The unused useZodForm helper goes, and CONTRIBUTING, frontend/CLAUDE.md and the frontend README describe the useForm + rhfZodValidate pattern the panel's forms actually use.
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { Suspense } from 'react';
|
|
import { createBrowserRouter, type RouteObject } from 'react-router';
|
|
import { Spin } from 'antd';
|
|
|
|
import PanelLayout from '@/layouts/PanelLayout';
|
|
import { PANEL_ROUTES } from '@/routes/panelRoutes';
|
|
|
|
function withSuspense(node: React.ReactNode) {
|
|
return (
|
|
<Suspense
|
|
fallback={
|
|
<div
|
|
style={{
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
minHeight: '60vh',
|
|
}}
|
|
>
|
|
<Spin size="large" />
|
|
</div>
|
|
}
|
|
>
|
|
{node}
|
|
</Suspense>
|
|
);
|
|
}
|
|
|
|
export const routes: RouteObject[] = [
|
|
{
|
|
path: '/',
|
|
element: <PanelLayout />,
|
|
children: PANEL_ROUTES.map((route) => {
|
|
const element = withSuspense(<route.component />);
|
|
return route.path === '/' ? { index: true, element } : { path: route.path.slice(1), element };
|
|
}),
|
|
},
|
|
];
|
|
|
|
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(),
|
|
});
|