diff --git a/apps/web-antd/src/layouts/basic.vue b/apps/web-antd/src/layouts/basic.vue index 525c2fe3d..d6a52c63e 100644 --- a/apps/web-antd/src/layouts/basic.vue +++ b/apps/web-antd/src/layouts/basic.vue @@ -3,7 +3,7 @@ import type { NotificationItem } from '@vben/layouts'; import type { SystemTenantApi } from '#/api/system/tenant'; -import { computed, onMounted, ref, watch } from 'vue'; +import { computed, onMounted, onUnmounted, ref, watch } from 'vue'; import { useAccess } from '@vben/access'; import { AuthenticationLoginExpiredModal, useVbenModal } from '@vben/common-ui'; @@ -185,13 +185,15 @@ async function handleTenantChange(tenant: SystemTenantApi.Tenant) { } // ========== 初始化 ========== +let notifyTimer: null | ReturnType = null; + onMounted(() => { // 首次加载未读数量 handleNotificationGetUnreadCount(); // 获取租户列表 handleGetTenantList(); // 轮询刷新未读数量 - setInterval( + notifyTimer = setInterval( () => { if (userStore.userInfo) { handleNotificationGetUnreadCount(); @@ -201,6 +203,13 @@ onMounted(() => { ); }); +onUnmounted(() => { + if (notifyTimer) { + clearInterval(notifyTimer); + notifyTimer = null; + } +}); + watch( () => ({ enable: preferences.app.watermark, diff --git a/apps/web-antd/src/views/dashboard/workspace/index.vue b/apps/web-antd/src/views/dashboard/workspace/index.vue index 280058bf1..08dbe79ee 100644 --- a/apps/web-antd/src/views/dashboard/workspace/index.vue +++ b/apps/web-antd/src/views/dashboard/workspace/index.vue @@ -1,5 +1,12 @@