From 08aeb1593c3a12c9a22085fdb2ba9c01850ef390 Mon Sep 17 00:00:00 2001 From: Zhunianya <2698076424@qq.com> Date: Tue, 31 Mar 2026 14:23:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A6=96=E9=A1=B5):=20=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E6=94=B9=E5=8F=98=E6=97=B6=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/views/index.vue | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/vue/src/views/index.vue b/vue/src/views/index.vue index fa31b4be..8cf94fe6 100644 --- a/vue/src/views/index.vue +++ b/vue/src/views/index.vue @@ -268,6 +268,11 @@ export default { deviceCount: 0, // 版本号 version: '3.8.0', + bMapChart: null, + pieCpuChart: null, + pieMemeryChart: null, + pieDiskChart: null, + // 服务器信息 server: { jvm: { @@ -302,10 +307,12 @@ export default { }, mounted() { this.$nextTick(() => { - this.draawPieCpu(); - window.addEventListener('resize', this.handleResize); // 监听窗口大小变化以重新渲染饼图 + window.addEventListener('resize', this.handleResize); }); }, + beforeDestroy() { + window.removeEventListener('resize', this.handleResize); + }, methods: { init() { if (this.$store.state.user.roles.indexOf('tenant') === -1 && this.$store.state.user.roles.indexOf('general') === -1) { @@ -372,12 +379,14 @@ export default { if (this.bMapChart) { this.bMapChart.resize(); } - if (this.gMapChart) { - this.gMapChart.resize(); - } if (this.pieCpuChart) { this.pieCpuChart.resize(); - this.updateRadius(); + } + if (this.pieMemeryChart) { + this.pieMemeryChart.resize(); + } + if (this.pieDiskChart) { + this.pieDiskChart.resize(); } }, /** 查询服务器信息 */ @@ -432,11 +441,11 @@ export default { /** 地图 */ getmap() { - var myChart = this.$echarts.init(this.$refs.map); + this.bMapChart = this.$echarts.init(this.$refs.map); var option; // 单击事件 - myChart.on('click', (params) => { + this.bMapChart.on('click', (params) => { if (params.data.deviceId) { this.$router.push({ path: '/iot/device-edit', @@ -699,12 +708,12 @@ export default { ], }; - option && myChart.setOption(option); + option && this.bMapChart.setOption(option); }, drawPieCpu() { // 基于准备好的dom,初始化echarts实例 - let myChart = this.$echarts.init(this.$refs.pieCpu); + this.pieCpuChart = this.$echarts.init(this.$refs.pieCpu); var option; option = { title: { @@ -753,11 +762,11 @@ export default { }, ], }; - option && myChart.setOption(option); + option && this.pieCpuChart.setOption(option); }, drawPieMemery() { // 基于准备好的dom,初始化echarts实例 - let myChart = this.$echarts.init(this.$refs.pieMemery); + this.pieMemeryChart = this.$echarts.init(this.$refs.pieMemery); var option; option = { title: { @@ -802,11 +811,11 @@ export default { }, ], }; - option && myChart.setOption(option); + option && this.pieMemeryChart.setOption(option); }, drawPieDisk() { // 基于准备好的dom,初始化echarts实例 - let myChart = this.$echarts.init(this.$refs.pieDisk); + this.pieDiskChart = this.$echarts.init(this.$refs.pieDisk); var option; let one = this.server.sysFiles[0].used.replace('GB', ''); let two = this.server.sysFiles[0].free.replace('GB', ''); @@ -853,7 +862,7 @@ export default { }, ], }; - option && myChart.setOption(option); + option && this.pieDiskChart.setOption(option); }, }, };