feat: AI对话

This commit is contained in:
zhangyh
2025-10-28 11:33:20 +08:00
parent 2a1023aea0
commit 0ce0c41dac
12 changed files with 358 additions and 111 deletions

View File

@@ -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)