滚动条

main
wangyunfei 1 month ago
parent 2301da2538
commit eb53daf45a

@ -61,13 +61,13 @@ function ChatConversation() {
// 获取当前会话 // 获取当前会话
const currentConversation = conversations.find(conv => conv.id === currentConversationId) const currentConversation = conversations.find(conv => conv.id === currentConversationId)
const currentMessages = currentConversation?.messages || [] const currentMessages = currentConversation?.messages || []
// 自动滚动到底部 // 自动滚动到底部 - 禁用
const chatScrollRef = useRef(null); const chatScrollRef = useRef(null);
useEffect(() => { // useEffect(() => {
if (chatScrollRef.current) { // if (chatScrollRef.current) {
chatScrollRef.current.scrollTop = chatScrollRef.current.scrollHeight; // chatScrollRef.current.scrollTop = chatScrollRef.current.scrollHeight;
} // }
}, [currentMessages, loading]); // currentMessages 是你的消息数组 // }, [currentMessages, loading]); // currentMessages 是你的消息数组
const scrollToBottom = () => { const scrollToBottom = () => {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }) messagesEndRef.current?.scrollIntoView({ behavior: "smooth" })
@ -138,9 +138,9 @@ function ChatConversation() {
} }
}, []) }, [])
useEffect(() => { // useEffect(() => {
scrollToBottom() // scrollToBottom()
}, [currentMessages]) // }, [currentMessages])
// 创建新对话 // 创建新对话
const createNewConversation = () => { const createNewConversation = () => {

Loading…
Cancel
Save