处理监听图表的函数,确保及时移除&生产环境不打印log

This commit is contained in:
2026-04-22 11:07:10 +08:00
parent 845e5a8af3
commit cfcb4f5068
117 changed files with 6781 additions and 5767 deletions

View File

@@ -1,4 +1,5 @@
# 生产环境配置 # 生产环境配置
NODE_ENV = production
ENV = 'production' ENV = 'production'
# 页面标题 # 页面标题

View File

@@ -1,8 +1,16 @@
const plugins = [];
// 生产环境移除 console.log/debug/info保留 error/warn
if (process.env.NODE_ENV === 'production') {
plugins.push(['transform-remove-console', { exclude: ['error', 'warn'] }]);
}
module.exports = { module.exports = {
presets: [ presets: [
// https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app // https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
'@vue/cli-plugin-babel/preset' '@vue/cli-plugin-babel/preset'
], ],
plugins: plugins,
'env': { 'env': {
'development': { 'development': {
// babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require(). // babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require().

View File

@@ -50,6 +50,7 @@
"code-brick-zj": "^1.1.1", "code-brick-zj": "^1.1.1",
"core-js": "^3.26.0", "core-js": "^3.26.0",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"diagram-js": "^15.12.0",
"echarts": "5.4.0", "echarts": "5.4.0",
"element-ui": "2.15.14", "element-ui": "2.15.14",
"file-saver": "2.0.5", "file-saver": "2.0.5",
@@ -65,6 +66,7 @@
"screenfull": "5.0.2", "screenfull": "5.0.2",
"sortablejs": "1.10.2", "sortablejs": "1.10.2",
"throttle-debounce": "2.1.0", "throttle-debounce": "2.1.0",
"video.js": "^8.23.7",
"vue": "2.7.14", "vue": "2.7.14",
"vue-count-to": "1.0.13", "vue-count-to": "1.0.13",
"vue-cropper": "0.5.8", "vue-cropper": "0.5.8",
@@ -83,6 +85,7 @@
"@vue/compiler-sfc": "^3.0.1", "@vue/compiler-sfc": "^3.0.1",
"@vue/eslint-config-prettier": "^5.0.0", "@vue/eslint-config-prettier": "^5.0.0",
"babel-eslint": "10.1.0", "babel-eslint": "10.1.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"bpmn-js": "8.9.0", "bpmn-js": "8.9.0",
"bpmn-js-properties-panel": "0.46.0", "bpmn-js-properties-panel": "0.46.0",
"chalk": "4.1.0", "chalk": "4.1.0",

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -158,18 +158,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,18 +154,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,18 +154,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -147,18 +147,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -25,13 +25,21 @@ export default {
}, },
data() { data() {
return { return {
myChart: null // 存储图表实例,方便后续操作 myChart: null, // 存储图表实例,方便后续操作
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.initData(); this.initData();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
watch: { watch: {
// 监听 series 数据变化,实时更新图表 // 监听 series 数据变化,实时更新图表
@@ -51,19 +59,6 @@ export default {
} }
this.myChart = echarts.init(chartDom); this.myChart = echarts.init(chartDom);
this.updateChart(); // 初始化时渲染图表 this.updateChart(); // 初始化时渲染图表
// 监听窗口缩放
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
// 组件销毁时清理
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
}, },
// 单独提取更新图表的方法,方便复用 // 单独提取更新图表的方法,方便复用
updateChart() { updateChart() {
@@ -119,6 +114,18 @@ export default {
this.myChart.setOption(option, true); // 第二个参数 true 表示替换现有配置 this.myChart.setOption(option, true); // 第二个参数 true 表示替换现有配置
} }
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
} }
}; };
</script> </script>

View File

@@ -58,7 +58,8 @@ export default {
chart: null, // 图表实例 chart: null, // 图表实例
financeData:{}, financeData:{},
costData:{}, costData:{},
currentTap: 'month' currentTap: 'month',
resizeHandler: null // 窗口resize事件处理器
} }
}, },
watch: { watch: {
@@ -97,8 +98,20 @@ export default {
mounted() { mounted() {
// 初始化图表 // 初始化图表
this.$nextTick(() => this.updateChart()) this.$nextTick(() => this.updateChart())
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.chart) {
this.chart.resize()
}
}
window.addEventListener('resize', this.resizeHandler)
}, },
beforeDestroy() { beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler)
this.resizeHandler = null
}
// 销毁图表,避免内存泄漏 // 销毁图表,避免内存泄漏
if (this.chart) { if (this.chart) {
this.chart.dispose() this.chart.dispose()
@@ -239,8 +252,6 @@ export default {
} }
this.chart.setOption(option) this.chart.setOption(option)
// 监听窗口 resize自适应图表
window.addEventListener('resize', this.chart.resize)
} }
} }
} }

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -21,6 +22,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -139,19 +147,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,19 +162,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -152,19 +160,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -24,7 +24,10 @@ export default {
}, },
}, },
data() { data() {
return {}; return {
myChart: null,
resizeHandler: null
};
}, },
computed: {}, computed: {},
watch: { watch: {
@@ -41,6 +44,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart(); // 只负责初始化图表实例 this.initChart(); // 只负责初始化图表实例
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
methods: { methods: {
initData() { initData() {
@@ -266,21 +276,20 @@ export default {
] ]
}; };
option && myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放监听
window.addEventListener('resize', () => {
myChart.resize();
});
// 组件销毁清理
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
myChart.resize();
});
myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -24,6 +24,7 @@ export default {
data() { data() {
return { return {
myChart: null, // 存储 echarts 实例 myChart: null, // 存储 echarts 实例
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
// 关键:监听 chartData 变化 // 关键:监听 chartData 变化
@@ -40,6 +41,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart(); this.initChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
methods: { methods: {
// 初始化图表实例 // 初始化图表实例
@@ -53,11 +61,6 @@ export default {
// 初始化时调用一次更新 // 初始化时调用一次更新
this.updateChart(this.chartData); this.updateChart(this.chartData);
// 监听窗口缩放
window.addEventListener('resize', () => {
this.myChart?.resize();
});
}, },
// 核心:根据数据更新图表 // 核心:根据数据更新图表
@@ -210,11 +213,16 @@ export default {
} }
}, },
beforeDestroy() { beforeDestroy() {
// 组件销毁时清理 // 移除窗口resize事件监听器
window.removeEventListener('resize', () => { if (this.resizeHandler) {
this.myChart?.resize(); window.removeEventListener('resize', this.resizeHandler);
}); this.resizeHandler = null;
this.myChart?.dispose(); }
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
} }
}; };
</script> </script>

View File

@@ -9,7 +9,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 保存图表实例,方便更新 myChart: null, // 保存图表实例,方便更新
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -35,6 +36,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.initChart(); this.initChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
methods: { methods: {
initChart() { initChart() {
@@ -45,19 +53,18 @@ export default {
} }
this.myChart = echarts.init(chartDom); this.myChart = echarts.init(chartDom);
this.updateChart(); // 初始化图表数据 this.updateChart(); // 初始化图表数据
},
// 窗口缩放适配 beforeDestroy() {
window.addEventListener('resize', () => { // 移除窗口resize事件监听器
this.myChart && this.myChart.resize(); if (this.resizeHandler) {
}); window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
// 组件销毁清理 }
this.$once('hook:destroyed', () => { // 销毁图表,避免内存泄漏
window.removeEventListener('resize', () => { if (this.myChart) {
this.myChart && this.myChart.resize(); this.myChart.dispose();
}); this.myChart = null;
this.myChart && this.myChart.dispose(); }
});
}, },
updateChart() { updateChart() {

View File

@@ -22,7 +22,8 @@ export default {
}, },
data() { data() {
return { return {
myChart: null myChart: null,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
watch: { watch: {
@@ -38,6 +39,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.initData(); this.initData();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
methods: { methods: {
initData() { initData() {
@@ -259,19 +279,6 @@ export default {
}; };
this.myChart.setOption(option); this.myChart.setOption(option);
// 窗口缩放适配
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
// 组件销毁清理
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,10 @@ import * as echarts from 'echarts';
export default { export default {
components: {}, components: {},
data() { data() {
return {}; return {
myChart: null,
resizeHandler: null // 窗口resize事件处理器
};
}, },
props: { props: {
seriesData: { seriesData: {
@@ -44,6 +47,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.initData(); this.initData();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
methods: { methods: {
initData() { initData() {
@@ -52,7 +62,11 @@ export default {
console.error('图表容器未找到!'); console.error('图表容器未找到!');
return; return;
} }
const myChart = echarts.init(chartDom); // 销毁已有图表实例
if (this.myChart) {
this.myChart.dispose();
}
this.myChart = echarts.init(chartDom);
const option = { const option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@@ -149,21 +163,20 @@ export default {
], ],
}; };
option && myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配
window.addEventListener('resize', () => {
myChart.resize();
});
// 组件销毁清理
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
myChart.resize();
});
myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,10 @@ import * as echarts from 'echarts';
export default { export default {
components: {}, components: {},
data() { data() {
return {}; return {
myChart: null,
resizeHandler: null // 窗口resize事件处理器
};
}, },
props: { props: {
seriesData: { seriesData: {
@@ -44,6 +47,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.initData(); this.initData();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
methods: { methods: {
initData() { initData() {
@@ -52,7 +62,11 @@ export default {
console.error('图表容器未找到!'); console.error('图表容器未找到!');
return; return;
} }
const myChart = echarts.init(chartDom); // 销毁已有图表实例
if (this.myChart) {
this.myChart.dispose();
}
this.myChart = echarts.init(chartDom);
const option = { const option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@@ -260,21 +274,20 @@ export default {
// } // }
}; };
option && myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配
window.addEventListener('resize', () => {
myChart.resize();
});
// 组件销毁清理
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
myChart.resize();
});
myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -158,18 +158,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,18 +154,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -140,18 +140,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -147,18 +147,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -158,18 +158,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,18 +154,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -155,18 +155,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -141,18 +141,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -17,7 +17,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null myChart: null,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -39,6 +40,25 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => this.updateChart()); this.$nextTick(() => this.updateChart());
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
watch: { watch: {
detailData: { detailData: {
@@ -168,19 +188,6 @@ export default {
}; };
this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存 this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存
// 优化防抖resize避免频繁触发
const resizeHandler = () => {
this.myChart && this.myChart.resize();
};
window.removeEventListener('resize', resizeHandler); // 先移除再添加,避免重复绑定
window.addEventListener('resize', resizeHandler);
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', resizeHandler);
this.myChart && this.myChart.dispose();
this.myChart = null;
});
} }
}, },
}; };

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,19 +162,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -155,19 +163,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -139,19 +147,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -18,7 +18,8 @@ export default {
data() { data() {
return { return {
myChart: null, // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
flag:0 flag:0,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -37,6 +38,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -188,19 +196,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,19 +162,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -155,19 +163,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -139,19 +147,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -17,7 +17,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null myChart: null,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -39,6 +40,13 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => this.updateChart()); this.$nextTick(() => this.updateChart());
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
watch: { watch: {
detailData: { detailData: {
@@ -169,20 +177,19 @@ export default {
}; };
this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存 this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存
// 优化防抖resize避免频繁触发
const resizeHandler = () => {
this.myChart && this.myChart.resize();
};
window.removeEventListener('resize', resizeHandler); // 先移除再添加,避免重复绑定
window.addEventListener('resize', resizeHandler);
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', resizeHandler);
this.myChart && this.myChart.dispose();
this.myChart = null;
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,19 +162,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -23,6 +24,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -141,19 +149,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -123,19 +131,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -18,7 +18,8 @@ export default {
data() { data() {
return { return {
myChart: null, // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
flag:0 flag:0,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -37,6 +38,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -188,19 +196,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -158,18 +158,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,18 +154,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -155,18 +155,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -139,18 +139,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -18,7 +18,8 @@ export default {
data() { data() {
return { return {
myChart: null, // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
flag:0 flag: 0,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -37,6 +38,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -199,19 +207,19 @@ getRateFlag(rate, real, target) {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -158,18 +158,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,18 +154,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -152,18 +152,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -147,18 +147,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -158,18 +158,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,18 +154,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -155,18 +155,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -139,18 +139,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -17,7 +17,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null myChart: null,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -39,6 +40,25 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => this.updateChart()); this.$nextTick(() => this.updateChart());
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
watch: { watch: {
detailData: { detailData: {
@@ -167,19 +187,6 @@ export default {
}; };
this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存 this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存
// 优化防抖resize避免频繁触发
const resizeHandler = () => {
this.myChart && this.myChart.resize();
};
window.removeEventListener('resize', resizeHandler); // 先移除再添加,避免重复绑定
window.addEventListener('resize', resizeHandler);
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', resizeHandler);
this.myChart && this.myChart.dispose();
this.myChart = null;
});
} }
}, },
}; };

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,18 +178,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,18 +174,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -155,18 +175,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -123,18 +143,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -17,7 +17,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -36,6 +37,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -187,18 +207,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,19 +162,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -155,19 +163,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -139,19 +147,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -17,7 +17,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null myChart: null,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -39,6 +40,13 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => this.updateChart()); this.$nextTick(() => this.updateChart());
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
watch: { watch: {
detailData: { detailData: {
@@ -167,20 +175,19 @@ export default {
}; };
this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存 this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存
// 优化防抖resize避免频繁触发
const resizeHandler = () => {
this.myChart && this.myChart.resize();
};
window.removeEventListener('resize', resizeHandler); // 先移除再添加,避免重复绑定
window.addEventListener('resize', resizeHandler);
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', resizeHandler);
this.myChart && this.myChart.dispose();
this.myChart = null;
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,18 +178,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,18 +174,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -155,18 +175,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -27,6 +28,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -139,18 +159,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -17,7 +17,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null myChart: null,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -39,6 +40,25 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => this.updateChart()); this.$nextTick(() => this.updateChart());
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
watch: { watch: {
detailData: { detailData: {
@@ -167,19 +187,6 @@ export default {
}; };
this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存 this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存
// 优化防抖resize避免频繁触发
const resizeHandler = () => {
this.myChart && this.myChart.resize();
};
window.removeEventListener('resize', resizeHandler); // 先移除再添加,避免重复绑定
window.addEventListener('resize', resizeHandler);
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', resizeHandler);
this.myChart && this.myChart.dispose();
this.myChart = null;
});
} }
}, },
}; };

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,18 +174,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -31,6 +32,25 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -149,18 +169,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -31,12 +32,21 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 在 mounted 中统一绑定 resize 事件 // 注册窗口resize事件,使用稳定的引用以便后续移除
window.addEventListener('resize', this.handleResize); this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
beforeDestroy() { // 或 unmounted (Vue3) beforeDestroy() {
// 组件销毁时移除监听器并销毁图表 // 移除窗口resize事件监听器
window.removeEventListener('resize', this.handleResize); if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) { if (this.myChart) {
this.myChart.dispose(); this.myChart.dispose();
this.myChart = null; this.myChart = null;
@@ -162,18 +172,6 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
}; };

View File

@@ -17,7 +17,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null myChart: null,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -43,6 +44,25 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(() => this.updateChart()); this.$nextTick(() => this.updateChart());
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
},
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}, },
watch: { watch: {
detailData: { detailData: {
@@ -172,19 +192,6 @@ export default {
}; };
this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存 this.myChart.setOption(option, true); // 新增true表示替换所有配置避免缓存
// 优化防抖resize避免频繁触发
const resizeHandler = () => {
this.myChart && this.myChart.resize();
};
window.removeEventListener('resize', resizeHandler); // 先移除再添加,避免重复绑定
window.addEventListener('resize', resizeHandler);
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', resizeHandler);
this.myChart && this.myChart.dispose();
this.myChart = null;
});
} }
}, },
}; };

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表,避免内存泄漏
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,19 +162,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -125,19 +125,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -139,19 +139,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -18,7 +18,8 @@ export default {
data() { data() {
return { return {
myChart: null, // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
flag:0 flag:0,
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -37,6 +38,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -187,19 +195,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -154,6 +154,18 @@ export default {
}, },
// 未使用的蒸汽仪表盘可注释/删除 // 未使用的蒸汽仪表盘可注释/删除
// getSteamGaugeOption(value) { ... } // getSteamGaugeOption(value) { ... }
},
beforeDestroy() {
// 销毁 ResizeObserver避免内存泄漏
if (this.resizeObserver) {
this.resizeObserver.disconnect();
this.resizeObserver = null;
}
// 销毁图表实例
if (this.electricityChart) {
this.electricityChart.dispose();
this.electricityChart = null;
}
} }
} }
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -158,19 +166,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -8,7 +8,8 @@ export default {
components: {}, components: {},
data() { data() {
return { return {
myChart: null // 存储图表实例,避免重复创建 myChart: null, // 存储图表实例,避免重复创建
resizeHandler: null // 窗口resize事件处理器
}; };
}, },
props: { props: {
@@ -29,6 +30,13 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.updateChart(); this.updateChart();
}); });
// 注册窗口resize事件使用稳定的引用以便后续移除
this.resizeHandler = () => {
if (this.myChart) {
this.myChart.resize();
}
};
window.addEventListener('resize', this.resizeHandler);
}, },
// 新增:监听 chartData 变化 // 新增:监听 chartData 变化
@@ -154,19 +162,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

View File

@@ -155,19 +155,19 @@ export default {
}; };
option && this.myChart.setOption(option); option && this.myChart.setOption(option);
// 窗口缩放适配和销毁逻辑保持不变
window.addEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.$once('hook:destroyed', () => {
window.removeEventListener('resize', () => {
this.myChart && this.myChart.resize();
});
this.myChart && this.myChart.dispose();
});
} }
}, },
beforeDestroy() {
// 移除窗口resize事件监听器
if (this.resizeHandler) {
window.removeEventListener('resize', this.resizeHandler);
this.resizeHandler = null;
}
// 销毁图表实例
if (this.myChart) {
this.myChart.dispose();
this.myChart = null;
}
}
}; };
</script> </script>

Some files were not shown because too many files have changed in this diff Show More