|
|
@ -889,7 +889,17 @@ const scrollToBottom = () => { |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
const scrollToTop = () => { |
|
|
const scrollToTop = () => { |
|
|
|
|
|
// 聊天区存在:控制 scroll-view 回到顶部 |
|
|
|
|
|
if (messages.value.length > 0) { |
|
|
chatScrollTop.value = 0; |
|
|
chatScrollTop.value = 0; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// 未发起对话:页面级滚动回到顶部 |
|
|
|
|
|
try { |
|
|
|
|
|
uni.pageScrollTo({ scrollTop: 0, duration: 200 }); |
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
// 兜底,无需处理 |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
// 自动滚动控制:用户向上滚动时暂停自动滚到底部 |
|
|
// 自动滚动控制:用户向上滚动时暂停自动滚到底部 |
|
|
const shouldAutoScroll = ref(true); |
|
|
const shouldAutoScroll = ref(true); |
|
|
@ -903,6 +913,9 @@ const onChatScroll = (e) => { |
|
|
const delta = st - lastScrollTop.value; |
|
|
const delta = st - lastScrollTop.value; |
|
|
lastScrollTop.value = st; |
|
|
lastScrollTop.value = st; |
|
|
|
|
|
|
|
|
|
|
|
// 同步当前滚动位置,确保点击回顶能产生数值变化 |
|
|
|
|
|
chatScrollTop.value = st; |
|
|
|
|
|
|
|
|
if (delta < 0) { |
|
|
if (delta < 0) { |
|
|
shouldAutoScroll.value = false; |
|
|
shouldAutoScroll.value = false; |
|
|
return; |
|
|
return; |
|
|
|