From b39ce3dcc2ce2a5b8501ebe7ade3feb0349c8a08 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 29 Dec 2025 09:13:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=B6=88=E6=81=AF=E7=9A=84=E6=8C=81=E4=B9=85?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正 ChatMessage 类型使用 metadata.createdAt 而不是直接的 createdAt - 确保保存到数据库的消息格式正确,可以正确加载和显示 --- components/chat.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/chat.tsx b/components/chat.tsx index 07493b327..def781dce 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -492,12 +492,14 @@ export function Chat({ // 构造图片Markdown(使用与Gemini生成相同的格式) const imageMarkdown = `![thumb|||${result.original_url}|||2K](${result.thumbnail_url || result.original_url})`; - // 创建最终消息 + // 创建最终消息(前端显示用) const finalMessage: ChatMessage = { id: messageId, role: "assistant", parts: [{ type: "text", text: imageMarkdown }], - createdAt: new Date().toISOString(), + metadata: { + createdAt: new Date().toISOString(), + }, } as ChatMessage; // 更新消息 @@ -514,7 +516,13 @@ export function Chat({ }, body: JSON.stringify({ chatId: id, - message: finalMessage, + message: { + id: messageId, + role: "assistant", + parts: [{ type: "text", text: imageMarkdown }], + attachments: [], + createdAt: new Date().toISOString(), + }, }), }); } catch (saveError) {