From 5184e4a43583453dc2afc089d4cf4485e33b2a2d Mon Sep 17 00:00:00 2001 From: yufei0306 <13417315+yufei0306@user.noreply.gitee.com> Date: Mon, 8 Apr 2024 11:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=86=85=E5=AD=98=E6=B3=84?= =?UTF-8?q?=E6=BC=8F=E9=80=A0=E6=88=90=E9=A1=B5=E9=9D=A2=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Message/src/Message.vue | 9 +++++++-- src/views/login/components/LoginForm.vue | 2 +- src/views/login/components/MobileForm.vue | 10 ++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/layout/components/Message/src/Message.vue b/src/layout/components/Message/src/Message.vue index 28f796b3b..ca7fc6107 100644 --- a/src/layout/components/Message/src/Message.vue +++ b/src/layout/components/Message/src/Message.vue @@ -8,7 +8,7 @@ const { push } = useRouter() const activeName = ref('notice') const unreadCount = ref(0) // 未读消息数量 const list = ref([]) // 消息列表 - +const interval = ref() // 获得消息列表 const getList = async () => { list.value = await NotifyMessageApi.getUnreadNotifyMessageList() @@ -35,13 +35,18 @@ onMounted(() => { // 首次加载小红点 getUnreadCount() // 轮询刷新小红点 - setInterval( + interval.value = setInterval( () => { getUnreadCount() }, 1000 * 60 * 2 ) }) +onBeforeUnmount(() => { + if(interval.value){ + clearInterval(interval.value) + } +})