diff --git a/nezha-fronted/src/components/chart/chart/chartBar.vue b/nezha-fronted/src/components/chart/chart/chartBar.vue index 402d618a4..5d45d057f 100644 --- a/nezha-fronted/src/components/chart/chart/chartBar.vue +++ b/nezha-fronted/src/components/chart/chart/chartBar.vue @@ -112,6 +112,9 @@ export default { /* 使用setTimeout延迟渲染图表,避免样式错乱 */ setTimeout(() => { const myChart = this.isInit ? echarts.init(document.getElementById(`chart-canvas-${this.chartId}`)) : getChart(this.chartId) + if (!myChart) { + return + } myChart.setOption(chartOption) this.isInit && setChart(this.chartId, myChart) // 缓存;不使用vue的data是为避免整个chart被监听导致卡顿 this.isInit = false diff --git a/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue b/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue index 5ca786d99..06e527c55 100644 --- a/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue +++ b/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue @@ -57,6 +57,8 @@ export default { this.initHexagonData(this.chartInfo, this.chartData).then(() => { this.getLayout().then(layout => { this.initHexagon(layout) + }).catch(() => { + }) }) }, 200) @@ -331,9 +333,12 @@ export default { : '#FFFFFF' }, getLayout () { - this.boxWidth = this.$refs[`chart-canvas-${this.chartId}`].offsetWidth - 2 * this.boxPadding - this.boxHeight = this.$refs[`chart-canvas-${this.chartId}`].offsetHeight - 2 * this.boxPadding - return new Promise(resolve => { + return new Promise((resolve, reject) => { + if (!this.$refs[`chart-canvas-${this.chartId}`]) { + reject() + } + this.boxWidth = this.$refs[`chart-canvas-${this.chartId}`].offsetWidth - 2 * this.boxPadding + this.boxHeight = this.$refs[`chart-canvas-${this.chartId}`].offsetHeight - 2 * this.boxPadding let radius = 0 let col = 0 let row = 0 @@ -384,6 +389,8 @@ export default { this.hexagonTimer = setTimeout(() => { this.getLayout().then(layout => { this.initHexagon(layout) + }).catch(() => { + }) }, 50) } diff --git a/nezha-fronted/src/components/chart/chart/chartPie.vue b/nezha-fronted/src/components/chart/chart/chartPie.vue index 3b8fd0fab..f3a2d7057 100644 --- a/nezha-fronted/src/components/chart/chart/chartPie.vue +++ b/nezha-fronted/src/components/chart/chart/chartPie.vue @@ -89,6 +89,9 @@ export default { /* 使用setTimeout延迟渲染图表,避免样式错乱 */ setTimeout(() => { const myChart = this.isInit ? echarts.init(document.getElementById(`chart-canvas-${this.chartId}`)) : getChart(this.chartId) + if (!myChart) { + return + } myChart.setOption(chartOption) this.isInit && setChart(this.chartId, myChart) // 缓存;不使用vue的data是为避免整个chart被监听导致卡顿 this.isInit = false diff --git a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue index d2b2ad3e1..77d408b6f 100644 --- a/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/chartTimeSeries.vue @@ -93,6 +93,9 @@ export default { /* 使用setTimeout延迟渲染图表,避免样式错乱 */ setTimeout(() => { const myChart = this.isInit ? echarts.init(document.getElementById(`chart-canvas-${this.chartId}`)) : getChart(this.chartId) + if (!myChart) { + return + } myChart.setOption(chartOption) this.isInit && setChart(this.chartId, myChart) // 缓存;不使用vue的data是为避免整个chart被监听导致卡顿 this.isInit = false diff --git a/nezha-fronted/src/components/chart/chart/chartTreemap.vue b/nezha-fronted/src/components/chart/chart/chartTreemap.vue index 3137d16cb..f43004259 100644 --- a/nezha-fronted/src/components/chart/chart/chartTreemap.vue +++ b/nezha-fronted/src/components/chart/chart/chartTreemap.vue @@ -86,6 +86,9 @@ export default { /* 使用setTimeout延迟渲染图表,避免样式错乱 */ setTimeout(() => { const myChart = this.isInit ? echarts.init(document.getElementById(`chart-canvas-${this.chartId}`)) : getChart(this.chartId) + if (!myChart) { + return + } myChart.setOption(chartOption) this.isInit && setChart(this.chartId, myChart) // 缓存;不使用vue的data是为避免整个chart被监听导致卡顿 this.isInit = false diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 196a5da18..d748acfa2 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -1796,6 +1796,9 @@ export default { this.imgageLoading = true this.$get('monitor/project/topo/icon').then((imageAllId) => { const promiseArr = [] + if (!imageAllId || !imageAllId.data) { + return + } imgidList.forEach((item, index) => { if (item.data.imageId && imageAllId.data.list.find(image => item.data.imageId === image.id)) { promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.data.imageId}/1`)) diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index d9d46af89..da74ed855 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -798,6 +798,9 @@ export default { resolve(this.topoPrevDataS) } this.$get('monitor/project/topo', { projectId: this.obj.id }).then(res => { + if (!res.data) { + return + } let data = res.data.topo if (!res.data.topo || !res.data.topo.pens.length) { this.showNoData = true @@ -1772,6 +1775,9 @@ export default { this.imgageLoading = true this.$get('monitor/project/topo/icon').then((imageAllId) => { const promiseArr = [] + if (!imageAllId || !imageAllId.data) { + return + } imgidList.forEach((item, index) => { if (item.data.imageId && imageAllId.data.list.find(image => item.data.imageId === image.id)) { promiseArr.push(this.dealImg(`monitor/project/topo/icon/${item.data.imageId}/1`)) diff --git a/nezha-fronted/src/components/layout/home.vue b/nezha-fronted/src/components/layout/home.vue index 1a2dbb474..557ed36dc 100644 --- a/nezha-fronted/src/components/layout/home.vue +++ b/nezha-fronted/src/components/layout/home.vue @@ -40,13 +40,7 @@ export default { }, methods: { refresh () { - this.containerShow = false - new Promise(resolve => { - this.$router.replace({ path: this.$route.path, query: {} }) - resolve() - }).then(() => { - this.$nextTick(() => { this.containerShow = true }) - }) + this.$store.commit('setIsRouteLive') } }, destroyed () { diff --git a/nezha-fronted/src/components/layout/leftMenu.vue b/nezha-fronted/src/components/layout/leftMenu.vue index c68b4bb6a..c2332acf0 100644 --- a/nezha-fronted/src/components/layout/leftMenu.vue +++ b/nezha-fronted/src/components/layout/leftMenu.vue @@ -82,6 +82,7 @@ export default { }, methods: { jump (route) { + console.log(route, this.route) if (route === this.route) { this.refresh() } diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 3f74917f0..693a39eab 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -442,7 +442,12 @@ export default { this.chart = JSON.parse(JSON.stringify(chartData)) this.chart.panelId = this.showPanel.id this.chart.panelName = this.showPanel.name - this.chart.param = JSON.parse(this.chart.param) + if (this.chart.param) { + this.chart.param = JSON.parse(this.chart.param) + } else { + this.chart.param = {} + } + if (!this.chart.groupId || this.chart.groupId == -1) { this.chart.groupId = '' } @@ -856,7 +861,9 @@ export default { this.nowTimeType.start_time = this.searchTime[0] this.nowTimeType.end_time = this.searchTime[1] setTimeout(() => { - this.$refs.pickTime.$refs.timePicker.setCustomTime(this.nowTimeType) + if (this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker) { + this.$refs.pickTime.$refs.timePicker.setCustomTime(this.nowTimeType) + } }, 100) } },