修bug
This commit is contained in:
@@ -363,6 +363,14 @@ export default {
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const fetchUnresolvedAlarmCount = async () => {
|
||||
// 检查用户是否已登录
|
||||
const token = localStorage.getItem('jwt_token');
|
||||
if (!token) {
|
||||
// 如果未登录,则不执行告警接口调用
|
||||
unresolvedAlarmCount.value = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 调用API获取活跃且未忽略的告警数量
|
||||
const response = await getActiveAlarms({
|
||||
@@ -391,8 +399,8 @@ export default {
|
||||
window.addEventListener('storage', handleStorageChange);
|
||||
// 首次加载时获取告警数量
|
||||
fetchUnresolvedAlarmCount();
|
||||
// 每30秒刷新一次告警数量
|
||||
alarmFetchInterval = setInterval(fetchUnresolvedAlarmCount, 30000);
|
||||
// 每60秒刷新一次告警数量
|
||||
alarmFetchInterval = setInterval(fetchUnresolvedAlarmCount, 60000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user