refactor: 移除调试日志并优化会话序列化逻辑

- 删除事件处理和对话记录中的调试日志语句
- 在数据库操作中添加会话对象的序列化处理,避免不可序列化内容
This commit is contained in:
Phoenix 2025-06-30 16:15:44 +08:00
parent 4863b4c77c
commit 123bf8051f
3 changed files with 7 additions and 5 deletions

View File

@ -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) => {

View File

@ -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)
// 同步到本地数据库

View File

@ -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) {