diff --git a/src/views/AiEmotion.vue b/src/views/AiEmotion.vue index 8c25099..ce3f617 100644 --- a/src/views/AiEmotion.vue +++ b/src/views/AiEmotion.vue @@ -669,6 +669,8 @@ const hasTriggeredTypewriter = ref(false); // 是否已触发打字机效果 const intersectionObserver = ref(null); // 存储observer实例 const isUserInitiated = ref(false); // 标记是否为用户主动搜索 const shouldEnableAutoScroll = ref(false); // 标记是否应该启动自动滚动(仅在搜索新数据成功后为true) +const isUserScrolling = ref(false); // 标记用户是否正在手动滚动 +const userScrollTimer = ref(null); // 用户滚动检测定时器 // 打字机效果相关的变量已移除,现在直接使用parsedConclusion显示内容 @@ -2838,9 +2840,21 @@ function renderCharts(data) { // scrollToBottom函数已移除 -// 处理用户滚动事件(用于其他滚动相关功能) +// 处理用户滚动事件 const handleUserScroll = () => { - // 用户滚动事件处理逻辑已简化,因为自动滚动功能已移除 + // 标记用户正在滚动 + isUserScrolling.value = true; + + // 清除之前的定时器 + if (userScrollTimer.value) { + clearTimeout(userScrollTimer.value); + } + + // 设置定时器,2秒后恢复自动滚动 + userScrollTimer.value = setTimeout(() => { + isUserScrolling.value = false; + console.log("用户滚动检测:恢复自动滚动"); + }, 2000); }; // 处理滚轮事件 @@ -3012,7 +3026,8 @@ const debouncedScrollToBottom = (() => { clearTimeout(timeoutId); } timeoutId = setTimeout(() => { - if (isAutoScrollEnabled.value && isPageLoaded.value) { + // 只有在自动滚动启用、页面已加载且用户未手动滚动时才执行自动滚动 + if (isAutoScrollEnabled.value && isPageLoaded.value && !isUserScrolling.value) { scrollToBottom(); } }, 150); @@ -3301,6 +3316,12 @@ onUnmounted(() => { // 清理页面高度监听器 stopHeightObserver(); + // 清理用户滚动检测定时器 + if (userScrollTimer.value) { + clearTimeout(userScrollTimer.value); + userScrollTimer.value = null; + } + // 清理Intersection Observer if (intersectionObserver.value) { intersectionObserver.value.disconnect(); diff --git a/src/views/homePage.vue b/src/views/homePage.vue index 0541f95..3d47c48 100644 --- a/src/views/homePage.vue +++ b/src/views/homePage.vue @@ -494,10 +494,10 @@ const handleAiEmotionUserScroll = () => { } // 设置定时器,2秒后恢复自动滚动 - aiEmotionScrollTimer.value = setTimeout(() => { - isAiEmotionUserScrolling.value = false; - console.log("AiEmotion页面用户滚动检测:恢复自动滚动"); - }, 2000); + // aiEmotionScrollTimer.value = setTimeout(() => { + // isAiEmotionUserScrolling.value = false; + // console.log("AiEmotion页面用户滚动检测:恢复自动滚动"); + // }, 2000); }; // 处理AiEmotion页面的滚动请求