改进 消息记录更新

This commit is contained in:
ivamp 2024-08-05 01:10:00 +08:00
parent 16c87b4ab1
commit 89da46022b

View File

@ -72,15 +72,19 @@ const chats = computed<ApiV1ChatsGet200Response>(() => {
}); });
chatStore.getChats(); chatStore.getChats();
let waitUpdate = false; let lastUpdate = null;
chatStore.$subscribe(() => { chatStore.$subscribe(() => {
if (waitUpdate) { if (lastUpdate === null) {
lastUpdate = new Date().getTime();
return; return;
} }
waitUpdate = true; if (lastUpdate !== null && new Date().getTime() - lastUpdate < 2 * 1000) {
return;
}
setTimeout(() => { setTimeout(() => {
chatStore.getChats(); chatStore.getChats();
waitUpdate = false; lastUpdate = new Date().getTime();
}, 1000); }, 1000);
}); });