perf: scrollToBottom 改成 scrollToBottomIfAtBottom (#771)

main
舜岳 2 years ago committed by GitHub
parent b1d0056429
commit 31a84325d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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

Loading…
Cancel
Save