diff --git a/frontend/src/components/v-charts/components/Line.vue b/frontend/src/components/v-charts/components/Line.vue index 94b410e59..d28108444 100644 --- a/frontend/src/components/v-charts/components/Line.vue +++ b/frontend/src/components/v-charts/components/Line.vue @@ -2,7 +2,7 @@
diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index b860d45fa..f454d1b43 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -513,13 +513,16 @@ const loadSafeStatus = async () => { isSafety.value = res.data.securityEntrance; }; +const onFocus = () => { + isActive.value = true; +}; +const onBlur = () => { + isActive.value = false; +}; + onMounted(() => { - window.addEventListener('focus', () => { - isActive.value = true; - }); - window.addEventListener('blur', () => { - isActive.value = false; - }); + window.addEventListener('focus', onFocus); + window.addEventListener('blur', onBlur); loadSafeStatus(); loadUpgradeStatus(); onLoadNetworkOptions(); @@ -528,6 +531,8 @@ onMounted(() => { }); onBeforeUnmount(() => { + window.removeEventListener('focus', onFocus); + window.removeEventListener('blur', onBlur); clearInterval(Number(timer)); timer = null; }); diff --git a/frontend/src/views/home/status/index.vue b/frontend/src/views/home/status/index.vue index d51e133e7..05d1ddb67 100644 --- a/frontend/src/views/home/status/index.vue +++ b/frontend/src/views/home/status/index.vue @@ -356,11 +356,21 @@ function changeChartSize() { } } +function disposeChart() { + echarts.getInstanceByDom(document.getElementById('cpu') as HTMLElement)?.dispose(); + echarts.getInstanceByDom(document.getElementById('memory') as HTMLElement)?.dispose(); + echarts.getInstanceByDom(document.getElementById('load') as HTMLElement)?.dispose(); + for (let i = 0; i < currentInfo.value.diskData.length; i++) { + echarts.getInstanceByDom(document.getElementById('disk' + i) as HTMLElement)?.dispose(); + } +} + onMounted(() => { window.addEventListener('resize', changeChartSize); }); onBeforeUnmount(() => { + disposeChart(); window.removeEventListener('resize', changeChartSize); });