diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index edcf3a8..4978f1b 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -10,8 +10,7 @@ - + @@ -392,6 +391,19 @@ export default { isFetchingHistory: false } }, + computed: { + // 为每条消息生成兼容小程序的唯一 key + messagesWithKey() { + return this.messages.map((msg, idx) => { + const uniqueId = msg.id || msg.timestamp || idx; + return { + ...msg, + __renderKey: `msg_${uniqueId}_${idx}`, + __index: idx // 保留原始索引,用于判断 first-message 等 + }; + }); + } + }, onShow() { // 优先读取本地缓存的会话 ID const localConvId = this.getConversationIdFromLocal();