Skip to content

Commit 1628381

Browse files
author
spark
committed
feat(app): 添加版本信息,为更新推送做准备
- 在应用启动时打印版本号
1 parent 8afc26b commit 1628381

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
submodules: recursive
3333

3434
- name: Build wails
35-
uses: ArvinLovegood/wails-build-action@v2.3
35+
uses: ArvinLovegood/wails-build-action@v2.4
3636
id: build
3737
with:
3838
build-name: ${{ matrix.build.name }}

app.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func NewApp() *App {
3737

3838
// startup is called at application startup
3939
func (a *App) startup(ctx context.Context) {
40+
logger.SugaredLogger.Infof("Version:%s", Version)
4041
// Perform your setup here
4142
a.ctx = ctx
4243

@@ -47,6 +48,18 @@ func (a *App) startup(ctx context.Context) {
4748
go onExit(a)
4849
})
4950

51+
//检查新版本
52+
go func() {
53+
config := data.NewSettingsApi(&data.Settings{}).GetConfig()
54+
if config.CheckUpdate {
55+
checkUpdate(a)
56+
}
57+
}()
58+
59+
}
60+
61+
func checkUpdate(a *App) {
62+
5063
}
5164

5265
// domReady is called after front-end resources have been loaded

backend/data/settings_api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Settings struct {
2222
OpenAiMaxTokens int `json:"openAiMaxTokens"`
2323
OpenAiTemperature float64 `json:"openAiTemperature"`
2424
Prompt string `json:"prompt"`
25+
CheckUpdate bool `json:"checkUpdate"`
2526
}
2627

2728
func (receiver Settings) TableName() string {

frontend/wailsjs/go/models.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export namespace data {
7474
openAiMaxTokens: number;
7575
openAiTemperature: number;
7676
prompt: string;
77+
checkUpdate: boolean;
7778

7879
static createFrom(source: any = {}) {
7980
return new Settings(source);
@@ -98,6 +99,7 @@ export namespace data {
9899
this.openAiMaxTokens = source["openAiMaxTokens"];
99100
this.openAiTemperature = source["openAiTemperature"];
100101
this.prompt = source["prompt"];
102+
this.checkUpdate = source["checkUpdate"];
101103
}
102104

103105
convertValues(a: any, classs: any, asMap: boolean = false): any {

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ var icon2 []byte
3333
var stocksBin []byte
3434

3535
//go:generate cp -R ./data ./build/bin
36+
37+
var Version string
38+
3639
func main() {
3740
checkDir("data")
3841
db.Init("")
@@ -82,7 +85,7 @@ func main() {
8285
//FileMenu.AddText("退出", keys.CmdOrCtrl("q"), func(_ *menu.CallbackData) {
8386
// runtime.Quit(app.ctx)
8487
//})
85-
88+
logger.NewDefaultLogger().Info("version: " + Version)
8689
// Create application with options
8790
err := wails.Run(&options.App{
8891
Title: "go-stock",

0 commit comments

Comments
 (0)