From 997b706d8a37763432ddc86d40bcb7b5fdfaa2f2 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 7 Jul 2025 11:03:49 +0800 Subject: [PATCH] fix: Fix dashboard refresh exception issue (#9429) --- frontend/src/views/home/index.vue | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index 662be0082..a186ebdf1 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -279,6 +279,7 @@ let timer: NodeJS.Timer | null = null; let isInit = ref(true); let isStatusInit = ref(true); let isActive = ref(true); +let isCurrentActive = ref(true); const ioReadBytes = ref>([]); const ioWriteBytes = ref>([]); @@ -406,16 +407,19 @@ const onLoadBaseInfo = async (isInit: boolean, range: string) => { statusRef.value?.acceptParams(currentInfo.value, baseInfo.value); appRef.value?.acceptParams(); if (isInit) { - try { - timer = setInterval(async () => { + timer = setInterval(async () => { + try { + if (!isCurrentActive.value) { + throw new Error('jump out'); + } if (isActive.value && !globalStore.isOnRestart) { await onLoadCurrentInfo(); } - }, 3000); - } finally { - clearInterval(Number(timer)); - timer = null; - } + } catch { + clearInterval(Number(timer)); + timer = null; + } + }, 3000); } }; @@ -554,6 +558,7 @@ onMounted(() => { onBeforeUnmount(() => { window.removeEventListener('focus', onFocus); window.removeEventListener('blur', onBlur); + isCurrentActive.value = false; clearInterval(Number(timer)); timer = null; });