mirror of
https://github.com/Chanzhaoyu/chatgpt-web.git
synced 2025-07-19 10:59:24 +00:00
perf: scrollToBottom 改成 scrollToBottomIfAtBottom (#771)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user