From 4f10a305de0cd99d5f42fcfa01b4f8974f68f605 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Mon, 26 Feb 2024 11:00:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20safari=20=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=BB=9A=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/ai-chat/index.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index d9d0582cd..9544a112e 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -408,6 +408,10 @@ function chatMessage(chat?: any) { }) chatList.value.push(chat) inputValue.value = '' + nextTick(() => { + // 将滚动条滚动到最下面 + scrollDiv.value.setScrollTop(getMaxHeight()) + }) } // 对话 applicationApi @@ -421,7 +425,7 @@ function chatMessage(chat?: any) { } else { nextTick(() => { // 将滚动条滚动到最下面 - scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER) + scrollDiv.value.setScrollTop(getMaxHeight()) }) ChatManagement.addChatRecord(chat, 50, loading) ChatManagement.write(chat.id) @@ -472,11 +476,14 @@ const scrollTop = ref(0) const scorll = ref(true) +const getMaxHeight = () => { + return dialogScrollbar.value!.scrollHeight +} const handleScrollTop = ($event: any) => { scrollTop.value = $event.scrollTop if ( dialogScrollbar.value.scrollHeight - (scrollTop.value + scrollDiv.value.wrapRef.offsetHeight) <= - 20 + 30 ) { scorll.value = true } else { @@ -490,7 +497,7 @@ const handleScroll = () => { if (scrollDiv.value.wrapRef.offsetHeight < dialogScrollbar.value.scrollHeight) { // 如果当前滚动条距离最下面的距离在 规定距离 滚动条就跟随 if (scorll.value) { - scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER) + scrollDiv.value.setScrollTop(getMaxHeight()) } } }