Skip to content

Commit 31a8432

Browse files
authored
perf: scrollToBottom 改成 scrollToBottomIfAtBottom (#771)
1 parent b1d0056 commit 31a8432

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/views/chat/hooks/useScroll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function useScroll(): ScrollReturn {
2828
const scrollToBottomIfAtBottom = async () => {
2929
await nextTick()
3030
if (scrollRef.value) {
31-
const threshold = 50 // 阈值,表示滚动条到底部的距离阈值
31+
const threshold = 100 // 阈值,表示滚动条到底部的距离阈值
3232
const distanceToBottom = scrollRef.value.scrollHeight - scrollRef.value.scrollTop - scrollRef.value.clientHeight
3333
if (distanceToBottom <= threshold)
3434
scrollRef.value.scrollTop = scrollRef.value.scrollHeight

src/views/chat/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ useCopyCode()
3030
3131
const { isMobile } = useBasicLayout()
3232
const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat()
33-
const { scrollRef, scrollToBottom } = useScroll()
33+
const { scrollRef, scrollToBottom, scrollToBottomIfAtBottom } = useScroll()
3434
const { usingContext, toggleUsingContext } = useUsingContext()
3535
3636
const { uuid } = route.params as { uuid: string }
@@ -142,7 +142,7 @@ async function onConversation() {
142142
return fetchChatAPIOnce()
143143
}
144144
145-
scrollToBottom()
145+
scrollToBottomIfAtBottom()
146146
}
147147
catch (error) {
148148
//
@@ -164,7 +164,7 @@ async function onConversation() {
164164
loading: false,
165165
},
166166
)
167-
scrollToBottom()
167+
scrollToBottomIfAtBottom()
168168
return
169169
}
170170
@@ -196,7 +196,7 @@ async function onConversation() {
196196
requestOptions: { prompt: message, options: { ...options } },
197197
},
198198
)
199-
scrollToBottom()
199+
scrollToBottomIfAtBottom()
200200
}
201201
finally {
202202
loading.value = false

0 commit comments

Comments
 (0)