From b98f8292865728abe33c16ccba9fa54a465837ef Mon Sep 17 00:00:00 2001 From: ArvinLovegood Date: Thu, 17 Jul 2025 17:31:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(update):=E4=BC=98=E5=8C=96=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 CheckUpdate 函数签名,添加 flag 参数 -根据 flag 参数控制是否显示"当前版本无更新"的通知 - 调整前端按钮点击事件,传递参数 1 给 CheckUpdate 函数 - 优化后端更新检查流程,减少不必要的通知推送 --- app.go | 21 ++++++++++++--------- frontend/src/components/about.vue | 2 +- frontend/wailsjs/go/main/App.d.ts | 2 +- frontend/wailsjs/go/main/App.js | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app.go b/app.go index 47d112f..b3516de 100644 --- a/app.go +++ b/app.go @@ -144,7 +144,7 @@ func (a *App) CheckSponsorCode(sponsorCode string) map[string]any { } } -func (a *App) CheckUpdate() { +func (a *App) CheckUpdate(flag int) { sponsorCode := strutil.Trim(a.GetConfig().SponsorCode) if sponsorCode != "" { encrypted, err := hex.DecodeString(sponsorCode) @@ -296,12 +296,15 @@ func (a *App) CheckUpdate() { }) } } else { - go runtime.EventsEmit(a.ctx, "newsPush", map[string]any{ - "time": "当前版本:" + Version, - "isRed": false, - "source": "go-stock", - "content": "当前版本无更新", - }) + if flag == 1 { + go runtime.EventsEmit(a.ctx, "newsPush", map[string]any{ + "time": "当前版本:" + Version, + "isRed": false, + "source": "go-stock", + "content": "当前版本无更新", + }) + } + } } @@ -430,11 +433,11 @@ func (a *App) domReady(ctx context.Context) { } //检查新版本 go func() { - a.CheckUpdate() + a.CheckUpdate(0) a.CheckStockBaseInfo(a.ctx) a.cron.AddFunc("30 05 8,12,20 * * *", func() { logger.SugaredLogger.Errorf("Checking for updates...") - a.CheckUpdate() + a.CheckUpdate(0) }) }() diff --git a/frontend/src/components/about.vue b/frontend/src/components/about.vue index f00429f..ec9d6d9 100644 --- a/frontend/src/components/about.vue +++ b/frontend/src/components/about.vue @@ -119,7 +119,7 @@ EventsOn("updateVersion",async (msg) => { vip到期时间:{{vipEndTime}} - 检查更新 + 检查更新

自选股行情实时监控,基于Wails和NaiveUI构建的AI赋能股票分析工具

目前已支持A股,港股,美股,未来计划加入基金,ETF等支持

diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts index f357823..f5bc6a7 100755 --- a/frontend/wailsjs/go/main/App.d.ts +++ b/frontend/wailsjs/go/main/App.d.ts @@ -18,7 +18,7 @@ export function CheckSponsorCode(arg1:string):Promise>; export function CheckStockBaseInfo(arg1:context.Context):Promise; -export function CheckUpdate():Promise; +export function CheckUpdate(arg1:number):Promise; export function ClsCalendar():Promise>; diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js index 00aa96a..bf3a42e 100755 --- a/frontend/wailsjs/go/main/App.js +++ b/frontend/wailsjs/go/main/App.js @@ -30,8 +30,8 @@ export function CheckStockBaseInfo(arg1) { return window['go']['main']['App']['CheckStockBaseInfo'](arg1); } -export function CheckUpdate() { - return window['go']['main']['App']['CheckUpdate'](); +export function CheckUpdate(arg1) { + return window['go']['main']['App']['CheckUpdate'](arg1); } export function ClsCalendar() {