From f297983554b2fa24d2311726905a4a4f4ce8aa29 Mon Sep 17 00:00:00 2001 From: "@changcode" Date: Fri, 31 Dec 2021 10:10:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/pickTime.vue | 7 +++--- .../src/components/common/timePicker.vue | 22 +++++-------------- nezha-fronted/src/libs/bus.js | 2 +- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/nezha-fronted/src/components/common/pickTime.vue b/nezha-fronted/src/components/common/pickTime.vue index b28585ae0..5ed4d7fb3 100644 --- a/nezha-fronted/src/components/common/pickTime.vue +++ b/nezha-fronted/src/components/common/pickTime.vue @@ -80,7 +80,8 @@ export default { theme: { themeColor: '' }, - timer: '' + timer: '', + pickTimer: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss', } }, created () { @@ -135,8 +136,8 @@ export default { if (timeRange && timeRange.length < 2) { return [] } - const startTime = bus.timeFormate(timeRange[0], 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(timeRange[1], 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(timeRange[0], this.pickTimer) + const endTime = bus.timeFormate(timeRange[1], this.pickTimer) return [startTime, endTime] }, dateChange (time) { diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue index 30c34fe90..8b8c27772 100644 --- a/nezha-fronted/src/components/common/timePicker.vue +++ b/nezha-fronted/src/components/common/timePicker.vue @@ -68,7 +68,10 @@ export default { isPopoverDisabled: false, isCustom: false, timePicker: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss', - searchTime: [], + searchTime: [ + bus.timeFormate(bus.getOffsetTimezoneData(-1), this.timePicker), + bus.timeFormate(bus.getOffsetTimezoneData(), this.timePicker) + ], showTime: { id: 4, text: this.$t('dashboard.panel.lastOneHour') @@ -308,22 +311,7 @@ export default { } } } - }, - stepSearchTime: { - immediate: true, - handler (n, o) { - if (n && this.searchTime[0]) { - if (this.showTime.value) { - this.setSearchTime(this.showTime.type, this.showTime.value) - } else { - const startTime = bus.timeFormate(this.searchTime[0], this.timePicker) - const endTime = bus.timeFormate(new Date(this.searchTime[0]).getTime() + new Date(this.stepSearchTime[1]).getTime() - new Date(this.stepSearchTime[0]).getTime(), this.timePicker) - this.$set(this.searchTime, 0, startTime) - this.$set(this.searchTime, 1, endTime) - } - } - } - }, + } } } diff --git a/nezha-fronted/src/libs/bus.js b/nezha-fronted/src/libs/bus.js index 807be1cfb..d3cea6702 100644 --- a/nezha-fronted/src/libs/bus.js +++ b/nezha-fronted/src/libs/bus.js @@ -294,7 +294,7 @@ export default new Vue({ getNewTime (time, num) { const date = new Date(time) const newDate = new Date(parseInt(date.getTime(), 10) + num) - return this.timeFormate(newDate, 'yyyy-MM-dd hh:mm:ss') + return this.timeFormate(newDate, localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') }, getOffsetTimezoneData (offset = 0) { return new Date(this.computeTimezone(new Date().getTime())).setHours(new Date(this.computeTimezone(new Date().getTime())).getHours() + offset)