From 1ab6875790d892bd9428b3363fbae506c23d8ef6 Mon Sep 17 00:00:00 2001 From: sparkmemory Date: Mon, 23 Dec 2024 11:25:33 +0800 Subject: [PATCH] update --- app.go | 9 +++++++++ main.go | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app.go b/app.go index cfecd3d..942db27 100644 --- a/app.go +++ b/app.go @@ -5,6 +5,7 @@ import ( "github.com/wailsapp/wails/v2/pkg/runtime" "go-stock/backend/data" "go-stock/backend/logger" + "time" ) // App struct @@ -26,6 +27,14 @@ func (a *App) startup(ctx context.Context) { // domReady is called after front-end resources have been loaded func (a *App) domReady(ctx context.Context) { // Add your action here + ticker := time.NewTicker(time.Second) + defer ticker.Stop() + //定时更新数据 + go func() { + for range ticker.C { + runtime.WindowSetTitle(ctx, "go-stock "+time.Now().Format("2006-01-02 15:04:05")) + } + }() } // beforeClose is called when the application is about to quit, diff --git a/main.go b/main.go index 38fe815..d018324 100644 --- a/main.go +++ b/main.go @@ -39,15 +39,6 @@ func main() { // Create an instance of the app structure app := NewApp() - - //ticker := time.NewTicker(time.Second) - //defer ticker.Stop() - ////定时更新数据 - //go func() { - // for range ticker.C { - // runtime.WindowSetTitle(app.ctx, "go-stock "+time.Now().Format("2006-01-02 15:04:05")) - // } - //}() // Create application with options err := wails.Run(&options.App{ Title: "go-stock",