From 65bc8cde47bba22a13399641891aaf129bba6650 Mon Sep 17 00:00:00 2001 From: ArvinLovegood Date: Mon, 7 Apr 2025 12:25:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(stock):=E4=BF=AE=E5=A4=8D=E8=82=A1=E7=A5=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在前端 stock 组件中增加了对股票代码是否已存在于 stocks.value 中的检查 - 如果股票代码不存在,则删除对应的 result.key - 在后端 app.go 中增加了对股票价格变化的判断,只有在价格变化时才发送事件 --- app.go | 4 +++- frontend/src/components/stock.vue | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index 0496d25..37c09a0 100644 --- a/app.go +++ b/app.go @@ -443,10 +443,12 @@ func MonitorStockPrices(a *App) { total += stockInfo.ProfitAmountToday price, _ := convertor.ToFloat(stockInfo.Price) + if stockInfo.PrePrice != price { - //logger.SugaredLogger.Infof("-----------------------股票代码: %s, 股票名称: %s, 股票价格: %s,盘前盘后:%s", stockInfo.Code, stockInfo.Name, stockInfo.Price, stockInfo.BA) + //logger.SugaredLogger.Infof("-----------sz------------股票代码: %s, 股票名称: %s, 股票价格: %s,盘前盘后:%s", stockInfo.Code, stockInfo.Name, stockInfo.Price, stockInfo.BA) go runtime.EventsEmit(a.ctx, "stock_price", stockInfo) } + } if total != 0 { title := "go-stock " + time.Now().Format(time.DateTime) + fmt.Sprintf(" %.2f¥", total) diff --git a/frontend/src/components/stock.vue b/frontend/src/components/stock.vue index 0aab8f3..4a003c2 100644 --- a/frontend/src/components/stock.vue +++ b/frontend/src/components/stock.vue @@ -518,6 +518,9 @@ async function updateData(result) { //result.key=result.sort result.key=GetSortKey(result.sort,result["股票代码"]) results.value[GetSortKey(result.sort,result["股票代码"])]=result + if(!stocks.value.includes(result["股票代码"])) { + delete results.value[result.key] + } console.log("updateData",result) }