Skip to content

fix(desktop): 托盘图标改为单色图,适配菜单栏深浅与尺寸 - #351

Merged
AmintaCCCP merged 2 commits into
mainfrom
fix/tray-template-icon
Sep 12, 2026
Merged

AmintaCCCP merged 2 commits into
mainfrom
fix/tray-template-icon

Conversation

@AmintaCCCP

@AmintaCCCP AmintaCCCP commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

背景

#345 新增了托盘图标,但用的是全彩 App 图标:在 macOS 菜单栏里是一块深色圆角方块,颜色突兀、尺寸偏大。

改动

  • macOS:改用单色 template 图(trayTemplate.png + @2x,纯黑+alpha),系统自动适配菜单栏深浅外观,不再需要维护两种颜色
  • Windows / Linux:没有 template 机制,新增 tray-black / tray-white 两份单色图(16/32px),通过 nativeTheme.updated 跟随系统深浅主题切换
  • 原 tray-16/32.png 彩色图保留为加载兜底
  • scripts/build-desktop.js 托盘图标存在性校验同步更新

验证

  • 真机菜单栏实测:template 图在浅色/着色菜单栏自动反色,视觉重量与系统图标一致
  • node --check、npm run test:electron:mcp 通过

Summary by CodeRabbit

  • 改进

    • 优化 macOS 托盘图标显示,支持系统模板图效果。
    • 托盘图标可根据系统深浅色主题自动切换。
    • 系统主题变化后,托盘图标会自动更新。
  • 构建

    • 完善桌面应用构建时的托盘图标完整性检查,覆盖不同平台和主题所需的图标资源。

- macOS 菜单栏改用 trayTemplate.png/@2x(纯黑+alpha template 图),
  系统自动适配深浅外观,替代原先突兀的全彩方块图标
- Windows/Linux 无 template 机制,新增 tray-black/tray-white 两份单色图,
  通过 nativeTheme.updated 跟随系统深浅主题切换
- 原 tray-16/32.png 彩色图保留为兜底;build-desktop.js 校验清单同步更新
@coderabbitai

coderabbitai Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 71b7fd34-a065-4f65-a155-b7c5794b4931

📥 Commits

Reviewing files that changed from the base of the PR and between 80ed00d and 6b48cec.

📒 Files selected for processing (1)
  • electron/main.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • electron/main.js

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

托盘图标验证范围已扩展。Electron 主进程支持 macOS 模板图,并在其他平台根据系统主题切换托盘图标。

Changes

托盘图标主题适配

Layer / File(s) Summary
托盘图标资源验证
scripts/build-desktop.js
构建脚本验证 8 个托盘图标文件。缺少任一文件时打印错误并退出。
运行时托盘图标切换
electron/main.js
macOS 优先使用模板图并启用 setTemplateImage(true)。其他平台根据 nativeTheme.shouldUseDarkColors 选择图标,并在主题变化后调用 tray.setImage。

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant nativeTheme
  participant resolveTrayIcon
  participant tray
  nativeTheme->>resolveTrayIcon: 提供系统主题状态
  resolveTrayIcon->>tray: 选择并设置托盘图标
  nativeTheme->>tray: 主题更新后触发 setImage
Loading

Merge Risk: ⚪ Minimal · up to 6b48c

No concrete merge-blocking risk remains from the supplied review context.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:托盘图标改为单色图,并适配菜单栏的深浅主题与图标尺寸。
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AmintaCCCP
AmintaCCCP merged commit 6920d4d into main Sep 12, 2026
8 checks passed
@AmintaCCCP
AmintaCCCP deleted the fix/tray-template-icon branch September 12, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant