diff --git a/src/App.vue b/src/App.vue index 4a7a172..a61848c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -71,6 +71,22 @@ const isDev = window.location.port === '5173' const noticeStore = useNoticeStore() noticeStore.fetchNotices() +// 定期检查新通知 +let noticeCheckInterval = null +const startNoticeCheck = () => { + // 每 5 分钟检查一次新通知 + noticeCheckInterval = setInterval(() => { + noticeStore.fetchNotices() + }, 5 * 60 * 1000) +} + +const stopNoticeCheck = () => { + if (noticeCheckInterval) { + clearInterval(noticeCheckInterval) + noticeCheckInterval = null + } +} + // Lifecycle onMounted(() => { // Set Title @@ -161,6 +177,10 @@ onMounted(() => { loadConfig() + // 启动定期检查新通知 + startNoticeCheck() + console.log('[App] 已启动通知检查') + // Health Check startHealthCheck() }) @@ -170,6 +190,8 @@ onUnmounted(() => { window.removeEventListener('storage', handleStorageChange) window.removeEventListener('config-updated', handleConfigUpdate) window.removeEventListener('auth-expired', handleAuthExpired) + stopNoticeCheck() + console.log('[App] 已停止通知检查') stopHealthCheck() })