diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index 7c0e43dda..1c42c08f4 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -863,7 +863,7 @@ export default { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { // this.showLoading = false; - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, resize (chartItem) { diff --git a/nezha-fronted/src/components/charts/chart-bar-statistics.vue b/nezha-fronted/src/components/charts/chart-bar-statistics.vue index a802fe184..57fcb64db 100644 --- a/nezha-fronted/src/components/charts/chart-bar-statistics.vue +++ b/nezha-fronted/src/components/charts/chart-bar-statistics.vue @@ -228,7 +228,7 @@ export default { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { // this.showLoading = false; - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, showLoad (chartItem) { @@ -498,7 +498,7 @@ export default { this.$nextTick(() => { const vm = this setTimeout(function () { - const divHeight = self.$refs.legendArea.offsetHeight + const divHeight = self.$refs.legendArea ? self.$refs.legendArea.offsetHeight : 20 if (!self.chartData.height) { getChart(self.chartIndex).resize({ height: (400 - divHeight - self.$chartResizeTool.titleHeight - self.$chartResizeTool.chartBlankHeight) }) } else { @@ -573,16 +573,16 @@ export default { if (self.pieData[0]) { if (self.pieData[0].data.length > 0) { getChart(self.chartIndex).clear() - getChart(self.chartIndex).setOption(self.option)// 创建图表 + getChart(self.chartIndex) && getChart(self.chartIndex).setOption(self.option)// 创建图表 self.noData = false } else { self.noData = true self.option = chartConfig.getOption('noData') getChart(self.chartIndex).clear() - getChart(self.chartIndex).setOption(self.option)// 创建图表 + getChart(self.chartIndex) && getChart(self.chartIndex).setOption(self.option)// 创建图表 } } - self.$refs['localLoading' + self.chartIndex].endLoading() + self.$refs['localLoading' + self.chartIndex] && self.$refs['localLoading' + self.chartIndex].endLoading() self.firstShow = true // 展示操作按键 }, 100) }) @@ -621,12 +621,12 @@ export default { setTimeout(function () { self.$set(self.option.tooltip, 'formatter', self.formatterFunc) if (self.pieData[0].data.length > 0) { - self.echartScreen.setOption(self.option)// 显示全屏界面 + self.echartScreen && self.echartScreen.setOption(self.option)// 显示全屏界面 self.noData = false } else { self.noData = true self.option = chartConfig.getOption('noData') - self.echartScreen.setOption(self.option)// 显示全屏界面 + self.echartScreen && self.echartScreen.setOption(self.option)// 显示全屏界面 } self.echartScreen.on('finished', function () { const legendDiv = document.getElementById('screenLegendArea' + self.chartIndex) diff --git a/nezha-fronted/src/components/charts/chart-detail.vue b/nezha-fronted/src/components/charts/chart-detail.vue index 18aaaed4d..01856cc09 100644 --- a/nezha-fronted/src/components/charts/chart-detail.vue +++ b/nezha-fronted/src/components/charts/chart-detail.vue @@ -404,7 +404,7 @@ export default { this.$refs['localLoading' + this.chartIndex].startLoading() }, endLoading (area) { - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() }, preview () { this.$refs.chartsPreview.show(this.data) @@ -538,7 +538,7 @@ export default { series: series } const chart = echarts.init(document.querySelector('#littleChart')) - chart.setOption(option)// 创建图表 + chart && chart.setOption(option)// 创建图表 }, timeFormat (val) { return this.utcTimeToTimezoneStr(val) diff --git a/nezha-fronted/src/components/charts/chart-group.vue b/nezha-fronted/src/components/charts/chart-group.vue index 0b87c1f8b..65c29b87b 100644 --- a/nezha-fronted/src/components/charts/chart-group.vue +++ b/nezha-fronted/src/components/charts/chart-group.vue @@ -195,7 +195,7 @@ export default { if (area === 'screen') { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, clearChart () { diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index ab098e9ff..a0f172ba8 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -1916,7 +1916,7 @@ export default { }, mounted () { this.init() - window.addEventListener('resize', () => this.resize(), false) + window.addEventListener('resize', this.resize, false) }, beforeDestroy () { window.removeEventListener('resize', this.resize, false) diff --git a/nezha-fronted/src/components/charts/chart-pie.vue b/nezha-fronted/src/components/charts/chart-pie.vue index 33538f735..e1024e0fb 100644 --- a/nezha-fronted/src/components/charts/chart-pie.vue +++ b/nezha-fronted/src/components/charts/chart-pie.vue @@ -224,7 +224,7 @@ export default { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { // this.showLoading = false; - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, showLoad (chartItem) { @@ -398,14 +398,14 @@ export default { this.$nextTick(() => { const vm = this setTimeout(function () { - const divHeight = self.$refs.legendArea.offsetHeight + const divHeight = self.$refs.legendArea ? self.$refs.legendArea.offsetHeight : 20 if (!self.chartData.height) { getChart(self.chartIndex).resize({ height: (400 - divHeight - self.$chartResizeTool.titleHeight - self.$chartResizeTool.chartBlankHeight) }) } else { getChart(self.chartIndex).resize({ height: (self.chartData.height * vm.stepWidth - divHeight - self.$chartResizeTool.titleHeight - self.$chartResizeTool.chartBlankHeight) }) } - self.$set(self.option.tooltip, 'formatter', self.formatterFunc) - self.$set(self.option.tooltip, 'position', function (point, params, dom, rect, size) { + self.option.tooltip && self.$set(self.option.tooltip, 'formatter', self.formatterFunc) + self.option.tooltip && self.$set(self.option.tooltip, 'position', function (point, params, dom, rect, size) { dom.style.transform = 'translateZ(0)' const windowWidth = window.innerWidth// 窗口宽度 const windowHeight = window.innerHeight// 窗口高度 @@ -472,16 +472,16 @@ export default { }) if (self.pieData[0].data.length > 0) { getChart(self.chartIndex).clear() - getChart(self.chartIndex).setOption(self.option)// 创建图表 + getChart(self.chartIndex) && getChart(self.chartIndex).setOption(self.option)// 创建图表 self.noData = false } else { self.noData = true self.option = chartConfig.getOption('noData') getChart(self.chartIndex).clear() - getChart(self.chartIndex).setOption(self.option)// 创建图表 + getChart(self.chartIndex) && getChart(self.chartIndex).setOption(self.option)// 创建图表 } - self.$refs['localLoading' + self.chartIndex].endLoading() + self.$refs['localLoading' + self.chartIndex] && self.$refs['localLoading' + self.chartIndex].endLoading() self.firstShow = true // 展示操作按键 }, 100) }) @@ -519,12 +519,12 @@ export default { self.echartScreen.resize({ height: (sumHeight - divHeight - 58) })// 图表的高度 setTimeout(function () { if (self.pieData[0].data.length > 0) { - self.echartScreen.setOption(self.option)// 显示全屏界面 + self.echartScreen && self.echartScreen.setOption(self.option)// 显示全屏界面 self.noData = false } else { self.noData = true self.option = chartConfig.getOption('noData') - self.echartScreen.setOption(self.option)// 显示全屏界面 + self.echartScreen && self.echartScreen.setOption(self.option)// 显示全屏界面 } self.echartScreen.on('finished', function () { const legendDiv = document.getElementById('screenLegendArea' + self.chartIndex) diff --git a/nezha-fronted/src/components/charts/chart-single-stat.vue b/nezha-fronted/src/components/charts/chart-single-stat.vue index dd1d3bd9f..54e7fdedb 100644 --- a/nezha-fronted/src/components/charts/chart-single-stat.vue +++ b/nezha-fronted/src/components/charts/chart-single-stat.vue @@ -320,7 +320,7 @@ export default { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { // this.showLoading = false; - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, showLoad (chartItem) { diff --git a/nezha-fronted/src/components/charts/chart-table.vue b/nezha-fronted/src/components/charts/chart-table.vue index af073c882..3692aa24f 100644 --- a/nezha-fronted/src/components/charts/chart-table.vue +++ b/nezha-fronted/src/components/charts/chart-table.vue @@ -288,7 +288,7 @@ export default { if (area === 'screen') { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, resize (chartItem) { diff --git a/nezha-fronted/src/components/charts/chart-url.vue b/nezha-fronted/src/components/charts/chart-url.vue index 6675d0d41..13e349ed8 100644 --- a/nezha-fronted/src/components/charts/chart-url.vue +++ b/nezha-fronted/src/components/charts/chart-url.vue @@ -203,7 +203,7 @@ export default { if (area === 'screen') { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, clearChart () { diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index a7144f924..856bf5d35 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -1081,9 +1081,9 @@ export default { this.echartModalStore.resize() this.echartModalStore.clear() if (dataArg.length < 1) { - this.echartModalStore.setOption(chartConfig.getOption('noData')) + this.echartModalStore && this.echartModalStore.setOption(chartConfig.getOption('noData')) } else { - this.echartModalStore.setOption(option)// 创建图表 + this.echartModalStore && this.echartModalStore.setOption(option)// 创建图表 } this.$refs.loadingPreview.endLoading() @@ -1295,9 +1295,9 @@ export default { this.echartModalStore.resize() this.echartModalStore.clear() if (dataArg[0].data.length < 1) { - this.echartModalStore.setOption(chartConfig.getOption('noData')) + this.echartModalStore && this.echartModalStore.setOption(chartConfig.getOption('noData')) } else { - this.echartModalStore.setOption(option)// 创建图表 + this.echartModalStore && this.echartModalStore.setOption(option)// 创建图表 } this.$refs.loadingPreview.endLoading() @@ -1360,9 +1360,9 @@ export default { this.echartModalStore.resize() this.echartModalStore.clear() if (dataArg[0].data.length < 1) { - this.echartModalStore.setOption(chartConfig.getOption('noData')) + this.echartModalStore && this.echartModalStore.setOption(chartConfig.getOption('noData')) } else { - this.echartModalStore.setOption(option)// 创建图表 + this.echartModalStore && this.echartModalStore.setOption(option)// 创建图表 } this.$refs.loadingPreview.endLoading() diff --git a/nezha-fronted/src/components/charts/diagram-chart.vue b/nezha-fronted/src/components/charts/diagram-chart.vue index 2dad1e46d..1999e7b39 100644 --- a/nezha-fronted/src/components/charts/diagram-chart.vue +++ b/nezha-fronted/src/components/charts/diagram-chart.vue @@ -149,7 +149,7 @@ export default { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { // this.showLoading = false; - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, showLoad (chartItem) { diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index ecae03a5f..feb9742da 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -345,7 +345,7 @@ export default { this.caretShow = true if (getChart(this.chartIndex)) { setTimeout(() => { - getChart(this.chartIndex).setOption({ + getChart(this.chartIndex) && getChart(this.chartIndex).setOption({ toolbox: { show: true } @@ -357,7 +357,7 @@ export default { this.caretShow = false if (getChart(this.chartIndex)) { setTimeout(() => { - getChart(this.chartIndex).setOption({ + getChart(this.chartIndex) && getChart(this.chartIndex).setOption({ toolbox: { show: false } @@ -368,7 +368,7 @@ export default { mouseEnterFullChart () { if (this.echartModalStore) { setTimeout(() => { - this.echartModalStore.setOption({ + this.echartModalStore && this.echartModalStore.setOption({ toolbox: { show: true } @@ -380,7 +380,7 @@ export default { if (this.echartModalStore) { setTimeout(() => { if (this.echartModalStore) { - this.echartModalStore.setOption({ + this.echartModalStore && this.echartModalStore.setOption({ toolbox: { show: false } @@ -451,7 +451,7 @@ export default { if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { delete option.yAxis.maxInterval } - getChart(this.chartIndex).setOption({ + getChart(this.chartIndex) && getChart(this.chartIndex).setOption({ yAxis: { ...option.yAxis } @@ -567,7 +567,7 @@ export default { if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { delete option.yAxis.maxInterval } - echart.setOption({ + echart && echart.setOption({ yAxis: { ...option.yAxis } @@ -1259,12 +1259,12 @@ export default { } option.series = self.seriesItemArrScreen if (dataArg && dataArg.length > 0) { - self.echartModalStore.setOption(option)// 显示全屏界面 + self.echartModalStore && self.echartModalStore.setOption(option)// 显示全屏界面 self.noData = false } else { self.noData = true option = chartConfig.getOptionNoData('noData') - self.echartModalStore.setOption(option)// 显示全屏界面 + self.echartModalStore && self.echartModalStore.setOption(option)// 显示全屏界面 } self.echartModalStore.on('finished', function () { const legendDiv = document.getElementById('screenLegendArea' + self.chartIndex) @@ -1952,7 +1952,7 @@ export default { if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { delete option.yAxis.maxInterval } - getChart(this.chartIndex).setOption({ + getChart(this.chartIndex) && getChart(this.chartIndex).setOption({ series: this.seriesItem, yAxis: { ...option.yAxis @@ -1999,7 +1999,7 @@ export default { if (unit.type == 'Time' || option.yAxis.maxInterval === 1) { delete option.yAxis.maxInterval } - this.echartModalStore.setOption({ + this.echartModalStore && this.echartModalStore.setOption({ series: this.seriesItemScreen, yAxis: { ...option.yAxis @@ -2135,7 +2135,7 @@ export default { } else { minInterval = 20 * 60 * 1000 } - getChart(this.chartIndex).setOption({ xAxis: { minInterval: minInterval } }) + getChart(this.chartIndex) && getChart(this.chartIndex).setOption({ xAxis: { minInterval: minInterval } }) } else { if (this.$refs.resizeBox.offsetWidth < 200) { splitNumber = 1 @@ -2144,7 +2144,7 @@ export default { } else if (this.$refs.resizeBox.offsetWidth < 500) { splitNumber = 5 } - getChart(this.chartIndex).setOption({ xAxis: { splitNumber: splitNumber } }) + getChart(this.chartIndex) && getChart(this.chartIndex).setOption({ xAxis: { splitNumber: splitNumber } }) } } } diff --git a/nezha-fronted/src/components/charts/logs.vue b/nezha-fronted/src/components/charts/logs.vue index b7f9b03a0..1086e1fab 100644 --- a/nezha-fronted/src/components/charts/logs.vue +++ b/nezha-fronted/src/components/charts/logs.vue @@ -237,7 +237,7 @@ export default { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { // this.showLoading = false; - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, showLoad (chartItem) { diff --git a/nezha-fronted/src/components/charts/text-chart.vue b/nezha-fronted/src/components/charts/text-chart.vue index 34b9c22a0..bc723c9a3 100644 --- a/nezha-fronted/src/components/charts/text-chart.vue +++ b/nezha-fronted/src/components/charts/text-chart.vue @@ -147,7 +147,7 @@ export default { this.$refs['localLoadingScreen' + this.chartIndex].endLoading() } else { // this.showLoading = false; - this.$refs['localLoading' + this.chartIndex].endLoading() + this.$refs['localLoading' + this.chartIndex] && this.$refs['localLoading' + this.chartIndex].endLoading() } }, showLoad (chartItem) { diff --git a/nezha-fronted/src/components/cli/console.vue b/nezha-fronted/src/components/cli/console.vue index f72838b7c..6a05f2271 100644 --- a/nezha-fronted/src/components/cli/console.vue +++ b/nezha-fronted/src/components/cli/console.vue @@ -287,7 +287,7 @@ export default { this.terminalSocket.onclose = () => { // 报错sorry的,还没来得及看信息就关闭 // this.$emit("closeConsole",this.terminal.name);// - this.term.setOption('disableStdin', true) + this.term && this.term.setOption('disableStdin', true) } // 错误 @@ -319,7 +319,7 @@ export default { this.conFinish = false }, setFontSize (fontSize) { - this.term.setOption('fontSize', fontSize) + this.term && this.term.setOption('fontSize', fontSize) const consoleBox = document.getElementById('ternimalContainer' + this.idIndex) const width = document.body.clientWidth// 可视宽度 let height = parseInt(consoleBox.style.height) diff --git a/nezha-fronted/src/components/page/dashboard/overview/chart.vue b/nezha-fronted/src/components/page/dashboard/overview/chart.vue index dc3562b7e..dd482e051 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chart.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chart.vue @@ -90,7 +90,7 @@ export default { return this.chart.getOption() }, setOption: function (option) { - this.chart.setOption(option) + this.chart && this.chart.setOption(option) }, setSeries: function (series, legend, legendData) { if (!this.chart) { @@ -181,12 +181,12 @@ export default { if (this.option.series instanceof Array) { this.option.series = this.option.series.filter((item, index) => index < this.dataSize) } - this.chart.setOption(this.option) + this.chart && this.chart.setOption(this.option) } else { this.noData = true const option = chartConfig.getOption('noData') this.chart.clear() - this.chart.setOption(option) + this.chart && this.chart.setOption(option) } // 坐标轴label鼠标悬浮提示 @@ -543,7 +543,7 @@ export default { const option = { series: this.optionSeriesAll } - this.chart.setOption(option) + this.chart && this.chart.setOption(option) this.chart.resize() }, chartInit () { diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview.vue b/nezha-fronted/src/components/page/dashboard/overview/overview.vue index 87e1a6984..9e86fd094 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/overview.vue @@ -654,8 +654,8 @@ export default { ] prometheusOption.title.text = vm.$t('config.agent.agent.agent') prometheusOption.legend.data = [vm.$t('config.agent.up'), vm.$t('config.agent.down')] - tooltipEndpointChart.setOption(endpointOption, true) - tooltipPrometheusChart.setOption(prometheusOption, true) + tooltipEndpointChart && tooltipEndpointChart.setOption(endpointOption, true) + tooltipPrometheusChart && tooltipPrometheusChart.setOption(prometheusOption, true) }, 100) /* setTimeout(function() { tooltipEndpointChart.setOption(endpointOption); @@ -1168,7 +1168,7 @@ export default { const limit = geo[0].scaleLimit const value = zoom + val if (value <= limit.max && value >= limit.min) { - this.$refs.dataCenterMap.setOption({ geo: { zoom: value } }) + this.$refs.dataCenterMap && this.$refs.dataCenterMap.setOption({ geo: { zoom: value } }) } } }, diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue index 3d2f4622d..6a74988fb 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue @@ -1424,7 +1424,7 @@ export default { const limit = geo[0].scaleLimit const value = zoom + val if (value <= limit.max && value >= limit.min) { - this.$refs.dataCenterMap.setOption({ geo: { zoom: value } }) + this.$refs.dataCenterMap && this.$refs.dataCenterMap.setOption({ geo: { zoom: value } }) } } },