|
|
@ -370,6 +370,8 @@ const aiEmotionHeightObserver = ref(null); |
|
|
|
const isAiEmotionAutoScrollEnabled = ref(false); |
|
|
|
const isAiEmotionUserScrolling = ref(false); // 用户是否正在手动滚动 |
|
|
|
const aiEmotionScrollTimer = ref(null); // 滚动检测定时器 |
|
|
|
const isChartInteracting = ref(false); // 图表是否正在交互 |
|
|
|
const chartInteractionTimer = ref(null); // 图表交互检测定时器 |
|
|
|
|
|
|
|
// 获取当前活动页面的滚动容器 |
|
|
|
const getCurrentScrollContainer = () => { |
|
|
@ -406,7 +408,7 @@ const throttledSmoothScrollToBottom = _.throttle(smoothScrollToBottom, 300, { |
|
|
|
|
|
|
|
// AiEmotion页面自动滚动到底部的防抖函数 |
|
|
|
const debouncedAiEmotionScrollToBottom = _.debounce(() => { |
|
|
|
if (activeTab.value === 'AiEmotion' && isAiEmotionAutoScrollEnabled.value && !isAiEmotionUserScrolling.value) { |
|
|
|
if (activeTab.value === 'AiEmotion' && isAiEmotionAutoScrollEnabled.value && !isAiEmotionUserScrolling.value && !isChartInteracting.value) { |
|
|
|
const container = tabContentAiEmotion.value; |
|
|
|
if (container) { |
|
|
|
container.scrollTop = container.scrollHeight - container.offsetHeight; |
|
|
@ -423,7 +425,7 @@ const startAiEmotionHeightObserver = () => { |
|
|
|
|
|
|
|
// 创建ResizeObserver监听页面内容变化 |
|
|
|
aiEmotionHeightObserver.value = new ResizeObserver((entries) => { |
|
|
|
if (isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion') { |
|
|
|
if (isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion' && !isChartInteracting.value) { |
|
|
|
debouncedAiEmotionScrollToBottom(); |
|
|
|
} |
|
|
|
}); |
|
|
@ -454,7 +456,7 @@ const startAiEmotionHeightObserver = () => { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (shouldScroll && isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion') { |
|
|
|
if (shouldScroll && isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion' && !isChartInteracting.value) { |
|
|
|
debouncedAiEmotionScrollToBottom(); |
|
|
|
} |
|
|
|
}); |
|
|
@ -500,6 +502,34 @@ const handleAiEmotionUserScroll = () => { |
|
|
|
// }, 2000); |
|
|
|
}; |
|
|
|
|
|
|
|
// 图表交互状态管理 |
|
|
|
const handleChartInteractionStart = () => { |
|
|
|
console.log("图表交互开始,临时禁用自动滚动"); |
|
|
|
isChartInteracting.value = true; |
|
|
|
|
|
|
|
// 清除之前的定时器 |
|
|
|
if (chartInteractionTimer.value) { |
|
|
|
clearTimeout(chartInteractionTimer.value); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const handleChartInteractionEnd = () => { |
|
|
|
// 清除之前的定时器 |
|
|
|
if (chartInteractionTimer.value) { |
|
|
|
clearTimeout(chartInteractionTimer.value); |
|
|
|
} |
|
|
|
|
|
|
|
// 设置定时器,1秒后恢复自动滚动 |
|
|
|
chartInteractionTimer.value = setTimeout(() => { |
|
|
|
isChartInteracting.value = false; |
|
|
|
console.log("图表交互结束,恢复自动滚动"); |
|
|
|
}, 1000); |
|
|
|
}; |
|
|
|
|
|
|
|
// 暴露图表交互管理函数给全局使用 |
|
|
|
window.handleChartInteractionStart = handleChartInteractionStart; |
|
|
|
window.handleChartInteractionEnd = handleChartInteractionEnd; |
|
|
|
|
|
|
|
// 处理AiEmotion页面的滚动请求 |
|
|
|
const handleAiEmotionScrollToBottom = () => { |
|
|
|
if (activeTab.value === 'AiEmotion') { |
|
|
@ -1001,6 +1031,17 @@ onUnmounted(() => { |
|
|
|
} |
|
|
|
// 清理AiEmotion页面的高度监听器 |
|
|
|
stopAiEmotionHeightObserver(); |
|
|
|
|
|
|
|
// 清理图表交互相关的定时器和全局函数 |
|
|
|
if (chartInteractionTimer.value) { |
|
|
|
clearTimeout(chartInteractionTimer.value); |
|
|
|
} |
|
|
|
if (window.handleChartInteractionStart) { |
|
|
|
delete window.handleChartInteractionStart; |
|
|
|
} |
|
|
|
if (window.handleChartInteractionEnd) { |
|
|
|
delete window.handleChartInteractionEnd; |
|
|
|
} |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|
|
|
|