From 13d1fea5fb0417660c85d4dfdfcb30f3601667ee Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Mon, 25 May 2026 00:00:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BE=A7=E8=BE=B9=E6=A0=8F?= =?UTF-8?q?=E6=8A=98=E5=8F=A0=E6=8C=89=E9=92=AE=E4=BB=8E=20Header=20?= =?UTF-8?q?=E7=A7=BB=E8=87=B3=E4=BE=A7=E8=BE=B9=E6=A0=8F=E5=BA=95=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 Header 左侧折叠按钮,改用 TDesign Menu operations 渲染底部折叠按钮 - Header 品牌名与版本号使用 brand-group 基线对齐 - 侧边栏折叠宽度从 80px 对齐 TDesign 默认 64px - 更新相关测试和 DEVELOPMENT.md 文档 --- DEVELOPMENT.md | 8 ++-- src/web/app.tsx | 16 ++++---- src/web/components/Sidebar/index.tsx | 17 +++++++-- src/web/styles.css | 16 ++++++-- tests/web/App.test.tsx | 17 +++++++++ tests/web/components/Sidebar/index.test.tsx | 42 +++++++++++++++++++-- 6 files changed, 93 insertions(+), 23 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index c0d233a..63fb5ae 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -38,7 +38,7 @@ src/ app.ts 应用全局常量(name、title、subtitle、description) web/ React 前端(通过 Vite 构建) index.html HTML 入口 - app.tsx 根组件(Admin 布局:Header + Sidebar + Content) + app.tsx 根组件(Admin 布局:Header + Sidebar + Content + 版本号展示) main.tsx 入口(BrowserRouter + QueryClient 挂载 + ErrorBoundary + ReactQueryDevtools + TDesign CSS 导入) routes.tsx 路由配置(定义所有页面路由) styles.css 全局样式与自定义 CSS 变量 @@ -55,7 +55,7 @@ src/ components/ UI 组件 ErrorBoundary.tsx React 错误边界,捕获渲染异常并展示降级 UI Sidebar/ - index.tsx 侧边栏菜单组件(TDesign Menu + 折叠控制) + index.tsx 侧边栏菜单组件(TDesign Menu + 底部折叠按钮) hooks/ React hooks use-theme-preference.ts 主题偏好 hook(system/light/dark,localStorage 记忆 + matchMedia 监听) use-sidebar-collapsed.ts 侧边栏折叠状态 hook(localStorage 记忆) @@ -268,10 +268,10 @@ main.tsx │ ├── useThemePreference() ── Header 主题模式 RadioGroup(系统/明亮/黑暗) │ ├── useSidebarCollapsed() ── 侧边栏折叠状态(localStorage 记忆) │ ├── Layout - │ │ ├── Header(折叠按钮 + 品牌名 + 页标题 + 主题切换) + │ │ ├── Header(品牌名 + 版本号 + 页标题 + 主题切换) │ │ └── Layout(嵌套) │ │ ├── Aside - │ │ │ └── Sidebar(TDesign Menu,菜单项点击导航) + │ │ │ └── Sidebar(TDesign Menu + 底部折叠按钮,菜单项点击导航) │ │ └── Content │ │ └── AppRoutes(路由配置) │ │ ├── / → DashboardPage(欢迎语 + /api/meta 联调) diff --git a/src/web/app.tsx b/src/web/app.tsx index 232c500..323d469 100644 --- a/src/web/app.tsx +++ b/src/web/app.tsx @@ -1,8 +1,7 @@ import { useQuery } from "@tanstack/react-query"; import { useEffect } from "react"; import { useLocation } from "react-router"; -import { ChevronLeftIcon, ChevronRightIcon } from "tdesign-icons-react"; -import { Button, Layout, RadioGroup } from "tdesign-react"; +import { Layout, RadioGroup } from "tdesign-react"; import type { MetaResponse } from "../shared/api"; @@ -50,11 +49,10 @@ export function App() {
- - {APP.title} - {versionDisplay && {versionDisplay}} + + {APP.title} + {versionDisplay && {versionDisplay}} + {pageTitle}
@@ -68,8 +66,8 @@ export function App() {
-