feat(app): 优化应用隐藏功能并添加错误日志

- 注释掉隐藏应用程序的代码,暂时禁用此功能
- 添加对话框错误日志记录,提高错误追踪能力
- 在 shutdown 函数中添加 runtime.Quit 调用,确保应用正确退出
-优化股票组件中的报警逻辑,增加对当前价格的判断
This commit is contained in:
spark 2025-01-07 09:27:24 +08:00
parent 180bec8866
commit 88aa793774
2 changed files with 11 additions and 7 deletions

12
app.go
View File

@ -68,6 +68,7 @@ func (a *App) beforeClose(ctx context.Context) (prevent bool) {
})
if err != nil {
logger.SugaredLogger.Errorf("dialog error:%s", err.Error())
return false
}
logger.SugaredLogger.Debugf("dialog:%s", dialog)
@ -80,7 +81,8 @@ func (a *App) beforeClose(ctx context.Context) (prevent bool) {
// shutdown is called at application termination
func (a *App) shutdown(ctx context.Context) {
// Perform your teardown here
//systray.Quit()
systray.Quit()
runtime.Quit(ctx)
}
// Greet returns a greeting for the given name
@ -143,7 +145,7 @@ func onReady(a *App) {
// 创建菜单项
show := systray.AddMenuItem("显示", "显示应用程序")
hide := systray.AddMenuItem("隐藏", "隐藏应用程序")
//hide := systray.AddMenuItem("隐藏", "隐藏应用程序")
systray.AddSeparator()
mQuitOrig := systray.AddMenuItem("退出", "退出应用程序")
@ -159,9 +161,9 @@ func onReady(a *App) {
logger.SugaredLogger.Infof("显示应用程序")
runtime.Show(a.ctx)
//runtime.WindowShow(a.ctx)
case <-hide.ClickedCh:
logger.SugaredLogger.Infof("隐藏应用程序")
runtime.Hide(a.ctx)
//case <-hide.ClickedCh:
// logger.SugaredLogger.Infof("隐藏应用程序")
// runtime.Hide(a.ctx)
}
}

View File

@ -204,8 +204,10 @@ async function monitor() {
}else if(result.profitAmount<0){
result.profitType="success"
}
if((res[0].AlarmChangePercent>0&&Math.abs(roundedNum)>res[0].AlarmChangePercent)||(res[0].AlarmPrice>0&&result["当前价格"]>res[0].AlarmPrice)){
SendMessage(result)
if(result["当前价格"]){
if((res[0].AlarmChangePercent>0&&Math.abs(roundedNum)>res[0].AlarmChangePercent)||(res[0].AlarmPrice>0&&result["当前价格"]>res[0].AlarmPrice)){
SendMessage(result)
}
}
}
results.value[result["股票名称"]]=result