From e2652c9dc6af6f4aced4d1bfa18752b431d7273a Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 20 Jul 2023 18:02:58 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=A4=84=E7=90=86=20=E5=9B=A0?= =?UTF-8?q?=E4=B8=BAurl=20=E4=BC=98=E5=85=88=E7=BA=A7=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=20=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=20=E4=BB=A5=E5=8F=8A=20=20?= =?UTF-8?q?=20group=20=E5=86=85=E9=83=A8=20=E6=97=B6=E9=97=B4=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/panelChart.vue | 6 +++- .../common/bottomBox/tabs/dashboardTab.vue | 20 ++++++++----- .../common/bottomBox/tabs/logBottomTab.vue | 16 +++++----- .../src/components/common/timePicker.vue | 2 +- .../components/page/dashboard/dashboard.vue | 30 +++++++++++-------- .../page/dashboard/explore/exploreItem.vue | 18 ++++++----- nezha-fronted/src/store/timePicker.js | 1 + 7 files changed, 57 insertions(+), 36 deletions(-) diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index fe2df651d..f674d674e 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -111,6 +111,10 @@ export default { type: Boolean, default: true }, + timerInit: { + type: Boolean, + default: true + }, hiddenText: { // 隐藏图表的悬浮文字 type: String } @@ -165,7 +169,7 @@ export default { }, // 参数 isRefresh 标识是否是刷新操作 getChartData (isRefresh, params) { // 获取chart的数据前的准备 主要用于处理时间参数 - if (!this.variablesInit) { // 变量未加载完成 不请求数据 + if (!this.variablesInit || !this.timerInit) { // 变量未加载完成 不请求数据 return } this.chartData = window.dataJson ? this.chartData : [] diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue index 671750f1c..05e7b8970 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue @@ -608,6 +608,10 @@ export default { this.$set(this.searchTime, 2, val + 'd') } this.$refs.pickTime.$refs.timePicker.searchTime = this.searchTime + this.$store.dispatch('dispatchPanelTime', { + time: this.searchTime, + nowTimeType: this.nowTimeType + }) }, getVarType (from) { if (from === this.fromRoute.asset) { @@ -868,13 +872,15 @@ export default { }) }, setTimePickerRange () { - if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { - this.setDefaultTimeRange() - } - const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType - this.searchTime = this.timePickerRange.time - this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.searchTime) - this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + this.$nextTick(() => { + if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { + this.setDefaultTimeRange() + } + const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType + this.searchTime = this.timePickerRange.time + this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.searchTime) + this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + }) }, // 设置默认刷新 setDefaultRefresh () { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue index 1a7aeb9b7..9cc2e7edb 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue @@ -137,13 +137,15 @@ export default { this.queryLogData() }, setTimePickerRange () { - if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { - return - } - const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType - this.filterTime = this.timePickerRange.time - this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.filterTime) - this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + this.$nextTick(() => { + if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { + return + } + const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType + this.filterTime = this.timePickerRange.time + this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.filterTime) + this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + }) }, setSearchTime (type, val) { // 设置searchTime if (type === 'minute') { diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue index d30a35688..50e219f2b 100644 --- a/nezha-fronted/src/components/common/timePicker.vue +++ b/nezha-fronted/src/components/common/timePicker.vue @@ -28,7 +28,7 @@
{ + console.log(13123213,this.timePickerLocked, this.timePickerRange.nowTimeType) + if (this.$route.query.searchTime) return + if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { + this.setDefaultTimeRange() + } + const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType + this.searchTime = this.timePickerRange.time + this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.searchTime) + this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + }) }, // 设置默认刷新 setDefaultRefresh () { @@ -1189,10 +1193,12 @@ export default { mode: { target: this, propertyName: 'mode', type: 'string' } } this.initQueryFromPath(searchKeys) - this.$store.dispatch('dispatchTimePickerRange', { - time: this.searchTime, - nowTimeType: this.nowTimeType - }) + if (this.$route.query.searchTime) { + this.$store.dispatch('dispatchTimePickerRange', { + time: this.searchTime, + nowTimeType: this.nowTimeType + }) + } this.showPanel.id = this.dashboardId this.filter.dashboardId = this.dashboardId // 设置查看模式 diff --git a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue index 42d8dc9b2..fbca9f952 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue @@ -3589,14 +3589,16 @@ export default { dom.querySelector(id).scrollIntoView(true) }, setTimePickerRange () { - console.log(this.timePickerLocked, !this.timePickerRange.nowTimeType) - if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { - return - } - const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType - this.filterTime = this.timePickerRange.time - this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.filterTime) - this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + this.$nextTick(() => { + console.log(this.timePickerLocked, !this.timePickerRange.nowTimeType) + if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { + return + } + const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType + this.filterTime = this.timePickerRange.time + this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.filterTime) + this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + }) }, selectMetricsLogs (val, icon, label) { if (val) { diff --git a/nezha-fronted/src/store/timePicker.js b/nezha-fronted/src/store/timePicker.js index 9dcc8cfbd..bc6afd612 100644 --- a/nezha-fronted/src/store/timePicker.js +++ b/nezha-fronted/src/store/timePicker.js @@ -25,6 +25,7 @@ const timePicker = { store.commit('setTimePickerLocked', flag) }, dispatchTimePickerRange (store, range) { + console.log('dispatchTimePickerRange', range) store.commit('setTimePickerRange', range) } }