feat: 添加路由树统一数据源,新增 antd/icons 依赖
This commit is contained in:
14
AGENTS.md
14
AGENTS.md
@@ -25,8 +25,12 @@ src/
|
||||
index.tsx # App entry point — mounts React root to #root
|
||||
App.tsx # Root component — renders <RouterProvider>
|
||||
App.css # Root component styles
|
||||
router.tsx # Route config (createBrowserRouter)
|
||||
router.tsx # createBrowserRouter,由 routes 树自动生成
|
||||
env.d.ts # Rsbuild environment type declarations
|
||||
routes/
|
||||
types.ts # RouteItem 类型定义
|
||||
index.tsx # 路由树数据(唯一数据源),导出 routes / RouteItem
|
||||
utils.tsx # toRouteObjects():将路由树转为 React Router RouteObject[]
|
||||
layouts/
|
||||
RootLayout.tsx # Root layout with nav links and <Outlet />
|
||||
pages/
|
||||
@@ -44,9 +48,11 @@ tsconfig.json
|
||||
|
||||
Uses **React Router v7** (`react-router`) with `createBrowserRouter`.
|
||||
|
||||
- Route config lives in `src/router.tsx`
|
||||
- `RootLayout` wraps all routes — add shared nav/header/footer there
|
||||
- Add new pages under `src/pages/`, register them in `src/router.tsx`
|
||||
- **唯一数据源**:`src/routes/index.tsx` 维护 `routes: RouteItem[]` 路由树
|
||||
- `RouteItem` 字段:`path` / `label` / `icon?` / `component?` / `hideInMenu?` / `redirect?` / `children?`
|
||||
- `toRouteObjects(routes)` 将路由树转换为 React Router 所需的 `RouteObject[]`
|
||||
- 菜单、面包屑等模块直接消费 `routes` 数组,无需重复维护路由信息
|
||||
- 添加新页面:在 `src/pages/` 创建组件,在 `src/routes/index.tsx` 追加节点即可
|
||||
|
||||
## TypeScript Configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user