diff --git a/src/views/ai/chat/index/components/message/MessageList.vue b/src/views/ai/chat/index/components/message/MessageList.vue index fce6529..ac764e6 100644 --- a/src/views/ai/chat/index/components/message/MessageList.vue +++ b/src/views/ai/chat/index/components/message/MessageList.vue @@ -85,13 +85,22 @@ const emits = defineEmits(['onDeleteSuccess', 'onRefresh', 'onEdit','update:list /** 滚动到底部 */ const scrollToBottom = async (isIgnore?: boolean) => { // 注意要使用 nextTick 以免获取不到 dom - await nextTick() - if (isIgnore || !isScrolling.value) { - messageContainer.value.scrollTop = - messageContainer.value.scrollHeight - messageContainer.value.offsetHeight - } + await nextTick(); + setTimeout(() => { + if (isIgnore || !isScrolling.value) { + const container = messageContainer.value; + if (container) { + container.scrollTop = container.scrollHeight - container.offsetHeight; + console.log('ScrollTop:', container.scrollTop); + } + } + }, 200); } +watch(list, () => { + nextTick(); + scrollToBottom(); +}, { deep: true }); function handleScroll() { const scrollContainer = messageContainer.value const scrollTop = scrollContainer.scrollTop