Skip to content

Commit d240239

Browse files
author
spark
committed
窗口标题显示当前时间
1 parent 6b62385 commit d240239

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import (
99
"github.com/wailsapp/wails/v2/pkg/options"
1010
"github.com/wailsapp/wails/v2/pkg/options/mac"
1111
"github.com/wailsapp/wails/v2/pkg/options/windows"
12+
"github.com/wailsapp/wails/v2/pkg/runtime"
1213
"go-stock/backend/data"
1314
"go-stock/backend/db"
1415
"log"
1516
"os"
17+
"time"
1618
)
1719

1820
//go:embed frontend/dist
@@ -41,6 +43,15 @@ func main() {
4143
// Create an instance of the app structure
4244
app := NewApp()
4345

46+
ticker := time.NewTicker(time.Second)
47+
defer ticker.Stop()
48+
//定时更新数据
49+
go func() {
50+
for range ticker.C {
51+
runtime.WindowSetTitle(app.ctx, "go-stock "+time.Now().Format("2006-01-02 15:04:05"))
52+
}
53+
}()
54+
4455
// Create application with options
4556
err := wails.Run(&options.App{
4657
Title: "go-stock",
@@ -100,6 +111,7 @@ func main() {
100111
if err != nil {
101112
log.Fatal(err)
102113
}
114+
103115
}
104116

105117
func initStockData() {

0 commit comments

Comments
 (0)