Compare commits
3 Commits
2a36fa2b60
...
9b53540f91
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b53540f91 | |||
| 2223636184 | |||
| 6144dc72b8 |
@@ -10,8 +10,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 消息列表 -->
|
<!-- 消息列表 -->
|
||||||
<view v-for="(message, index) in messages" :key="`msg-${message.id || message.timestamp}-${index}`"
|
<view v-for="item in messagesWithKey" :key="item.__renderKey" class="message-item" :class="[item.role, { 'first-message': item.__index === 0 }]">
|
||||||
class="message-item" :class="[message.role, { 'first-message': index === 0 }]">
|
|
||||||
|
|
||||||
<!-- 用户消息 -->
|
<!-- 用户消息 -->
|
||||||
<view v-if="message.role === 'user'" class="user-message">
|
<view v-if="message.role === 'user'" class="user-message">
|
||||||
@@ -392,6 +391,19 @@ export default {
|
|||||||
isFetchingHistory: false
|
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() {
|
onShow() {
|
||||||
// 优先读取本地缓存的会话 ID
|
// 优先读取本地缓存的会话 ID
|
||||||
const localConvId = this.getConversationIdFromLocal();
|
const localConvId = this.getConversationIdFromLocal();
|
||||||
|
|||||||
Reference in New Issue
Block a user