feat: 重构前端为企业 Admin 后台布局,引入 React Router 路由

- 引入 React Router v7 (Declarative mode) 实现 SPA 路由
- 重构 Layout 为 Header + 侧边栏 + 内容区的企业 Admin 布局
- 新增侧边栏菜单组件,支持折叠/展开,状态持久化到 localStorage
- 新增示例页面:仪表盘、用户管理、系统设置、404
- 菜单配置与路由统一为单一数据源 (menu.tsx)
- Vite code splitting 新增 vendor-router 组
- 更新 DEVELOPMENT.md 和 README.md 文档
This commit is contained in:
2026-05-20 19:06:14 +08:00
parent 5aed73523e
commit 4caf502908
32 changed files with 981 additions and 140 deletions

View File

@@ -0,0 +1,29 @@
import { useQuery } from "@tanstack/react-query";
import { Space } from "tdesign-react";
import type { HealthResponse } from "../../../shared/api";
import { APP } from "../../../shared/app";
export function DashboardPage() {
const { data: health } = useQuery({
queryFn: fetchHealth,
queryKey: ["health"],
refetchInterval: 30000,
staleTime: 5000,
});
return (
<Space direction="vertical" size="large" style={{ width: "100%" }}>
<h2>使 {APP.title}</h2>
<p> /health API </p>
{health && <pre className="health-response">{JSON.stringify(health, null, 2)}</pre>}
</Space>
);
}
async function fetchHealth(): Promise<HealthResponse> {
const response = await fetch("/health");
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json() as Promise<HealthResponse>;
}