diff --git a/nezha-fronted/src/components/chart/chartList.vue b/nezha-fronted/src/components/chart/chartList.vue index bc3a280ac..5c2105477 100644 --- a/nezha-fronted/src/components/chart/chartList.vue +++ b/nezha-fronted/src/components/chart/chartList.vue @@ -359,7 +359,10 @@ export default { this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].groupShow(item.param.collapse) this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].$refs.chart && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id] && this.$refs['chart' + item.id][0].$refs.chart.$refs['chart' + item.id].$refs.chartList.resize() } - this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].resize() + try { + this.$refs['chart' + item.id][0] && this.$refs['chart' + item.id][0].resize() + } catch (error) { + } }) }, refreshPanel () { @@ -448,10 +451,10 @@ export default { // 监听查看模式变化 '$store.state.panel.mode': { immediate: true, - handler () { + handler (val) { setTimeout(() => { this.resize() - }, 100) + }, 200) } }, dataList: { diff --git a/nezha-fronted/src/components/common/deleteButton.vue b/nezha-fronted/src/components/common/deleteButton.vue index 854fdc7ae..dc17fd1ef 100644 --- a/nezha-fronted/src/components/common/deleteButton.vue +++ b/nezha-fronted/src/components/common/deleteButton.vue @@ -10,6 +10,7 @@ diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue index 3b8eb33c6..7d9dd74ba 100644 --- a/nezha-fronted/src/components/common/timePicker.vue +++ b/nezha-fronted/src/components/common/timePicker.vue @@ -92,9 +92,9 @@ class="date-range-history-item" @click="historyChange(item)" > - {{ timeFormate(item.start) }} + {{ momentTz(item.start) }} {{ $t("dashboard.panel.to") }} - {{ timeFormate(item.end) }} + {{ momentTz(item.end) }} @@ -340,8 +340,8 @@ export default { } this.isCustom = true this.rangeHistory.unshift({ - start: item[0], - end: item[1] + start: this.momentStrToTimestamp(item[0]), + end: this.momentStrToTimestamp(item[1]) }) localStorage.setItem( 'date-range-history' + this.sign, diff --git a/nezha-fronted/src/entrance/exportHtml/App.vue b/nezha-fronted/src/entrance/exportHtml/App.vue index b4928343c..ce3feb569 100644 --- a/nezha-fronted/src/entrance/exportHtml/App.vue +++ b/nezha-fronted/src/entrance/exportHtml/App.vue @@ -14,7 +14,7 @@
{{dataJson.panel.data.name}}
- {{timeFormate(dataJson.start * 1000)}} - {{timeFormate(dataJson.end * 1000)}} + {{dateFormat(dataJson.start * 1000)}} - {{dateFormat(dataJson.end * 1000)}} ({{dataJson.timezone}})
@@ -50,7 +50,6 @@ import chartList from '@/components/chart/chartList.vue' import moment from 'moment-timezone' import { loadI18n } from '@/components/common/i18n' import i18nData from '@/entrance/exportHtml/i18nData' - const dataJson = window.dataJson || {} export default { name: 'Entrance', @@ -67,7 +66,8 @@ export default { created () { this.$i18n.locale = this.dataJson.language loadI18n(i18nData) - const localOffset = moment.tz.guess()// 默认 一分钟显示时区偏移的结果 + const localOffset = this.dataJson.timezone || moment.tz.guess() + this.dataJson.timezone = localOffset localStorage.setItem('nz-sys-timezone', localOffset) }, mounted () { @@ -78,7 +78,13 @@ export default { delChart () {}, addGroupItem () {}, chartListLoading () {}, - refreshPanel () {} + refreshPanel () {}, + // 时间戳转为UTC格式 + dateFormat (time) { + let offset = localStorage.getItem('nz-sys-timezone') + offset = moment.tz(offset).format('Z') + return moment(time).utcOffset(offset).format() + } } }