From 5716c4ad1ff5809a6920fa1b852f3dedd625fbfd Mon Sep 17 00:00:00 2001 From: dataeaseShu <106045316+dataeaseShu@users.noreply.github.com> Date: Thu, 3 Nov 2022 14:35:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/chart/components/ChartComponent.vue | 8 ++++---- .../views/chart/components/ChartComponentG2.vue | 10 ++++++---- .../views/chart/components/ChartComponentS2.vue | 16 +++++++--------- .../chart/components/normal/LabelNormal.vue | 6 ++---- .../chart/components/normal/LabelNormalText.vue | 6 ++---- .../views/chart/components/table/TableNormal.vue | 6 ++---- frontend/src/views/chart/view/ChartFieldEdit.vue | 7 ++++--- frontend/src/views/dataset/add/AddApi.vue | 7 ++++--- frontend/src/views/dataset/add/AddCustom.vue | 7 ++++--- frontend/src/views/dataset/add/AddDB.vue | 7 ++++--- frontend/src/views/dataset/add/AddExcel.vue | 7 ++++--- frontend/src/views/dataset/add/AddSQL.vue | 7 ++++--- .../src/views/dataset/add/union/UnionPreview.vue | 7 ++++--- .../views/dataset/common/DatasetTableData.vue | 6 ------ frontend/src/views/dataset/data/FieldEdit.vue | 7 ++++--- 15 files changed, 55 insertions(+), 59 deletions(-) diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index b6d2577ca1..c7d1178eca 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -207,8 +207,10 @@ export default { mounted() { this.preDraw() }, - destroyed() { + beforeDestroy() { + window.removeEventListener('resize', this.myChart.resize) this.myChart.dispose() + this.myChart = null }, created() { this.loadThemeStyle() @@ -403,9 +405,7 @@ export default { const chart = this.myChart this.setBackGroundBorder() setTimeout(chart.setOption(option, true), 500) - window.onresize = function() { - chart.resize() - } + window.removeEventListener('resize', chart.resize) }, setBackGroundBorder() { if (this.chart.customStyle) { diff --git a/frontend/src/views/chart/components/ChartComponentG2.vue b/frontend/src/views/chart/components/ChartComponentG2.vue index a6c8791745..891c7195eb 100644 --- a/frontend/src/views/chart/components/ChartComponentG2.vue +++ b/frontend/src/views/chart/components/ChartComponentG2.vue @@ -155,6 +155,11 @@ export default { this.drawEcharts() } }, + beforeDestroy() { + this.myChart.destroy() + window.removeEventListener('resize', this.calcHeightDelay) + this.myChart = null + }, mounted() { this.preDraw() }, @@ -202,10 +207,7 @@ export default { new Promise((resolve) => { resolve() }).then(() => { this.drawView() }) - const that = this - window.onresize = function() { - that.calcHeightDelay() - } + window.addEventListener('resize', this.calcHeightDelay) }, drawView() { const chart = this.chart diff --git a/frontend/src/views/chart/components/ChartComponentS2.vue b/frontend/src/views/chart/components/ChartComponentS2.vue index 1bc6849579..bfc811a891 100644 --- a/frontend/src/views/chart/components/ChartComponentS2.vue +++ b/frontend/src/views/chart/components/ChartComponentS2.vue @@ -195,6 +195,9 @@ export default { }, beforeDestroy() { clearInterval(this.scrollTimer) + window.removeEventListener('resize', this.onResize) + this.myChart.destroy() + this.myChart = null }, methods: { initData() { @@ -221,21 +224,16 @@ export default { this.tableData = data }, preDraw() { + this.onResize() + window.addEventListener('resize', this.onResize) + }, + onResize() { this.initData() this.initTitle() this.calcHeightDelay() new Promise((resolve) => { resolve() }).then(() => { this.drawView() }) - const that = this - window.onresize = function() { - that.initData() - that.initTitle() - that.calcHeightDelay() - new Promise((resolve) => { resolve() }).then(() => { - that.drawView() - }) - } }, drawView() { const chart = this.chart diff --git a/frontend/src/views/chart/components/normal/LabelNormal.vue b/frontend/src/views/chart/components/normal/LabelNormal.vue index 08881845ae..c7aac6cff7 100644 --- a/frontend/src/views/chart/components/normal/LabelNormal.vue +++ b/frontend/src/views/chart/components/normal/LabelNormal.vue @@ -133,15 +133,13 @@ export default { }, beforeDestroy() { eventBus.$off('resizing', this.chartResize) + window.removeEventListener('resize', this.calcHeight) }, methods: { init() { - const that = this this.initStyle() this.resultFormat() - window.onresize = function() { - that.calcHeight() - } + window.addEventListener('resize', this.calcHeight) this.setBackGroundBorder() this.initRemark() }, diff --git a/frontend/src/views/chart/components/normal/LabelNormalText.vue b/frontend/src/views/chart/components/normal/LabelNormalText.vue index bc76b5a5d2..350aff5983 100644 --- a/frontend/src/views/chart/components/normal/LabelNormalText.vue +++ b/frontend/src/views/chart/components/normal/LabelNormalText.vue @@ -161,14 +161,12 @@ export default { }, beforeDestroy() { eventBus.$off('resizing', this.chartResize) + window.removeEventListener('resize', this.calcHeight) }, methods: { init() { - const that = this this.initStyle() - window.onresize = function() { - that.calcHeight() - } + window.addEventListener('resize', this.calcHeight) this.setBackGroundBorder() this.initRemark() }, diff --git a/frontend/src/views/chart/components/table/TableNormal.vue b/frontend/src/views/chart/components/table/TableNormal.vue index 4738d1bc04..632491e403 100644 --- a/frontend/src/views/chart/components/table/TableNormal.vue +++ b/frontend/src/views/chart/components/table/TableNormal.vue @@ -168,6 +168,7 @@ export default { beforeDestroy() { eventBus.$off('resizing', this.chartResize) clearInterval(this.scrollTimer) + window.removeEventListener('resize', this.calcHeightDelay) }, methods: { init() { @@ -187,7 +188,6 @@ export default { } }, initData() { - const that = this let data = [] this.showPage = false if (this.chart.data) { @@ -229,9 +229,7 @@ export default { this.$nextTick(() => { this.initStyle() }) - window.onresize = function() { - that.calcHeightDelay() - } + window.addEventListener('resize', this.calcHeightDelay) }, calcHeightRightNow() { this.$nextTick(() => { diff --git a/frontend/src/views/chart/view/ChartFieldEdit.vue b/frontend/src/views/chart/view/ChartFieldEdit.vue index 55287b9bd6..105948d741 100644 --- a/frontend/src/views/chart/view/ChartFieldEdit.vue +++ b/frontend/src/views/chart/view/ChartFieldEdit.vue @@ -568,10 +568,11 @@ export default { this.filterField(val) } }, + beforeDestroy() { + window.removeEventListener('resize', this.calcHeight) + }, mounted() { - window.onresize = () => { - this.calcHeight() - } + window.addEventListener('resize', this.calcHeight) this.calcHeight() this.initField() }, diff --git a/frontend/src/views/dataset/add/AddApi.vue b/frontend/src/views/dataset/add/AddApi.vue index 2e009ccca8..459e0efcfd 100644 --- a/frontend/src/views/dataset/add/AddApi.vue +++ b/frontend/src/views/dataset/add/AddApi.vue @@ -312,11 +312,12 @@ export default { } } }, + beforeDestroy() { + window.removeEventListener('resize', this.calHeight) + }, mounted() { this.initDataSource() - window.onresize = () => { - this.calHeight() - } + window.addEventListener('resize', this.calHeight) this.calHeight() }, activated() { diff --git a/frontend/src/views/dataset/add/AddCustom.vue b/frontend/src/views/dataset/add/AddCustom.vue index 11f1c8a576..d2d473d78e 100644 --- a/frontend/src/views/dataset/add/AddCustom.vue +++ b/frontend/src/views/dataset/add/AddCustom.vue @@ -140,10 +140,11 @@ export default { this.getUnionData() } }, + beforeDestroy() { + window.removeEventListener('resize', this.calHeight) + }, mounted() { - window.onresize = () => { - this.calHeight() - } + window.addEventListener('resize', this.calHeight) this.calHeight() if (this.param && this.param.id && this.param.tableId) { diff --git a/frontend/src/views/dataset/add/AddDB.vue b/frontend/src/views/dataset/add/AddDB.vue index 791f839d8c..07b73ccf18 100644 --- a/frontend/src/views/dataset/add/AddDB.vue +++ b/frontend/src/views/dataset/add/AddDB.vue @@ -328,11 +328,12 @@ export default { } } }, + beforeDestroy() { + window.removeEventListener('resize', this.calHeight) + }, mounted() { this.initDataSource() - window.onresize = () => { - this.calHeight() - } + window.addEventListener('resize', this.calHeight) this.calHeight() }, activated() { diff --git a/frontend/src/views/dataset/add/AddExcel.vue b/frontend/src/views/dataset/add/AddExcel.vue index 9f5fbf0122..fd96a93531 100644 --- a/frontend/src/views/dataset/add/AddExcel.vue +++ b/frontend/src/views/dataset/add/AddExcel.vue @@ -304,10 +304,11 @@ export default { return this.nameList.filter((ele) => ele !== this.originName) } }, + beforeDestroy() { + window.removeEventListener('resize', this.calHeight) + }, mounted() { - window.onresize = () => { - this.calHeight() - } + window.addEventListener('resize', this.calHeight) this.calHeight() }, created() { diff --git a/frontend/src/views/dataset/add/AddSQL.vue b/frontend/src/views/dataset/add/AddSQL.vue index 03506438c9..a1ee77640b 100644 --- a/frontend/src/views/dataset/add/AddSQL.vue +++ b/frontend/src/views/dataset/add/AddSQL.vue @@ -675,10 +675,11 @@ export default { } } }, + beforeDestroy() { + window.removeEventListener('resize', this.calHeight) + }, async mounted() { - window.onresize = () => { - this.calHeight() - } + window.addEventListener('resize', this.calHeight) this.calHeight() await this.initDataSource() this.$refs.myCm.codemirror.on('keypress', () => { diff --git a/frontend/src/views/dataset/add/union/UnionPreview.vue b/frontend/src/views/dataset/add/union/UnionPreview.vue index e559634265..058f1040c3 100644 --- a/frontend/src/views/dataset/add/union/UnionPreview.vue +++ b/frontend/src/views/dataset/add/union/UnionPreview.vue @@ -57,12 +57,13 @@ export default { } } }, + beforeDestroy() { + window.removeEventListener('resize', this.calHeight) + }, mounted() { this.initPreview() this.calHeight() - window.onresize = () => { - this.calHeight() - } + window.addEventListener('resize', this.calHeight) }, methods: { calHeight: _.debounce(function() { diff --git a/frontend/src/views/dataset/common/DatasetTableData.vue b/frontend/src/views/dataset/common/DatasetTableData.vue index cabf2c4e1a..ecdf741a7b 100644 --- a/frontend/src/views/dataset/common/DatasetTableData.vue +++ b/frontend/src/views/dataset/common/DatasetTableData.vue @@ -80,12 +80,6 @@ export default { } }, mounted() { - // window.onresize = () => { - // return (() => { - // this.height = window.innerHeight / 3 - // })() - // } - // this.height = window.innerHeight / 3 this.$nextTick(() => { this.height = document.getElementById('dsData').parentNode.offsetHeight - 16 - 14 - 5 diff --git a/frontend/src/views/dataset/data/FieldEdit.vue b/frontend/src/views/dataset/data/FieldEdit.vue index a666b0e68f..a93f29821b 100644 --- a/frontend/src/views/dataset/data/FieldEdit.vue +++ b/frontend/src/views/dataset/data/FieldEdit.vue @@ -794,10 +794,11 @@ export default { this.filterField(val) } }, + beforeDestroy() { + window.removeEventListener('resize', this.calcHeight) + }, mounted() { - window.onresize = () => { - this.calcHeight() - } + window.addEventListener('resize', this.calcHeight) this.calcHeight() this.initField() },