diff --git a/src/utils/db.js b/src/utils/db.js index 42db0ca..38f932c 100644 --- a/src/utils/db.js +++ b/src/utils/db.js @@ -1,28 +1,21 @@ -// src/db.js + import Dexie from 'dexie'; -// 创建数据库实例 export const db = new Dexie('chatHistory'); // 定义数据库结构 db.version(2).stores({ - // 表名: 索引字段列表 - // ++id 表示自增主键 - // name, age 表示这些字段将被索引 -// friends: '++id, name, age', - + // 聊天记录表 - // 为常用查询字段创建索引 + messages: 'msg_id, sequence, talk_type, msg_type, user_id, receiver_id, is_read, created_at', // 会话表(包含私聊和群聊) - // 为常用查询字段创建索引 conversations: 'id, talk_type, receiver_id, index_name, updated_at, unread_num' }); -// 数据库升级处理 db.on('ready', function() { - // 检查是否需要从服务器同步数据 + console.log('数据库已就绪,版本:', db.verno); });