From 30f7fa6afa58fbd894a25a3022435585f83248ff Mon Sep 17 00:00:00 2001 From: wzrove <88016243+wzrove@users.noreply.github.com> Date: Thu, 13 Jul 2023 20:47:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2echart=E8=B5=84=E6=BA=90=E9=87=8A=E6=94=BE=20?= =?UTF-8?q?(#1651)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What this PR does / why we need it? #1598 监控页面echart资源 组件卸载未释放 #### Summary of your change 优化监控页面echart资源释放 #### Please indicate you've done the following: - [x] Made sure tests are passing and test coverage is added if needed. - [x] Made sure commit message follow the rule of [Conventional Commits specification](https://www.conventionalcommits.org/). - [x] Considered the docs impact and opened a new docs issue or PR with docs changes if needed. --- frontend/src/views/host/monitor/monitor/index.vue | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/views/host/monitor/monitor/index.vue b/frontend/src/views/host/monitor/monitor/index.vue index 82294db75..5b1060fb4 100644 --- a/frontend/src/views/host/monitor/monitor/index.vue +++ b/frontend/src/views/host/monitor/monitor/index.vue @@ -759,12 +759,21 @@ function changeChartSize() { echarts.getInstanceByDom(document.getElementById('loadNetworkChart') as HTMLElement)?.resize(); } +function disposeChart() { + echarts.getInstanceByDom(document.getElementById('loadLoadChart') as HTMLElement)?.dispose(); + echarts.getInstanceByDom(document.getElementById('loadCPUChart') as HTMLElement)?.dispose(); + echarts.getInstanceByDom(document.getElementById('loadMemoryChart') as HTMLElement)?.dispose(); + echarts.getInstanceByDom(document.getElementById('loadIOChart') as HTMLElement)?.dispose(); + echarts.getInstanceByDom(document.getElementById('loadNetworkChart') as HTMLElement)?.dispose(); +} + onMounted(() => { zoomStart.value = dateFormatWithoutYear(new Date(new Date().setHours(0, 0, 0, 0))); loadNetworkOptions(); window.addEventListener('resize', changeChartSize); }); onBeforeUnmount(() => { + disposeChart(); window.removeEventListener('resize', changeChartSize); });