From 790b6905ef59aa6c6e148a6d805c5f146077097f Mon Sep 17 00:00:00 2001 From: xie2can <384968446@qq.com> Date: Fri, 15 May 2026 14:05:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE/=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=8C=E9=87=8D=E6=9E=84=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=E4=B8=BA=20/xxx/index.tsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 1 + src/layouts/RootLayout.tsx | 10 +++----- src/layouts/SystemLayout.tsx | 5 ++++ src/pages/{About.tsx => about/index.tsx} | 0 src/pages/{Home.tsx => home/index.tsx} | 0 .../{NotFound.tsx => not-found/index.tsx} | 0 src/pages/system/user/index.tsx | 21 ++++++++++++++++ src/routes/index.tsx | 24 +++++++++++++++---- src/routes/utils.tsx | 18 ++++++++++++++ 9 files changed, 68 insertions(+), 11 deletions(-) create mode 100644 .gitattributes create mode 100644 src/layouts/SystemLayout.tsx rename src/pages/{About.tsx => about/index.tsx} (100%) rename src/pages/{Home.tsx => home/index.tsx} (100%) rename src/pages/{NotFound.tsx => not-found/index.tsx} (100%) create mode 100644 src/pages/system/user/index.tsx diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/src/layouts/RootLayout.tsx b/src/layouts/RootLayout.tsx index 675c642..a0c56ba 100644 --- a/src/layouts/RootLayout.tsx +++ b/src/layouts/RootLayout.tsx @@ -3,16 +3,11 @@ import { Layout, Menu } from 'antd'; import { useState } from 'react'; import { Outlet, useLocation, useNavigate } from 'react-router'; import { routes } from '../routes'; +import { toMenuItems } from '../routes/utils'; const { Header, Sider, Content } = Layout; -const menuItems = routes - .filter((r) => !r.hideInMenu) - .map((r) => ({ - key: r.path, - icon: r.icon, - label: r.label, - })); +const menuItems = toMenuItems(routes); const RootLayout = () => { const navigate = useNavigate(); @@ -42,6 +37,7 @@ const RootLayout = () => { item.key)} items={menuItems} onClick={({ key }) => navigate(key)} style={{ height: '100%', borderRight: 0, paddingBottom: 48 }} diff --git a/src/layouts/SystemLayout.tsx b/src/layouts/SystemLayout.tsx new file mode 100644 index 0000000..f308459 --- /dev/null +++ b/src/layouts/SystemLayout.tsx @@ -0,0 +1,5 @@ +import { Outlet } from 'react-router'; + +const SystemLayout = () => ; + +export default SystemLayout; diff --git a/src/pages/About.tsx b/src/pages/about/index.tsx similarity index 100% rename from src/pages/About.tsx rename to src/pages/about/index.tsx diff --git a/src/pages/Home.tsx b/src/pages/home/index.tsx similarity index 100% rename from src/pages/Home.tsx rename to src/pages/home/index.tsx diff --git a/src/pages/NotFound.tsx b/src/pages/not-found/index.tsx similarity index 100% rename from src/pages/NotFound.tsx rename to src/pages/not-found/index.tsx diff --git a/src/pages/system/user/index.tsx b/src/pages/system/user/index.tsx new file mode 100644 index 0000000..673ab1f --- /dev/null +++ b/src/pages/system/user/index.tsx @@ -0,0 +1,21 @@ +import { Table, Typography } from 'antd'; + +const { Title } = Typography; + +const columns = [ + { title: '用户名', dataIndex: 'username', key: 'username' }, + { title: '姓名', dataIndex: 'name', key: 'name' }, + { title: '邮箱', dataIndex: 'email', key: 'email' }, + { title: '状态', dataIndex: 'status', key: 'status' }, +]; + +const UserManagement = () => { + return ( +
+ 用户管理 + + + ); +}; + +export default UserManagement; diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 02982c7..3974c8e 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,7 +1,9 @@ -import { HomeOutlined, InfoCircleOutlined } from '@ant-design/icons'; -import About from '../pages/About'; -import Home from '../pages/Home'; -import NotFound from '../pages/NotFound'; +import { HomeOutlined, InfoCircleOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons'; +import SystemLayout from '../layouts/SystemLayout'; +import About from '../pages/about'; +import Home from '../pages/home'; +import NotFound from '../pages/not-found'; +import UserManagement from '../pages/system/user'; import type { RouteItem } from './types'; export const routes: RouteItem[] = [ @@ -17,6 +19,20 @@ export const routes: RouteItem[] = [ icon: , component: , }, + { + path: '/system', + label: '系统配置', + icon: , + component: , + children: [ + { + path: '/system/user', + label: '用户管理', + icon: , + component: , + }, + ], + }, { path: '*', label: '404', diff --git a/src/routes/utils.tsx b/src/routes/utils.tsx index c057110..3f9a94b 100644 --- a/src/routes/utils.tsx +++ b/src/routes/utils.tsx @@ -21,3 +21,21 @@ export function toRouteObjects(items: RouteItem[]): RouteObject[] { return route; }); } + +type MenuItem = { + key: string; + icon?: React.ReactNode; + label: string; + children?: MenuItem[]; +}; + +export function toMenuItems(items: RouteItem[]): MenuItem[] { + return items + .filter((r) => !r.hideInMenu) + .map((r) => ({ + key: r.path, + icon: r.icon, + label: r.label, + children: r.children ? toMenuItems(r.children) : undefined, + })); +}