From 7d39041d7a2b6376b8cf0a089e122d01c6c746e2 Mon Sep 17 00:00:00 2001 From: xiaomakuaiz Date: Mon, 3 Aug 2026 05:30:58 +0000 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20=E7=AA=84=E7=AA=97=E4=B8=8B?= =?UTF-8?q?=E8=87=AA=E7=BB=98=E6=A0=87=E9=A2=98=E6=A0=8F=E4=B8=8E=E4=BE=A7?= =?UTF-8?q?=E6=A0=8F=E7=9A=84=E7=AB=96=E5=88=86=E9=9A=94=E7=BA=BF=E9=94=99?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows 壳去掉了原生装饰栏,标题栏是自绘的,左边两段必须与下方双层 侧栏逐列对齐。但栏宽写了两份:内容区的 .mc-nav-rail / .mc-sidebar-panel 在 styles.css 的媒体查询里随窗宽收窄(62/232 → 58/220),标题栏那两段 却把 62 / 232 内联写死。窗口一缩到 1080px 以下只有下面那层跟着收, 两条竖线就错开——实测偏移 4px 与 16px。.mc-sidebar-panel 那条 `width: 220px !important` 正是为了压 sidebar.tsx 的内联 232,本身就是 这份重复的症状。 收成一组令牌:--railW / --sideW / --setNavW 定义在 :root,内容区的栏与 标题栏同列都只读令牌,媒体查询只改令牌,两层一起走,!important 随之删掉。 设置页左导航与标题栏设置态那份 168 是同一类重复(目前没媒体查询所以 没暴露),一并收口。 守护断言:titlebar.test 禁止标题栏出现栏宽字面像素,navigation.test 补上 .mc-sidebar-panel 不带内联 width。 --- desktop/ui/src/navigation.test.tsx | 13 +++++++++---- desktop/ui/src/settings.tsx | 5 +++-- desktop/ui/src/sidebar.tsx | 4 +++- desktop/ui/src/styles.css | 27 ++++++++++++++++++++++----- desktop/ui/src/titlebar.test.tsx | 21 ++++++++++++++++----- desktop/ui/src/titlebar.tsx | 6 +++--- 6 files changed, 56 insertions(+), 20 deletions(-) diff --git a/desktop/ui/src/navigation.test.tsx b/desktop/ui/src/navigation.test.tsx index 0192fc568..c212683a0 100644 --- a/desktop/ui/src/navigation.test.tsx +++ b/desktop/ui/src/navigation.test.tsx @@ -18,10 +18,11 @@ afterEach(() => { vi.unstubAllGlobals(); }); -describe("一级导航栏的栏宽归属", () => { - // 栏宽随窗宽收窄、底色与右分隔线都在 CSS(styles.css .mc-nav-rail 与 - // ::after),写进内联样式会静默盖掉这些规则。mac 自绘红绿灯也依赖 - // 62px 栏宽收纳整组圆点,宽度被内联锁死的话窄窗下会挤压变形。 +describe("双层侧栏的栏宽归属", () => { + // 栏宽随窗宽收窄(--railW/--sideW)、底色与右分隔线都在 CSS(styles.css + // .mc-nav-rail 与 ::after、.mc-sidebar-panel),写进内联样式会静默盖掉这些 + // 规则:mac 自绘红绿灯依赖 62px 栏宽收纳整组圆点,窄窗下会挤压变形; + // Windows 自绘标题栏同列也读同一组令牌,内联写死则两层竖线会错开。 it("栏宽、右边线与底色不写在内联样式里,留给 CSS 按平台与窗宽决定", () => { const html = renderToStaticMarkup( { expect(rail![1]).not.toMatch(/(^|;)\s*width:/); expect(rail![1]).not.toMatch(/border-right/); expect(rail![1]).not.toMatch(/background/); + + const panel = /