From b7647707292465a4f93b86ebaefb8053c600a0cf Mon Sep 17 00:00:00 2001 From: spark Date: Tue, 7 Jan 2025 09:42:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(app):=20=E9=87=8D=E6=9E=84=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=8E=A7=E5=88=B6=E9=80=BB=E8=BE=91=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E9=83=A8=E5=88=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -移除了 App.shutdown 方法中的 runtime.Quit 调用 - 将 runtime.Show 替换为 runtime.WindowShow - 在全屏菜单项中移除了 MenuItem.Hide 调用 - 将 runtime.Hide替换为 runtime.WindowHide --- app.go | 3 +-- main.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app.go b/app.go index efabc9b..0fd3776 100644 --- a/app.go +++ b/app.go @@ -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("隐藏应用程序") diff --git a/main.go b/main.go index 964b652..28d83c3 100644 --- a/main.go +++ b/main.go @@ -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) }) }