From 5e3e580f51947c5541c25b1cce756f6cba041cf6 Mon Sep 17 00:00:00 2001 From:   <73635091+nightzjp@users.noreply.github.com> Date: Mon, 5 Jun 2023 17:52:53 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B5=8F=E8=A7=88=E5=99=A8=E5=A4=B1?= =?UTF-8?q?=E5=8E=BB=E7=84=A6=E7=82=B9=E5=81=9C=E6=AD=A2=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E3=80=81=E8=8A=82=E7=9C=81=E5=BC=80=E9=94=80=20(#1256)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/home/index.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index 87bf5e0da..74556edb6 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -239,6 +239,7 @@ const isSafety = ref(); const chartOption = ref('network'); let timer: NodeJS.Timer | null = null; let isInit = ref(true); +let isActive = ref(true); const ioReadBytes = ref>([]); const ioWriteBytes = ref>([]); @@ -353,12 +354,14 @@ const onLoadBaseInfo = async (isInit: boolean, range: string) => { const res = await loadBaseInfo(searchInfo.ioOption, searchInfo.netOption); baseInfo.value = res.data; currentInfo.value = baseInfo.value.currentInfo; - onLoadCurrentInfo(); + await onLoadCurrentInfo(); statuRef.value.acceptParams(currentInfo.value, baseInfo.value); appRef.value.acceptParams(); if (isInit) { timer = setInterval(async () => { - onLoadCurrentInfo(); + if (isActive.value) { + await onLoadCurrentInfo(); + } }, 3000); } }; @@ -511,6 +514,12 @@ const loadSafeStatus = async () => { }; onMounted(() => { + window.addEventListener('focus', () => { + isActive.value = true; + }); + window.addEventListener('blur', () => { + isActive.value = false; + }); loadSafeStatus(); loadUpgradeStatus(); onLoadNetworkOptions();