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) + } +})