From 7b4bdbc1e0d8e9e67aa2ae297ce3d203c711c97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=9D=B0?= Date: Sun, 13 Jul 2025 11:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=83=85=E7=BB=AA=E5=A4=A7?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E8=87=AA=E5=8A=A8=E6=BB=9A=E5=8A=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E5=8F=AA=E5=9C=A8=E5=A4=BA=E5=AE=9D=E5=A5=87?= =?UTF-8?q?=E5=85=B5=E5=A4=A7=E6=A8=A1=E5=9E=8B=E8=87=AA=E5=8A=A8=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/AiEmotion.vue | 63 +++++++------------------------------------------ src/views/homePage.vue | 6 ++++- 2 files changed, 14 insertions(+), 55 deletions(-) diff --git a/src/views/AiEmotion.vue b/src/views/AiEmotion.vue index 02276f2..2f364e8 100644 --- a/src/views/AiEmotion.vue +++ b/src/views/AiEmotion.vue @@ -258,8 +258,6 @@ const hasTriggeredAudio = ref(false); // 是否已触发音频播放 const hasTriggeredTypewriter = ref(false); // 是否已触发打字机效果 const intersectionObserver = ref(null); // 存储observer实例 const isUserInitiated = ref(false); // 标记是否为用户主动搜索 -const isUserScrolling = ref(false); // 标记用户是否正在手动滚动 -const scrollTimeout = ref(null); // 滚动超时定时器 // 显示的文本内容(用于打字机效果) const displayedTexts = ref({ @@ -846,10 +844,7 @@ function playAudio(url) { isAudioPlaying.value = true; emotionAudioStore.isPlaying = true; console.log('开始播放场景应用语音'); - // 音频开始播放时,滚动到底部 - // setTimeout(() => { - // scrollToBottom(); - // }, 100); + // 音频开始播放时的自动滚动已移除 }, onend: () => { isAudioPlaying.value = false; @@ -1518,36 +1513,11 @@ function renderCharts(data) { }); } -// const scrollToBottom = async () => { -// // 如果用户正在手动滚动,则不执行自动滚动 -// if (isUserScrolling.value) { -// console.log('用户正在手动滚动,跳过自动滚动'); -// return; -// } +// scrollToBottom函数已移除 -// const container = userInputDisplayRef.value; -// if (!container) return; -// await nextTick(); -// console.log(container.scrollHeight, "container.scrollHeight"); -// console.log(container.scrollTop, "container.scrollTop"); -// console.log(container.offsetHeight, "container.offsetHeight"); -// container.scrollTop = container.scrollHeight - container.offsetHeight; -// }; - -// 处理用户滚动事件 +// 处理用户滚动事件(用于其他滚动相关功能) const handleUserScroll = () => { - isUserScrolling.value = true; - - // 清除之前的定时器 - if (scrollTimeout.value) { - clearTimeout(scrollTimeout.value); - } - - // 设置定时器,2秒后重新允许自动滚动 - scrollTimeout.value = setTimeout(() => { - isUserScrolling.value = false; - console.log('用户滚动结束,重新允许自动滚动'); - }, 2000); + // 用户滚动事件处理逻辑已简化,因为自动滚动功能已移除 }; // 处理滚轮事件 @@ -1589,16 +1559,11 @@ function isDataLoaded() { return false; } - console.log('所有数据和组件已加载完成,可以开始滚动'); + console.log('所有数据和组件已加载完成'); return true; } -// 自动滚动函数(已禁用) -function startAutoScroll() { - // 自动滚动功能已被禁用 - console.log('自动滚动功能已被禁用'); - return; -} +// 自动滚动函数已移除 // 设置Intersection Observer监听场景应用部分 function setupIntersectionObserver() { @@ -1690,12 +1655,7 @@ function setupIntersectionObserver() { intersectionObserver.value = observer; } -// 手动触发自动滚动(已禁用) -function triggerAutoScroll() { - // 自动滚动功能已被禁用 - console.log('自动滚动功能已被禁用'); - return; -} +// 手动触发自动滚动函数已移除 // 返回顶部功能 const scrollToTop = () => { @@ -1911,11 +1871,7 @@ onUnmounted(() => { window.removeEventListener('scroll', handlePageScroll); document.removeEventListener('scroll', handlePageScroll); - // 清理滚动定时器 - if (scrollTimeout.value) { - clearTimeout(scrollTimeout.value); - scrollTimeout.value = null; - } + // 滚动相关清理已简化 }); // 声明组件可以触发的事件 @@ -1923,8 +1879,7 @@ const emit = defineEmits(['updateMessage', 'sendMessage', 'ensureAIchat']); // 导出方法供外部使用 defineExpose({ - handleSendMessage, - triggerAutoScroll + handleSendMessage }); diff --git a/src/views/homePage.vue b/src/views/homePage.vue index 1d64fc1..aa5f138 100644 --- a/src/views/homePage.vue +++ b/src/views/homePage.vue @@ -287,7 +287,10 @@ watch( () => chatStore.messages, () => { // console.log('messages变化了') - throttledSmoothScrollToBottom(); + // 只有在AIchat页面时才执行自动滚动 + if (activeTab.value === "AIchat") { + throttledSmoothScrollToBottom(); + } // setTimeout(throttledSmoothScrollToBottom, 100); }, { deep: true, immediate: true } @@ -303,6 +306,7 @@ watch( throttledSmoothScrollToBottom(); }, 100); } + // AiEmotion页面不执行自动滚动,避免刷新后滚动到底部 // setTimeout(throttledSmoothScrollToBottom, 100); }, { deep: true, immediate: true }