From 20681d05a01f6020a659d0a07fafdc74d7f67281 Mon Sep 17 00:00:00 2001 From: no99 <17663930442@163.com> Date: Thu, 2 Oct 2025 15:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B1=E5=BA=A6=E4=B9=9D=E5=A4=A7=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=BB=9A=E5=8A=A8=E5=88=B0=E5=BA=95=E9=83=A8=E7=9A=84?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/deepNine.vue | 10 ++-------- src/views/homePage.vue | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/views/deepNine.vue b/src/views/deepNine.vue index 3df6af2..370c02d 100644 --- a/src/views/deepNine.vue +++ b/src/views/deepNine.vue @@ -722,7 +722,7 @@ const createTypingEffect = (message, content, speed) => { } } if (message.end) { - chatStore.getUserCount(); + homepageChatStore.getUserCount(); chatStore.isLoading = false; console.log("打印完毕,接触输入框禁用状态"); chatStore.chatInput = false; @@ -1874,15 +1874,9 @@ watch( console.error("请求失败:", e); chatStore.firstAPICall = false; hasValidData.value = false; // 请求失败时设置数据无效 - // chatStore.messages.pop(); - // chatStore.messages.push({ - // sender: "ai", - // content: "AI思考失败,请稍后再试... ", - // }); - // chatStore.setLoading(false); } finally { // chatStore.setLoading(false); - await chatStore.getUserCount(); + await homepageChatStore.getUserCount(); } } } diff --git a/src/views/homePage.vue b/src/views/homePage.vue index 0c525a7..668e6dd 100644 --- a/src/views/homePage.vue +++ b/src/views/homePage.vue @@ -61,6 +61,7 @@ const historyRecordRef = ref(null); const { getQueryVariable, setActiveTabIndex, getUserInfo } = useDataStore(); const dataStore = useDataStore(); const chatStore = useChatStore(); +const deepNineStore = useDeepNineStore(); // 变量 // 音频管理 const emotionAudioStore = useEmotionAudioStore(); @@ -588,21 +589,13 @@ const getCurrentScrollContainer = () => { }; const smoothScrollToBottom = async () => { - // console.log("调用滚动到底部的方法"); - // await nextTick(); const container = getCurrentScrollContainer(); - // console.log(container, 'container') - // console.log(isScrolling.value, 'isScrolling.value') if (!container) return; await nextTick(); // 确保在DOM更新后执行 if (!isScrolling.value) { container.scrollTop = container.scrollHeight - container.offsetHeight; - // container.scrollTop = container.scrollHeight; - // container.scrollTop = container.offsetHeight; - // container.scrollTop = container.scrollHeight + container.offsetHeight; - // console.log(container.scrollHeight, container.offsetHeight, container.scrollHeight - container.offsetHeight, container.scrollTop, "总长度", "可视长度", "位置") } }; @@ -811,7 +804,18 @@ watch( if (activeTab.value === "AIchat" || activeTab.value === "deepNine") { throttledSmoothScrollToBottom(); } - // setTimeout(throttledSmoothScrollToBottom, 100); + }, + { deep: false, immediate: true } +); + +watch( + () => deepNineStore.messages.length, + () => { + // console.log('messages变化了') + // 只有在AIchat页面时才执行自动滚动 + if (activeTab.value === "AIchat" || activeTab.value === "deepNine") { + throttledSmoothScrollToBottom(); + } }, { deep: false, immediate: true } ); @@ -876,8 +880,6 @@ watch( // 其他页面时停止AiEmotion页面的高度监听器 stopAiEmotionHeightObserver(); } - // AiEmotion页面不执行自动滚动,避免刷新后滚动到底部 - // setTimeout(throttledSmoothScrollToBottom, 100); }, { deep: true, immediate: true } );