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:
@@ -0,0 +1,31 @@
|
||||
//go:build !windows
|
||||
|
||||
package win32
|
||||
|
||||
// TrayItem / TrayEvent / TrayManager are no-op stubs on non-Windows.
|
||||
|
||||
type TrayItem struct {
|
||||
ID uint32
|
||||
Label string
|
||||
}
|
||||
|
||||
type TrayEvent struct {
|
||||
ItemID uint32
|
||||
}
|
||||
|
||||
type TrayManager struct {
|
||||
events chan TrayEvent
|
||||
}
|
||||
|
||||
func NewTrayManager(tooltip string, items []TrayItem) (*TrayManager, error) {
|
||||
return nil, ErrUnsupported
|
||||
}
|
||||
|
||||
func (m *TrayManager) Events() <-chan TrayEvent {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
return m.events
|
||||
}
|
||||
|
||||
func (m *TrayManager) Stop() {}
|
||||
Reference in New Issue
Block a user