Skip to content

fix(window): 恢复 macOS 原生交通灯#197

Merged
H-Chris233 merged 1 commit into
Open-Less:mainfrom
H-Chris233:main
May 3, 2026
Merged

fix(window): 恢复 macOS 原生交通灯#197
H-Chris233 merged 1 commit into
Open-Less:mainfrom
H-Chris233:main

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

@H-Chris233 H-Chris233 commented May 3, 2026

User description

摘要

Fixes #183

本 PR 修复 macOS 下窗口左上角原生红黄绿交通灯消失,以及窗口出现双重圆角的问题。

此前应用使用自定义窗口壳时,macOS 没有显示系统原生 traffic lights,导致窗口关闭 / 最小化 / 最大化按钮缺失或反馈不符合系统习惯。同时 macOS 外层 shell 仍保留额外圆角和边框,叠加原生窗口效果后会出现双重圆角观感。

本次改动在 macOS 运行时单独开启 native decorations,以恢复系统原生交通灯;Windows / Linux 仍保持现有自定义标题栏行为,不通过全局 tauri.conf 打开 decorations,避免影响非 macOS 平台窗口样式。

修复 / 新增 / 改进

  • macOS 主窗口运行时启用 native decorations:

    • 恢复系统原生红黄绿 traffic lights
    • 保留 macOS 原生窗口按钮交互反馈
  • 不在 tauri.conf 中全局开启 decorations:

    • 避免 Windows / Linux 被切换到原生标题栏
    • 保持非 macOS 平台现有自定义窗口行为
  • 调整 WindowChrome 的 macOS 外层样式:

    • macOS 外层 shell radius 改为 0
    • macOS 外层 border 改为 none
    • 避免原生窗口外观与自定义壳叠加形成双重圆角 / 双重边框
  • 增加 native decorations 开启失败时的 warning 日志:

    • [main] enable native decorations failed: ...

兼容

  • 不包含:

    • 不全局开启 Tauri native chrome。
    • 不改变 Windows 自定义标题栏行为。
    • 不改变 Linux 自定义标题栏行为。
    • 不重构窗口组件结构。
    • 不引入新依赖。
    • 不调整业务页面布局。
  • 对现有用户 / 本地环境 / 构建流程的影响:

    • macOS 用户会重新看到系统原生红黄绿窗口按钮。
    • macOS 窗口外观不再出现额外双重圆角 / 外层边框。
    • Windows / Linux 继续使用现有自定义窗口壳。
    • 构建流程无变化。

测试计划

  • 命令:npm run build

  • 结果:通过

  • 证据路径:openless-all/app 本地构建输出

  • macOS 真机窗口视觉验证

  • Windows 真机窗口视觉验证

  • Linux 真机窗口视觉验证

  • 说明:当前 commit 未做真实 macOS / Windows / Linux 运行时视觉回归验证。

主要改动文件

  • openless-all/app/src-tauri/src/lib.rs
  • openless-all/app/src/components/WindowChrome.tsx

备注

本 PR 采用平台运行时分支处理窗口 decorations:只在 macOS 恢复 native traffic lights,不把该行为扩散到 Windows / Linux。这样可以同时修复 macOS 原生按钮缺失问题,并保留非 macOS 平台的自定义标题栏体验。


PR Type

Bug fix


Description

  • 在 macOS 运行时为主窗口启用原生装饰,恢复系统交通灯按钮

  • 移除 macOS 下自定义窗口壳的圆角和边框,消除双重圆角

  • 添加 set_decorations 失败时的警告日志

  • 保持 Windows/Linux 的自定义标题栏行为不变


Diagram Walkthrough

flowchart LR
  A["macOS 运行时"] -- "启用原生装饰" --> B["lib.rs: set_decorations(true)"]
  A -- "移除自定义外观" --> C["WindowChrome.tsx: shellRadius=0, border=none"]
  B --> D["恢复系统交通灯"]
  C --> D
  D --> E["消除双重圆角与交互缺失"]
Loading

File Walkthrough

Relevant files
Bug fix
lib.rs
macOS 运行时启用原生窗口装饰                                                                               

openless-all/app/src-tauri/src/lib.rs

  • 在 macOS 构建目标下,为主窗口调用 set_decorations(true) 以启用系统原生交通灯
  • 增加 set_decorations 失败的 warn 日志,输出错误详情
+3/-0     
WindowChrome.tsx
移除 macOS 自定义窗口壳的圆角和边框                                                                       

openless-all/app/src/components/WindowChrome.tsx

  • 将 macOS 外壳圆角半径 shellRadius 从 20 改为 0
  • 将 macOS 外壳边框样式改为 'none',移除原有 0.5px 深色边框
  • 避免自定义壳与原生窗口视觉叠加导致的双重圆角和多余边框
+6/-2     

…ndows

Keep custom chrome on non-mac platforms while restoring native traffic lights on macOS. Also remove the extra outer mac shell radius/border to avoid double-rounded corners.

Constraint: macOS must show native traffic lights for issue Open-Less#183
Constraint: Windows/Linux should keep custom titlebar behavior
Rejected: set decorations=true in tauri.conf globally | enables native chrome on Linux
Confidence: high
Scope-risk: narrow
Directive: Platform-specific window decoration behavior should be controlled at runtime, not by global config
Tested: npm run build (openless-all/app)
Not-tested: manual visual verification on real macOS/Linux/Windows runtimes
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 3, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

183 - PR Code Verified

Compliant requirements:

  • macOS 窗口原生红黄绿交通灯消失
  • macOS 窗口双重圆角
  • 红黄绿按钮光标反馈感(恢复原生装饰后系统自带反馈)

Requires further human verification:

  • 在 macOS 上实际验证原生交通灯是否正常显示,悬停/点击反馈是否符合系统习惯
  • 确认双重圆角已消失,窗口外观与系统原生窗口一致
  • 检查 Linux 下非 macOS 平台的窗口样式是否未受影响(shellRadius、边框等)
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit 90497a6 into Open-Less:main May 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI]窗口有多余双重圆角/三按钮放置光标无反馈感

1 participant