From ebb17a49106ad4f23855dc5afe3ba8b2244f06b7 Mon Sep 17 00:00:00 2001 From: dongqian <3475123872@qq.com> Date: Thu, 30 Oct 2025 20:09:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/deepMate/deepMate.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pages/deepMate/deepMate.vue b/pages/deepMate/deepMate.vue index 3de84b6..f1e774f 100644 --- a/pages/deepMate/deepMate.vue +++ b/pages/deepMate/deepMate.vue @@ -816,7 +816,17 @@ const scrollToBottom = () => { }); }; const scrollToTop = () => { - chatScrollTop.value = 0; + // 聊天区存在:控制 scroll-view 回到顶部 + if (messages.value.length > 0) { + chatScrollTop.value = 0; + return; + } + // 未发起对话:页面级滚动回到顶部 + try { + uni.pageScrollTo({ scrollTop: 0, duration: 200 }); + } catch (e) { + // 兜底,无需处理 + } }; // 自动滚动控制:用户向上滚动时暂停自动滚到底部 const shouldAutoScroll = ref(true); @@ -830,6 +840,9 @@ const onChatScroll = (e) => { const delta = st - lastScrollTop.value; lastScrollTop.value = st; + // 同步当前滚动位置,确保点击回顶能产生数值变化 + chatScrollTop.value = st; + if (delta < 0) { shouldAutoScroll.value = false; return;