From abf05aabd8a12b3be3340c4ff6c1623ff89b3fa1 Mon Sep 17 00:00:00 2001 From: spark Date: Fri, 20 Dec 2024 14:33:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E7=A8=8B=E5=BA=8F=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index bc2318d..cfecd3d 100644 --- a/app.go +++ b/app.go @@ -2,7 +2,9 @@ package main import ( "context" + "github.com/wailsapp/wails/v2/pkg/runtime" "go-stock/backend/data" + "go-stock/backend/logger" ) // App struct @@ -22,7 +24,7 @@ func (a *App) startup(ctx context.Context) { } // domReady is called after front-end resources have been loaded -func (a App) domReady(ctx context.Context) { +func (a *App) domReady(ctx context.Context) { // Add your action here } @@ -30,6 +32,23 @@ func (a App) domReady(ctx context.Context) { // either by clicking the window close button or calling runtime.Quit. // Returning true will cause the application to continue, false will continue shutdown as normal. func (a *App) beforeClose(ctx context.Context) (prevent bool) { + + dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{ + Type: runtime.QuestionDialog, + Title: "go-stock", + Message: "确定关闭吗?", + Buttons: []string{"确定"}, + Icon: icon, + CancelButton: "取消", + }) + + if err != nil { + return false + } + logger.SugaredLogger.Debugf("dialog:%s", dialog) + if dialog == "No" { + return true + } return false }