diff --git a/frontend/src/components/canvas/components/editor/ComponentWrapper.vue b/frontend/src/components/canvas/components/editor/ComponentWrapper.vue index b6111656ef..58f49bca1c 100644 --- a/frontend/src/components/canvas/components/editor/ComponentWrapper.vue +++ b/frontend/src/components/canvas/components/editor/ComponentWrapper.vue @@ -305,6 +305,9 @@ export default { this[event](events[event]) }) } + }, + setChartData() { + }, elementMouseDown(e) { // // private 设置当前组件数据及状态 diff --git a/frontend/src/components/canvas/components/editor/Preview.vue b/frontend/src/components/canvas/components/editor/Preview.vue index 513570607f..870bdb5fc8 100644 --- a/frontend/src/components/canvas/components/editor/Preview.vue +++ b/frontend/src/components/canvas/components/editor/Preview.vue @@ -238,6 +238,8 @@ export default { return { imageDownloading: false, chartDetailsVisible: false, + canvasMain: null, + tempCanvas: null, showChartInfo: {}, showChartTableInfo: {}, showChartInfoType: 'details', @@ -439,8 +441,14 @@ export default { this.initPdfTemplate() }, beforeDestroy() { - erd.uninstall(this.$refs[this.previewTempRefId]) - erd.uninstall(this.$refs[this.previewRefId]) + if (this.$refs[this.previewTempRefId]) { + erd.uninstall(this.$refs[this.previewTempRefId]) + } + if (this.$refs[this.previewRefId]) { + erd.uninstall(this.$refs[this.previewRefId]) + } + erd.uninstall(this.canvasMain) + erd.uninstall(this.tempCanvas) clearInterval(this.timer) this.canvasId === 'canvas-main' && bus.$off('pcChartDetailsDialog', this.openChartDetailsDialog) bus.$off('trigger-search-button', this.triggerSearchButton) @@ -719,26 +727,27 @@ export default { bus.$emit('onScroll') }, initListen() { - const _this = this - const canvasMain = document.getElementById(this.previewDomId) + this.canvasMain = document.getElementById(this.previewDomId) // 监听主div变动事件 - if (canvasMain) { - erd.listenTo(canvasMain, element => { - _this.$nextTick(() => { - _this.restore() + if (this.canvasMain) { + erd.uninstall(this.canvasMain) + erd.listenTo(this.canvasMain, () => { + this.$nextTick(() => { + this.restore() }) }) } setTimeout(() => { // 监听画布div变动事件 - const tempCanvas = document.getElementById(this.previewTempDomId) - if (tempCanvas) { - erd.listenTo(document.getElementById(this.previewTempDomId), element => { - _this.$nextTick(() => { + this.tempCanvas = document.getElementById(this.previewTempDomId) + if (this.tempCanvas) { + erd.uninstall(this.tempCanvas) + erd.listenTo(document.getElementById(this.previewTempDomId), () => { + this.$nextTick(() => { // 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题 - _this.mainHeight = tempCanvas.scrollHeight + 'px!important' - _this.mainHeightCount = tempCanvas.scrollHeight - this.$emit('mainHeightChange', _this.mainHeight) + this.mainHeight = this.tempCanvas.scrollHeight + 'px!important' + this.mainHeightCount = this.tempCanvas.scrollHeight + this.$emit('mainHeightChange', this.mainHeight) }) }) } diff --git a/frontend/src/components/canvas/customComponent/UserView.vue b/frontend/src/components/canvas/customComponent/UserView.vue index ae86d425b8..0ee37893d0 100644 --- a/frontend/src/components/canvas/customComponent/UserView.vue +++ b/frontend/src/components/canvas/customComponent/UserView.vue @@ -560,6 +560,12 @@ export default { }, beforeDestroy() { + for (const key in this.chart) { + this.$delete(this.chart, key) + } + for (const key in this.view) { + this.$delete(this.view, key) + } this.innerRefreshTimer && clearInterval(this.innerRefreshTimer) bus.$off('plugin-chart-click', this.pluginChartClick) bus.$off('plugin-jump-click', this.pluginJumpClick) @@ -570,6 +576,7 @@ export default { bus.$off('onThemeColorChange', this.optFromBatchThemeChange) bus.$off('onThemeAttrChange', this.optFromBatchSingleProp) bus.$off('clear_panel_linkage', this.clearPanelLinkage) + bus.$off('tab-canvas-change', this.tabSwitch) }, created() { this.refId = uuid.v1 @@ -865,8 +872,8 @@ export default { }, initCurFields(chartDetails) { this.curFields = [] - this.dataRowSelect = [] - this.dataRowNameSelect = [] + this.dataRowSelect = {} + this.dataRowNameSelect = {} if (chartDetails.data && chartDetails.data.sourceFields) { const checkAllAxisStr = chartDetails.xaxis + chartDetails.xaxisExt + chartDetails.yaxis + chartDetails.yaxisExt chartDetails.data.sourceFields.forEach(field => { diff --git a/frontend/src/views/chart/components/ChartComponentG2.vue b/frontend/src/views/chart/components/ChartComponentG2.vue index 2c32934575..60390d6e2a 100644 --- a/frontend/src/views/chart/components/ChartComponentG2.vue +++ b/frontend/src/views/chart/components/ChartComponentG2.vue @@ -61,7 +61,7 @@ import ChartTitleUpdate from './ChartTitleUpdate.vue' import { equalsAny } from '@/utils/StringUtils' import { mapState } from 'vuex' import { baseFlowMapOption } from '@/views/chart/chart/map/map_antv' - +import { clear } from 'size-sensor' export default { name: 'ChartComponentG2', components: { TitleRemark, ViewTrackBar, ChartTitleUpdate }, @@ -166,7 +166,26 @@ export default { } }, beforeDestroy() { - this.myChart.destroy() + if (this.myChart.container) { + clear(this.myChart.container) + } + this.myChart?.clear?.() + this.myChart?.unbindSizeSensor?.() + this.myChart?.unbind?.() + this.myChart?.destroy?.() + if (this.myChart) { + for (const key in this.myChart.chart) { + this.myChart.chart[key] = null + this.$delete(this.myChart.chart, key) + } + for (const key in this.myChart) { + this.myChart[key] = null + this.$delete(this.myChart, key) + } + } + for (const key in this.pointParam) { + this.$delete(this.pointParam, key) + } window.removeEventListener('resize', this.calcHeightDelay) this.myChart = null }, @@ -222,7 +241,7 @@ export default { window.addEventListener('resize', this.calcHeightDelay) }, drawView() { - const chart = this.chart + const chart = JSON.parse(JSON.stringify(this.chart)) // type // if (chart.data) { this.antVRenderStatus = true