diff --git a/src/event/read.js b/src/event/read.js index 5c74b49..95029e4 100644 --- a/src/event/read.js +++ b/src/event/read.js @@ -32,7 +32,7 @@ class Read extends Base { handle() { if (this.type == 'total') { - console.error('====接收到了新版已读回执全量=====', this.resource) + const readList = this.resource.result if (readList.length > 0) { readList.forEach((item) => { diff --git a/src/store/modules/dialogue.js b/src/store/modules/dialogue.js index 022688a..9f2daab 100644 --- a/src/store/modules/dialogue.js +++ b/src/store/modules/dialogue.js @@ -195,7 +195,6 @@ export const useDialogueStore = defineStore('dialogue', { async addDialogueRecord(record) { // TOOD 需要通过 sequence 排序,保证消息一致性 // this.records.splice(index, 0, record) - console.log('addDialogueRecord',addDialogueRecord) this.records.push(record) // 同步到本地数据库 diff --git a/src/utils/db.js b/src/utils/db.js index 6ac699e..42db0ca 100644 --- a/src/utils/db.js +++ b/src/utils/db.js @@ -382,19 +382,22 @@ function generateUUID() { */ export async function addOrUpdateConversation(conversation) { try { + // 创建一个纯数据副本,移除所有不可序列化的内容 + const serializableConversation = JSON.parse(JSON.stringify(conversation)); + // 检查会话是否已存在 const existingConversation = await db.conversations .where('index_name') - .equals(conversation.index_name) + .equals(serializableConversation.index_name) .first(); if (existingConversation) { // 更新现有会话 - await db.conversations.update(existingConversation.id, conversation); + await db.conversations.update(existingConversation.id, serializableConversation); return existingConversation.id; } else { // 添加新会话 - const id = await db.conversations.add(conversation); + const id = await db.conversations.add(serializableConversation); return id; } } catch (error) {