refactor(app): 重构应用控制逻辑并修正部分功能

-移除了 App.shutdown 方法中的 runtime.Quit 调用
- 将 runtime.Show 替换为 runtime.WindowShow
- 在全屏菜单项中移除了 MenuItem.Hide 调用
- 将 runtime.Hide替换为 runtime.WindowHide
This commit is contained in:
spark 2025-01-07 09:42:20 +08:00
parent 88aa793774
commit b764770729
2 changed files with 2 additions and 4 deletions

3
app.go
View File

@ -82,7 +82,6 @@ func (a *App) beforeClose(ctx context.Context) (prevent bool) {
func (a *App) shutdown(ctx context.Context) {
// Perform your teardown here
systray.Quit()
runtime.Quit(ctx)
}
// Greet returns a greeting for the given name
@ -159,7 +158,7 @@ func onReady(a *App) {
//systray.Quit()
case <-show.ClickedCh:
logger.SugaredLogger.Infof("显示应用程序")
runtime.Show(a.ctx)
runtime.WindowShow(a.ctx)
//runtime.WindowShow(a.ctx)
//case <-hide.ClickedCh:
// logger.SugaredLogger.Infof("隐藏应用程序")

View File

@ -64,7 +64,6 @@ func main() {
FileMenu.AddSeparator()
FileMenu.AddText("窗口全屏", keys.CmdOrCtrl("f"), func(callback *menu.CallbackData) {
runtime.WindowFullscreen(app.ctx)
callback.MenuItem.Hide()
})
FileMenu.AddText("窗口还原", keys.Key("Esc"), func(callback *menu.CallbackData) {
runtime.WindowUnfullscreen(app.ctx)
@ -72,7 +71,7 @@ func main() {
if goruntime.GOOS == "windows" {
FileMenu.AddText("隐藏到托盘区", keys.CmdOrCtrl("h"), func(_ *menu.CallbackData) {
runtime.Hide(app.ctx)
runtime.WindowHide(app.ctx)
})
}