mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
fix(stock):修复股票代码错误导致的重复问题
- 在前端 stock 组件中增加了对股票代码是否已存在于 stocks.value 中的检查 - 如果股票代码不存在,则删除对应的 result.key - 在后端 app.go 中增加了对股票价格变化的判断,只有在价格变化时才发送事件
This commit is contained in:
parent
b45d5dc762
commit
65bc8cde47
4
app.go
4
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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user