8000 chore: scrollToBottom 改成 scrollToBottomIfAtBottom by shunyue1320 · Pull Request #771 · Chanzhaoyu/chatgpt-web · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

chore: scrollToBottom 改成 scrollToBottomIfAtBottom #771

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/views/chat/hooks/useScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/views/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -142,7 +142,7 @@ async function onConversation() {
return fetchChatAPIOnce()
}

scrollToBottom()
scrollToBottomIfAtBottom()
}
catch (error) {
//
Expand All @@ -164,7 +164,7 @@ async function onConversation() {
loading: false,
},
)
scrollToBottom()
scrollToBottomIfAtBottom()
return
}

Expand Down Expand Up @@ -196,7 +196,7 @@ async function onConversation() {
requestOptions: { prompt: message, options: { ...options } },
},
)
scrollToBottom()
scrollToBottomIfAtBottom()
}
finally {
loading.value = false
Expand Down
0