移除轮询

This commit is contained in:
2026-07-17 11:32:34 +08:00
parent 2232ef6f3c
commit 9b788189fd
7 changed files with 753 additions and 718 deletions
+2 -14
View File
@@ -242,14 +242,7 @@ const handleMarkAllRead = async () => {
}
};
const handleMessagesChanged = () => {
fetchUnreadCount();
fetchMessages();
};
let timer: any = null;
// 根据菜单列表和当前路径计算出的面包屑导航
// 根据菜单列表和当前路径计算出的面包屑导航
const breadcrumbs = computed(() => {
let chain: Breadcrumb[] = [];
let currentPath = route.path || '/';
@@ -433,9 +426,8 @@ onMounted(async () => {
mediaQuery.addEventListener('change', handleChange);
if (authStore.token) {
// 仅在后台页面刷新/首次挂载时更新未读数量,不再自动轮询。
fetchUnreadCount();
timer = setInterval(fetchUnreadCount, 60000);
window.addEventListener('site-messages-changed', handleMessagesChanged);
}
});
@@ -444,10 +436,6 @@ onUnmounted(() => {
if (mediaQuery && handleChange) {
mediaQuery.removeEventListener('change', handleChange);
}
if (timer) {
clearInterval(timer);
}
window.removeEventListener('site-messages-changed', handleMessagesChanged);
});
</script>