feat: AI对话
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
<template>
|
||||
<div class="chat-list" ref="chatListRef">
|
||||
<div class="chat-message-item" v-for="message in list" :key="message.id">
|
||||
<NoticeItem :value="message" />
|
||||
<NoticeItem
|
||||
:value="message"
|
||||
:is-streaming="isStreaming && streamingMessage?.id === message.id"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -21,6 +24,8 @@ interface ChatMessage {
|
||||
}
|
||||
const props = defineProps<{
|
||||
list: ChatMessage[]
|
||||
isStreaming?: boolean
|
||||
streamingMessage?: ChatMessage | null
|
||||
}>()
|
||||
|
||||
const emits = defineEmits(['send-message'])
|
||||
@@ -47,6 +52,17 @@ watch(
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
// 监听流式消息内容变化,实时滚动
|
||||
watch(
|
||||
() => props.streamingMessage?.content,
|
||||
async () => {
|
||||
if (props.isStreaming) {
|
||||
await nextTick()
|
||||
scrollToBottom()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const handleSendMessage = (message: string): void => {
|
||||
console.log('list发送消息:', message)
|
||||
emits('send-message', message)
|
||||
|
||||
Reference in New Issue
Block a user