fix: 修复图片处理消息的持久保存格式
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

- 修正 ChatMessage 类型使用 metadata.createdAt 而不是直接的 createdAt
- 确保保存到数据库的消息格式正确,可以正确加载和显示
This commit is contained in:
Your Name 2025-12-29 09:13:29 +08:00
parent 1c7bd9e2d0
commit b39ce3dcc2

View File

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