import { lazy, type ReactNode } from "react";
import { Soon } from "./components/Soon";
// 路由注册表 —— 控制台的单一事实源:导航 + 内容都从这里派生。
// 新增页面 = 在此加一条;real 页面用 lazy 懒加载(代码分割)。
const ModelsPage = lazy(() => import("./pages/ModelsPage").then((m) => ({ default: m.ModelsPage })));
const DatasourcesPage = lazy(() => import("./pages/DatasourcesPage").then((m) => ({ default: m.DatasourcesPage })));
const PricingPage = lazy(() => import("./pages/PricingPage").then((m) => ({ default: m.PricingPage })));
export interface RouteDef {
path: string;
label: string;
group: string;
ready?: boolean;
element: ReactNode;
}
export const routes: RouteDef[] = [
{
path: "/models",
label: "模型",
group: "配置",
ready: true,
element: ,
},
{
path: "/datasources",
label: "数据源",
group: "配置",
ready: true,
element: ,
},
{
path: "/pricing",
label: "计价",
group: "配置",
ready: true,
element: ,
},
{
path: "/tenants",
label: "租户",
group: "平台",
element: ,
},
{
path: "/guardrails",
label: "护栏",
group: "平台",
element: ,
},
];
export const defaultPath = "/models";
// 派生分组导航(保持注册顺序)。
export function navGroups(): Array<{ group: string; items: RouteDef[] }> {
const out: Array<{ group: string; items: RouteDef[] }> = [];
for (const r of routes) {
let g = out.find((x) => x.group === r.group);
if (!g) {
g = { group: r.group, items: [] };
out.push(g);
}
g.items.push(r);
}
return out;
}