diff --git a/src/assets/ai/gpt.svg b/src/assets/ai/gpt.svg
new file mode 100644
index 00000000..603e2e95
--- /dev/null
+++ b/src/assets/ai/gpt.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue
index 0de50b0a..2f16a23f 100644
--- a/src/views/ai/chat/index.vue
+++ b/src/views/ai/chat/index.vue
@@ -109,6 +109,7 @@ const conversationInProgress = ref(false) // 对话进行中
const conversationInAbortController = ref() // 对话进行中 abort 控制器(控制 stream 对话)
const inputTimeout = ref() // 处理输入中回车的定时器
const prompt = ref() // prompt
+const userInfo = ref() // 用户信息
const fullText = ref('');
const displayedText = ref('');
@@ -124,6 +125,9 @@ const listLoadingTime = ref() // time定时器,如果加载速度很快
const messageRef = ref()
const isComposing = ref(false) // 判断用户是否在输入
+// 默认 role 头像
+const defaultRoleAvatar = 'http://test.yudao.iocoder.cn/eaef5f41acb911dd718429a0702dcc3c61160d16e57ba1d543132fab58934f9f.png'
+
// =========== 自提滚动效果
const textRoll = async () => {
@@ -300,6 +304,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
conversationId: activeConversationId.value,
type: 'user',
content: userMessage.content,
+ userAvatar: userInfo.value?.avatar,
createTime: new Date()
} as ChatMessageVO)
list.value.push({
@@ -307,6 +312,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
conversationId: activeConversationId.value,
type: 'system',
content: '思考中...',
+ roleAvatar: defaultRoleAvatar,
createTime: new Date()
} as ChatMessageVO)
// 滚动到最下面
@@ -388,12 +394,11 @@ const getMessageList = async () => {
// 获取列表数据
const messageListRes = await ChatMessageApi.messageList(activeConversationId.value)
// 设置用户头像
- const user = await getUserProfile()
messageListRes.map(item => {
- item.userAvatar = user?.avatar
+ // 设置 role 默认头像
+ item.roleAvatar = item.roleAvatar ? item.roleAvatar : defaultRoleAvatar
})
list.value = messageListRes
- console.log("设置头像成功", messageListRes)
// 滚动到最下面
await nextTick(() => {
// 滚动到最后
@@ -524,6 +529,8 @@ onMounted(async () => {
// 获取列表数据
listLoading.value = true
await getMessageList()
+ // 获取用户信息
+ userInfo.value = await getUserProfile()
})