Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(builder/navbar): revise the vertical position annotation of traffic lights to reflect actual logic(#663)

hairyfe286e49ba128
diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rs
index ba54ed93..0957c4b9 100644
--- a/src-tauri/src/desktop/builder.rs
+++ b/src-tauri/src/desktop/builder.rs
@@ -47,11 +47,15 @@ pub const SHELL_NAV_HEIGHT: u32 = 44;
#[cfg(target_os = "macos")]
const TRAFFIC_LIGHT_INSET_X: f64 = 14.0;
-/// Wry 保留了 AppKit 原生按钮的纵向 frame 偏移:实测视觉圆心 = 传入 y − 2
-/// (44px 栏高配 y = 24 时圆心为 22px,而非直觉上的 24px)。因此「视觉圆心 =
-/// 栏高 / 2」对应 y = 栏高 / 2 + 2(44px 栏高 → 24)。
+/// 交通灯纵向锚点相对「栏高 / 2」的修正量(逻辑像素)。
+///
+/// tao 的 `inset_traffic_lights` 只把标题栏容器高度改成 `close_rect.height + y`,
+/// AppKit 按钮仍贴着容器底边,故传入 y 与按钮视觉圆心近似 1:1 平移(实测 y = 24
+/// 时圆心落在窗口顶端下方 26px)。2x 截图实测:圆心在设备行 54,而栏内 flex 居中
+/// 的折叠/展开按钮圆心在设备行 45(= 栏内容盒中心),低 9 设备像素 = 4.5 逻辑像素,
+/// 故锚点要回退 4.5:44 / 2 + (−2.5) = 19.5。
#[cfg(target_os = "macos")]
-const TRAFFIC_LIGHT_VISUAL_OFFSET: f64 = 2.0;
+const TRAFFIC_LIGHT_VISUAL_OFFSET: f64 = -2.5;
/// WebView2 原生拖拽区域所需的参数。
///
@@ -520,8 +524,8 @@ pub fn build_main_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::We
.decorations(true)
.title_bar_style(tauri::TitleBarStyle::Overlay)
.hidden_title(true)
- // 交通灯纵向位置由 SHELL_NAV_HEIGHT 推导(见常量注释),使视觉圆心落在
- // 栏高一半,与随栏高 flex 居中的折叠/展开按钮同一水平线(issue #524)。
+ // 交通灯纵向位置由 SHELL_NAV_HEIGHT 与 TRAFFIC_LIGHT_VISUAL_OFFSET 推导
+ // (见常量注释),使视觉圆心与随栏高 flex 居中的折叠/展开按钮同一水平线(issue #524)。
// 位置只在窗口创建时生效:Tauri 2.11.5 没有运行期交通灯 API,而 wry
// 0.55.1 会在自身重绘时按创建时的值回放(`WryWebViewParent::drawRect:`),
// 所以运行期改 NSWindow 会被随时覆盖——改栏高必须同步上面的常量。
@@ -679,7 +683,7 @@ pub fn build_extra_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::W
.title_bar_style(tauri::TitleBarStyle::Overlay)
.hidden_title(true)
// 与主窗口同一真值:附加窗口用的是同一个壳层导航栏(h-11 = 44px),
- // 交通灯必须落在同一水平线上(写死 24.0 会随 #524 的栏高改动错位 4px)。
+ // 交通灯必须落在同一水平线上(写死锚点值会随 #524 的栏高/修正量改动错位)。
.traffic_light_position(tauri::LogicalPosition::new(
TRAFFIC_LIGHT_INSET_X,
f64::from(SHELL_NAV_HEIGHT) / 2.0 + TRAFFIC_LIGHT_VISUAL_OFFSET,
diff --git a/src/layout/components/navbar.tsx b/src/layout/components/navbar.tsx
index da574f69..672b7a73 100644
--- a/src/layout/components/navbar.tsx
+++ b/src/layout/components/navbar.tsx
@@ -55,7 +55,7 @@ import { toast } from '@/utils/toast'
* 「文件」「帮助」在 macOS 上由原生菜单栏承载(见 `desktop/builder.rs` 的
* `install_macos_menu`),本组按钮不渲染。
* 交通灯的纵向位置由 `src-tauri/src/desktop/builder.rs` 的 `SHELL_NAV_HEIGHT`
- * 推导(视觉圆心 = 栏高 / 2),与下面根元素的 `h-11` 是同一真值;两者的一致性
+ * 推导(视觉圆心与栏内 flex 居中控件同线),与下面根元素的 `h-11` 是同一真值;两者的一致性
* 由 Rust 测试 `shell_nav_height_matches_navbar_height_class` 守住——改这个
* class 就必须同步那个常量,否则 CI 失败(issue #524)。
* - Windows/Linux:右侧窗口按钮直接调用 Tauri API;