窗口标题显示当前时间

This commit is contained in:
spark 2024-12-19 20:59:01 +08:00
parent 6b62385cad
commit d240239fcc

12
main.go
View File

@ -9,10 +9,12 @@ import (
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/mac"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"github.com/wailsapp/wails/v2/pkg/runtime"
"go-stock/backend/data"
"go-stock/backend/db"
"log"
"os"
"time"
)
//go:embed frontend/dist
@ -41,6 +43,15 @@ 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",
@ -100,6 +111,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
}
func initStockData() {