fix: 修复图片处理消息的持久保存格式
- 修正 ChatMessage 类型使用 metadata.createdAt 而不是直接的 createdAt - 确保保存到数据库的消息格式正确,可以正确加载和显示
This commit is contained in:
parent
1c7bd9e2d0
commit
b39ce3dcc2
@ -492,12 +492,14 @@ export function Chat({
|
|||||||
// 构造图片Markdown(使用与Gemini生成相同的格式)
|
// 构造图片Markdown(使用与Gemini生成相同的格式)
|
||||||
const imageMarkdown = ``;
|
const imageMarkdown = ``;
|
||||||
|
|
||||||
// 创建最终消息
|
// 创建最终消息(前端显示用)
|
||||||
const finalMessage: ChatMessage = {
|
const finalMessage: ChatMessage = {
|
||||||
id: messageId,
|
id: messageId,
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
parts: [{ type: "text", text: imageMarkdown }],
|
parts: [{ type: "text", text: imageMarkdown }],
|
||||||
createdAt: new Date().toISOString(),
|
metadata: {
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
},
|
||||||
} as ChatMessage;
|
} as ChatMessage;
|
||||||
|
|
||||||
// 更新消息
|
// 更新消息
|
||||||
@ -514,7 +516,13 @@ export function Chat({
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
chatId: id,
|
chatId: id,
|
||||||
message: finalMessage,
|
message: {
|
||||||
|
id: messageId,
|
||||||
|
role: "assistant",
|
||||||
|
parts: [{ type: "text", text: imageMarkdown }],
|
||||||
|
attachments: [],
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
} catch (saveError) {
|
} catch (saveError) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user