From 123bf8051f393aae7423d663c02428f1a161b240 Mon Sep 17 00:00:00 2001 From: Phoenix <64720302+Concur-max@users.noreply.github.com> Date: Mon, 30 Jun 2025 16:15:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=A5=E5=BF=97=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=BA=8F=E5=88=97=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除事件处理和对话记录中的调试日志语句 - 在数据库操作中添加会话对象的序列化处理,避免不可序列化内容 --- src/event/read.js | 2 +- src/store/modules/dialogue.js | 1 - src/utils/db.js | 9 ++++++--- 3 files changed, 7 insertions(+), 5 deletions(-) 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) {