feat(ui): 系统托盘 + 关闭最小化到托盘

- 原生 win32 实现的 TrayManager:Shell_NotifyIcon + 私有 message-only
  窗口承载 popup 菜单,专用 OS 线程跑 GetMessage 泵,避免引入 cgo 依赖。
- WindowSubclass 通过 SetWindowLongPtrW 子类化 Gio 主窗口,拦截
  WM_CLOSE:minimize_to_tray=true 时吞掉消息只隐藏窗口;exit 路径下
  放行让 Gio 正常关闭事件循环。
- Preferences 新增"最小化到托盘"复选框,切换后立即重装/卸载钩子,
  不需要重启程序。
- 托盘菜单提供 Show / Hide / Exit;左键单击图标等同 Show;右键弹菜单。
- 非 Windows 平台所有相关 API 退化为 ErrUnsupported / no-op stub。
This commit is contained in:
2026-06-12 04:13:35 +08:00
parent 0918fd446a
commit c0dd3b9028
11 changed files with 808 additions and 8 deletions
+17
View File
@@ -448,3 +448,20 @@ other = "Automatisch sperren nach (Minuten)"
[hint_auto_lock_disabled]
other = "0 deaktiviert. Nur wirksam, wenn die Konfiguration verschlüsselt ist."
# --- System-Tray ---
[tray_show]
other = "WinAuth anzeigen"
[tray_hide]
other = "WinAuth ausblenden"
[tray_exit]
other = "Beenden"
[label_minimize_to_tray]
other = "Beim Schließen in den Tray minimieren"
[hint_minimize_to_tray]
other = "Schließen des Fensters versteckt es im System-Tray statt das Programm zu beenden."
+17
View File
@@ -450,3 +450,20 @@ other = "Auto-lock after (minutes)"
[hint_auto_lock_disabled]
other = "Set to 0 to disable. Only takes effect when the configuration is encrypted."
# --- System tray ---
[tray_show]
other = "Show WinAuth"
[tray_hide]
other = "Hide WinAuth"
[tray_exit]
other = "Exit"
[label_minimize_to_tray]
other = "Minimize to tray when closing the window"
[hint_minimize_to_tray]
other = "Closing the window hides it to the system tray instead of exiting."
+17
View File
@@ -448,3 +448,20 @@ other = "自动锁定(分钟)"
[hint_auto_lock_disabled]
other = "填 0 关闭。仅当配置已加密时生效。"
# --- 系统托盘 ---
[tray_show]
other = "显示 WinAuth"
[tray_hide]
other = "隐藏 WinAuth"
[tray_exit]
other = "退出"
[label_minimize_to_tray]
other = "关闭窗口时最小化到托盘"
[hint_minimize_to_tray]
other = "勾选后点击窗口关闭按钮将隐藏到系统托盘而非退出程序。"