From 1072541927bd57ab96e242d30515362db34ccafe Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 21 Jun 2026 08:51:21 -0700 Subject: [PATCH] =?UTF-8?q?fix(ai):=20=E4=BC=9A=E8=AF=9D=20createTime=20?= =?UTF-8?q?=E6=8C=89=E5=A5=91=E7=BA=A6=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ChatConversationVO.createTime 改为必填字段 - 排序和分组时间计算去掉 Number(... || 0) 兜底 - 避免用 0 掩盖异常响应数据 ts:check 保持 0 --- src/api/ai/chat/conversation/index.ts | 2 +- .../chat/index/components/conversation/ConversationList.vue | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/ai/chat/conversation/index.ts b/src/api/ai/chat/conversation/index.ts index 14be6c77f..15a0db322 100644 --- a/src/api/ai/chat/conversation/index.ts +++ b/src/api/ai/chat/conversation/index.ts @@ -12,7 +12,7 @@ export interface ChatConversationVO { temperature: number // 温度参数 maxTokens: number // 单条回复的最大 Token 数量 maxContexts: number // 上下文的最大 Message 数量 - createTime?: Date // 创建时间 + createTime: Date // 创建时间 // 额外字段 systemMessage?: string // 角色设定 modelName?: string // 模型名字 diff --git a/src/views/ai/chat/index/components/conversation/ConversationList.vue b/src/views/ai/chat/index/components/conversation/ConversationList.vue index 6fa1478a9..f0ab09880 100644 --- a/src/views/ai/chat/index/components/conversation/ConversationList.vue +++ b/src/views/ai/chat/index/components/conversation/ConversationList.vue @@ -205,7 +205,7 @@ const getChatConversationList = async () => { conversationList.value = await ChatConversationApi.getChatConversationMyList() // 1.2 排序 conversationList.value.sort((a, b) => { - return Number(b.createTime || 0) - Number(a.createTime || 0) + return Number(b.createTime) - Number(a.createTime) }) // 1.3 没有任何对话情况 if (conversationList.value.length === 0) { @@ -252,7 +252,7 @@ const getConversationGroupByCreateTime = async (list: ChatConversationVO[]) => { continue } // 计算时间差(单位:毫秒) - const diff = now - Number(conversation.createTime || 0) + const diff = now - Number(conversation.createTime) // 根据时间间隔判断 if (diff < oneDay) { groupMap['今天'].push(conversation)