✨ Added hotkey service
This commit is contained in:
@@ -18,16 +18,31 @@ func RegisterTrayEvents(app *application.App, systray *application.SystemTray, m
|
||||
// 设置点击托盘图标显示主窗口
|
||||
systray.OnClick(func() {
|
||||
mainWindow.Show()
|
||||
mainWindow.Restore()
|
||||
mainWindow.Focus()
|
||||
// 通知前端窗口已显示
|
||||
app.EmitEvent("window:shown", nil)
|
||||
})
|
||||
|
||||
// 使用关闭前的事件处理
|
||||
// 处理窗口关闭事件 - 隐藏到托盘
|
||||
mainWindow.RegisterHook(wailsevents.Common.WindowClosing, func(event *application.WindowEvent) {
|
||||
// 取消默认关闭行为
|
||||
event.Cancel()
|
||||
// 隐藏窗口
|
||||
// 隐藏窗口到托盘
|
||||
mainWindow.Hide()
|
||||
// 通知前端窗口已隐藏
|
||||
app.EmitEvent("window:hidden", nil)
|
||||
})
|
||||
|
||||
// 处理窗口最小化事件 - 也隐藏到托盘
|
||||
mainWindow.RegisterHook(wailsevents.Common.WindowMinimise, func(event *application.WindowEvent) {
|
||||
// 取消默认最小化行为
|
||||
event.Cancel()
|
||||
// 隐藏窗口到托盘
|
||||
mainWindow.Hide()
|
||||
// 通知前端窗口已隐藏
|
||||
app.EmitEvent("window:hidden", nil)
|
||||
})
|
||||
}
|
||||
|
||||
// RegisterTrayMenuEvents 注册系统托盘菜单事件
|
||||
|
Reference in New Issue
Block a user