diff --git a/src/views/AiEmotion.vue b/src/views/AiEmotion.vue index b6caa39..8f69ddc 100644 --- a/src/views/AiEmotion.vue +++ b/src/views/AiEmotion.vue @@ -530,6 +530,12 @@ const addedStocks = ref(new Set()); // 从stockList生成对话历史 const loadConversationsFromStockList = () => { + // 如果当前正在处理用户发送的消息,跳过加载以避免重复 + if (isRotating.value) { + console.log("正在处理用户消息,跳过对话历史加载"); + return; + } + // 检查是否有新的股票需要添加到对话中 emotionStore.stockList.forEach((stock) => { const stockKey = `${stock.stockInfo.code}_${stock.timestamp}`; @@ -2186,13 +2192,15 @@ async function handleSendMessage(input, onComplete) { isPageLoaded.value = true; // 使用nextTick确保DOM更新后清空对话显示并启动高度监听器 - nextTick(() => { - messages.value = []; - // 启动页面高度监听器,实时监听内容变化并自动滚动 - startHeightObserver(); - // 立即滚动到底部 - scrollToBottom(); - }); + nextTick(() => { + messages.value = []; + // 清空已添加股票的记录,避免重复添加 + addedStocks.value.clear(); + // 启动页面高度监听器,实时监听内容变化并自动滚动 + startHeightObserver(); + // 立即滚动到底部 + scrollToBottom(); + }); // 数据获取成功后,重新获取用户次数以实现实时更新 try {