diff --git a/src/chat.js b/src/chat.js index 3c160d9..0aaf93d 100644 --- a/src/chat.js +++ b/src/chat.js @@ -208,8 +208,11 @@ export default class Chat { ] })) } - 存储消息(data) { - set(data.id, data, this.store) + async 存储消息(data) { + // 检查id是否已经存在 + const item = await get(data.id, this.store) + if (item) return; + await set(data.id, data, this.store) } 发送消息(text) { const name = '我' diff --git a/src/main.js b/src/main.js index ad89dbb..4e39f6e 100644 --- a/src/main.js +++ b/src/main.js @@ -175,7 +175,7 @@ clientList.setChannel('chat', { } if (data.type === 'list') { console.log(client.name, `同步来 ${data.list.length} 条消息`) - chat.合并消息列表(data.list) + await chat.合并消息列表(data.list) return } console.log('未知类型:', data.type)