Skip to content

Commit cce557a

Browse files
committed
fix: ensure scroll position updates correctly after DOM changes in chat list
1 parent 2bcfdb4 commit cce557a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ui/src/components/ai-chat/index.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,8 @@ const handleScroll = () => {
645645
if (props.type !== 'log' && scrollDiv.value) {
646646
// 内部高度小于外部高度 就需要出滚动条
647647
if (scrollDiv.value.wrapRef.offsetHeight < dialogScrollbar.value.scrollHeight) {
648-
// 如果当前滚动条距离最下面的距离在 规定距离 滚动条就跟随
649-
if (scorll.value) {
650-
scrollDiv.value.setScrollTop(getMaxHeight())
651-
}
648+
// 滚动到底部
649+
scrollDiv.value.setScrollTop(dialogScrollbar.value.scrollHeight);
652650
}
653651
}
654652
}
@@ -759,9 +757,11 @@ function setScrollBottom() {
759757
watch(
760758
chatList,
761759
() => {
762-
handleScroll()
760+
nextTick(() => {
761+
handleScroll(); // 确保 DOM 更新后再滚动
762+
});
763763
},
764-
{ deep: true, immediate: true },
764+
{deep: true, immediate: true},
765765
)
766766
767767
defineExpose({

0 commit comments

Comments
 (0)