1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

fix: 优化监控页面echart资源释放 (#1651)

#### 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.
This commit is contained in:
wzrove 2023-07-13 20:47:18 +08:00 committed by GitHub
parent 4605b19473
commit 30f7fa6afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -759,12 +759,21 @@ function changeChartSize() {
echarts.getInstanceByDom(document.getElementById('loadNetworkChart') as HTMLElement)?.resize(); 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(() => { onMounted(() => {
zoomStart.value = dateFormatWithoutYear(new Date(new Date().setHours(0, 0, 0, 0))); zoomStart.value = dateFormatWithoutYear(new Date(new Date().setHours(0, 0, 0, 0)));
loadNetworkOptions(); loadNetworkOptions();
window.addEventListener('resize', changeChartSize); window.addEventListener('resize', changeChartSize);
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
disposeChart();
window.removeEventListener('resize', changeChartSize); window.removeEventListener('resize', changeChartSize);
}); });
</script> </script>