From 89da46022b8d427db745563ca886edbe8e3ab5c3 Mon Sep 17 00:00:00 2001 From: ivamp Date: Mon, 5 Aug 2024 01:10:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/AppBar.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/AppBar.vue b/src/components/AppBar.vue index 5f7f66e..0b6117f 100644 --- a/src/components/AppBar.vue +++ b/src/components/AppBar.vue @@ -72,15 +72,19 @@ const chats = computed(() => { }); chatStore.getChats(); -let waitUpdate = false; +let lastUpdate = null; chatStore.$subscribe(() => { - if (waitUpdate) { + if (lastUpdate === null) { + lastUpdate = new Date().getTime(); return; } - waitUpdate = true; + if (lastUpdate !== null && new Date().getTime() - lastUpdate < 2 * 1000) { + return; + } + setTimeout(() => { chatStore.getChats(); - waitUpdate = false; + lastUpdate = new Date().getTime(); }, 1000); });