This commit is contained in:
sparkmemory 2024-12-23 11:25:33 +08:00
parent cc40da8371
commit 1ab6875790
2 changed files with 9 additions and 9 deletions

9
app.go
View File

@ -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,

View File

@ -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",