diff --git a/src/views/chat/hooks/useScroll.ts b/src/views/chat/hooks/useScroll.ts index e5e4b35..16987ad 100644 --- a/src/views/chat/hooks/useScroll.ts +++ b/src/views/chat/hooks/useScroll.ts @@ -28,7 +28,7 @@ export function useScroll(): ScrollReturn { const scrollToBottomIfAtBottom = async () => { await nextTick() if (scrollRef.value) { - const threshold = 50 // 阈值,表示滚动条到底部的距离阈值 + const threshold = 100 // 阈值,表示滚动条到底部的距离阈值 const distanceToBottom = scrollRef.value.scrollHeight - scrollRef.value.scrollTop - scrollRef.value.clientHeight if (distanceToBottom <= threshold) scrollRef.value.scrollTop = scrollRef.value.scrollHeight diff --git a/src/views/chat/index.vue b/src/views/chat/index.vue index 82f3235..9ed9fdd 100644 --- a/src/views/chat/index.vue +++ b/src/views/chat/index.vue @@ -30,7 +30,7 @@ useCopyCode() const { isMobile } = useBasicLayout() const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat() -const { scrollRef, scrollToBottom } = useScroll() +const { scrollRef, scrollToBottom, scrollToBottomIfAtBottom } = useScroll() const { usingContext, toggleUsingContext } = useUsingContext() const { uuid } = route.params as { uuid: string } @@ -142,7 +142,7 @@ async function onConversation() { return fetchChatAPIOnce() } - scrollToBottom() + scrollToBottomIfAtBottom() } catch (error) { // @@ -164,7 +164,7 @@ async function onConversation() { loading: false, }, ) - scrollToBottom() + scrollToBottomIfAtBottom() return } @@ -196,7 +196,7 @@ async function onConversation() { requestOptions: { prompt: message, options: { ...options } }, }, ) - scrollToBottom() + scrollToBottomIfAtBottom() } finally { loading.value = false