通知功能

This commit is contained in:
2026-04-13 14:51:44 +08:00
parent e2e39cc674
commit 1f8b830d27

View File

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