diff --git a/src/chat.js b/src/chat.js index 8d6b9d5..023e4b7 100644 --- a/src/chat.js +++ b/src/chat.js @@ -143,6 +143,7 @@ export default class Chat { }) } async 筛选指定范围的消息({ start, end }) { + console.log('筛选指定范围的消息', start, end) const data = await values(this.store) return data.map(item => ({ timestamp: new Date(item.time).getTime(), ...item })).filter(item => { const timestamp = new Date(item.time).getTime() diff --git a/src/main.js b/src/main.js index 6e5ee00..a4bb376 100644 --- a/src/main.js +++ b/src/main.js @@ -183,6 +183,14 @@ clientList.setChannel('chat', { } if (data.type === 'list') { console.log(client.name, '发来消息列表:', data) + const last = localStorage.getItem('store-chat-default') + const lastTimestamp = new Date(last).getTime() + data.list.map(item => ({ timestamp: new Date(item.time).getTime(), ...item })).filter(item => { + const timestamp = new Date(item.time).getTime() + return timestamp >= lastTimestamp + }).forEach(item => { + console.log('消息不符合要求的时间区间', item) + }) chat.合并消息列表(data.list) return }