Skip to content

Commit

Permalink
调整监听问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sumingcheng committed Jan 4, 2025
1 parent 8537a88 commit b074708
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/views/home/components/ChatContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { markedRender } from '@/libs/highlight'
import type { ChatMessage } from '@/types'
import { Service, UserFilled } from '@element-plus/icons-vue'
import { ElIcon } from 'element-plus'
import { computed, ref, onMounted, onUnmounted } from 'vue'
import { computed, ref, onMounted, onUnmounted, watch, nextTick } from 'vue'
interface Props {
messages: ChatMessage[]
Expand Down Expand Up @@ -46,6 +46,13 @@ const getRenderedContent = computed(() => (content: string) => {
return markedRender(content)
})
// 监听消息变化,自动滚动到底部
watch(() => props.messages, () => {
nextTick(() => {
scrollToBottom()
})
}, { deep: true })
defineExpose({
chatListDom,
scrollToBottom
Expand Down

0 comments on commit b074708

Please sign in to comment.