diff --git a/pages/chat/ChatMainList.vue b/pages/chat/ChatMainList.vue index 4c91141..0e49d0c 100644 --- a/pages/chat/ChatMainList.vue +++ b/pages/chat/ChatMainList.vue @@ -20,6 +20,8 @@ scroll-y :scroll-with-animation="true" class="area-msg-list" + @scroll="handleScroll" + @scrolltolower="handleScrollToLower" > { holdKeyboard.value = false; }; +// 处理用户滚动事件 +const handleScroll = (e) => { + // 标记用户正在滚动 +}; + +// 处理滚动到底部事件 +const handleScrollToLower = () => {}; + // 滚动到底部 - 优化版本,确保打字机效果始终可见 const scrollToBottom = () => { nextTick(() => { scrollTop.value = 99999; // 强制触发滚动更新 setTimeout(() => { - scrollTop.value = scrollTop.value + 1; + scrollTop.value = scrollTop.value + Math.random(); }, 10); }); }; @@ -526,14 +539,8 @@ const initTypewriterManager = () => { typewriterManager.setCallbacks({ // 每个字符打字时的回调 onCharacterTyped: (displayedContent) => { - // 立即滚动到底部,确保打字过程中始终可见 - nextTick(() => { - scrollTop.value = 99999; - // 双重保险,确保滚动生效 - setTimeout(() => { - scrollTop.value = 99999 + Math.random(); - }, 20); - }); + // 只有在用户没有滚动时才自动滚动到底部 + scrollToBottom(); }, // 内容更新时的回调 onContentUpdate: (content) => {