Skip to content

Commit

Permalink
feat(frontend): 优化 AI 分析功能
Browse files Browse the repository at this point in the history
- 添加 loading 状态和DONE消息处理
- 改进消息提示和销毁逻辑
- 优化 AI 分析结果的展示
- 调整 API测试日志输出
  • Loading branch information
spark committed Jan 31, 2025
1 parent 0d182b9 commit 0bfa50e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ func (a *App) NewChatStream(stock, stockCode string) {
for msg := range msgs {
runtime.EventsEmit(a.ctx, "newChatStream", msg)
}
runtime.EventsEmit(a.ctx, "newChatStream", "DONE")
}

func GenNotificationMsg(stockInfo *data.StockInfo) string {
Expand Down
5 changes: 2 additions & 3 deletions backend/data/stock_data_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ func TestGetTelegraph(t *testing.T) {
}
document.Find("div.telegraph-content-box").Each(func(i int, selection *goquery.Selection) {
text := selection.Text()
if strings.Contains(text, "【公告】") {
logger.SugaredLogger.Info(text)
}
logger.SugaredLogger.Info(text)

})
}

Expand Down
25 changes: 18 additions & 7 deletions frontend/src/components/stock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const data = reactive({
fullscreen: false,
airesult: "",
openAiEnable: false,
loading: true,
})
const sortedResults = computed(() => {
Expand Down Expand Up @@ -81,7 +82,7 @@ onBeforeMount(()=>{
}
}
monitor()
message.destroyAll
message.destroyAll()
})
GetConfig().then(result => {
if (result.openAiEnable) {
Expand Down Expand Up @@ -136,9 +137,15 @@ EventsOn("refreshFollowList",(data)=>{
// })
})
EventsOn("newChatStream",(msg)=>{
//console.log("newChatStream:->",data.airesult)
data.airesult=data.airesult+msg
EventsOn("newChatStream",async (msg) => {
//console.log("newChatStream:->",data.airesult)
data.loading = false
if (msg === "DONE") {
message.info("AI分析完成!")
message.destroyAll()
} else {
data.airesult = data.airesult + msg
}
})
Expand Down Expand Up @@ -337,7 +344,7 @@ function updateCostPriceAndVolumeNew(code,price,volume,alarm,formModel){
}
}
monitor()
message.destroyAll
message.destroyAll()
})
})
}
Expand Down Expand Up @@ -388,7 +395,9 @@ function aiCheckStock(stock,stockCode){
data.name=stock
data.code=stockCode
modalShow4.value=true
message.loading("ai检测中...")
message.loading("ai检测中...",{
duration: 0,
})
NewChatStream(stock,stockCode)
}
Expand Down Expand Up @@ -541,7 +550,9 @@ function getHeight() {
</n-modal>

<n-modal transform-origin="center" v-model:show="modalShow4" preset="card" style="width: 800px;height: 480px" :title="'['+data.name+']AI分析结果'" >
<MdPreview ref="mdPreviewRef" style="height: 380px" :modelValue="data.airesult" :theme="'dark'"/>
<n-spin size="small" :show="data.loading">
<MdPreview ref="mdPreviewRef" style="height: 380px" :modelValue="data.airesult" :theme="'dark'"/>
</n-spin>
</n-modal>
</template>

Expand Down

0 comments on commit 0bfa50e

Please sign in to comment.