From 431ae7b01b8c27a9616335cd6fccb7e282633d43 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Wed, 22 May 2024 10:30:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=A7=A3=E5=86=B3todo=E3=80=91AI=20Ch?= =?UTF-8?q?at=20=E8=BD=AC=E6=8D=A2=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E3=80=81role=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/chat/message/index.ts | 2 ++ src/views/ai/chat/Message.vue | 8 ++------ src/views/ai/chat/index.vue | 12 +++++++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/api/ai/chat/message/index.ts b/src/api/ai/chat/message/index.ts index d3564164..802061af 100644 --- a/src/api/ai/chat/message/index.ts +++ b/src/api/ai/chat/message/index.ts @@ -15,6 +15,8 @@ export interface ChatMessageVO { content: string // 聊天内容 tokens: number // 消耗 Token 数量 createTime: Date // 创建时间 + roleAvatar: string // 角色头像 + userAvatar: string // 创建时间 } export interface ChatMessageSendVO { diff --git a/src/views/ai/chat/Message.vue b/src/views/ai/chat/Message.vue index 279681f0..1a33b4bd 100644 --- a/src/views/ai/chat/Message.vue +++ b/src/views/ai/chat/Message.vue @@ -5,9 +5,7 @@
- +
@@ -29,9 +27,7 @@
- +
diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue index c07afa27..0de50b0a 100644 --- a/src/views/ai/chat/index.vue +++ b/src/views/ai/chat/index.vue @@ -93,6 +93,7 @@ import ChatEmpty from './ChatEmpty.vue' import MessageLoading from './MessageLoading.vue' import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message' import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation' +import { getUserProfile, ProfileVO } from '@/api/system/user/profile' import {useClipboard} from '@vueuse/core' import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue"; import {Download, Top} from "@element-plus/icons-vue"; @@ -385,7 +386,14 @@ const getMessageList = async () => { return } // 获取列表数据 - list.value = await ChatMessageApi.messageList(activeConversationId.value) + const messageListRes = await ChatMessageApi.messageList(activeConversationId.value) + // 设置用户头像 + const user = await getUserProfile() + messageListRes.map(item => { + item.userAvatar = user?.avatar + }) + list.value = messageListRes + console.log("设置头像成功", messageListRes) // 滚动到最下面 await nextTick(() => { // 滚动到最后 @@ -505,8 +513,6 @@ const handlerMessageClear = async () => { await getMessageList() } - - /** 初始化 **/ onMounted(async () => { // 设置当前对话 TODO 角色仓库过来的,自带 conversationId 需要选中