Skip to content

Commit 8eb9e50

Browse files
shunyue1320pzcn
authored andcommitted
perf: scrollToBottom 改成 scrollToBottomIfAtBottom (Chanzhaoyu#771)
1 parent ab9e4b7 commit 8eb9e50

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/views/chat/hooks/useScroll.ts

+1-1
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

+4-4
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 }
@@ -147,7 +147,7 @@ async function onConversation() {
147147
return fetchChatAPIOnce()
148148
}
149149
150-
scrollToBottom()
150+
scrollToBottomIfAtBottom()
151151
}
152152
catch (error) {
153153
//
@@ -169,7 +169,7 @@ async function onConversation() {
169169
loading: false,
170170
},
171171
)
172-
scrollToBottom()
172+
scrollToBottomIfAtBottom()
173173
return
174174
}
175175
@@ -201,7 +201,7 @@ async function onConversation() {
201201
requestOptions: { prompt: message, options: { ...options } },
202202
},
203203
)
204-
scrollToBottom()
204+
scrollToBottomIfAtBottom()
205205
}
206206
finally {
207207
loading.value = false

0 commit comments

Comments
 (0)