diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index befb66efc..b7ca9dc82 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -243,7 +243,7 @@ export default { fromTopo: { type: Boolean, default: false - }, + } }, computed: { getButtonCode () { @@ -945,7 +945,25 @@ export default { delete option.yAxis.maxInterval } if (this.fromTopo) { - option.xAxis.minInterval = 20 * 60 * 1000 + const panelTime = localStorage.getItem('panelTime') ? JSON.parse(localStorage.getItem('panelTime')) : ['', ''] + if (panelTime[0]) { + const numInterval = new Date(panelTime[1]).getTime() - new Date(panelTime[0]).getTime() + console.log(numInterval) + + if (numInterval >= 60 * 60 * 1000) { + option.xAxis.minInterval = 20 * 60 * 1000 + } else if (numInterval >= 30 * 60 * 1000 && numInterval < 60 * 60 * 1000) { + option.xAxis.minInterval = 10 * 60 * 1000 + } else if (numInterval >= 15 * 60 * 1000 && numInterval < 30 * 60 * 1000) { + option.xAxis.minInterval = 5 * 60 * 1000 + } else if (numInterval >= 5 * 60 * 1000 && numInterval < 15 * 60 * 1000) { + option.xAxis.minInterval = 1 * 60 * 1000 + } else { + option.xAxis.minInterval = 15 * 1000 + } + } else { + option.xAxis.minInterval = 20 * 60 * 1000 + } } // params.series = dataArg; if (chartSite === 'local') { // 本地显示 diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 55cbe021c..b25910660 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -661,8 +661,9 @@ export default { }) }) } - const endTime = this.filterTime[1] - const startTime = this.filterTime[0] + const panelTime = localStorage.getItem('panelTime') ? JSON.parse(localStorage.getItem('panelTime')) : ['', ''] + const endTime = panelTime[1] || this.filterTime[1] + const startTime = panelTime[0] || this.filterTime[0] const step = bus.getStep(startTime, endTime) data.pens && data.pens.forEach((item, index) => { this.chartGetData.push({ id: item.id, res: [] }) diff --git a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue index c8de4441f..db2e7bae2 100644 --- a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue +++ b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue @@ -128,8 +128,9 @@ export default { } }) } else { - const endTime = this.filter.end_time - const startTime = this.filter.start_time + const panelTime = localStorage.getItem('panelTime') ? JSON.parse(localStorage.getItem('panelTime')) : ['', ''] + const endTime = panelTime[1] || bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') + const startTime = panelTime[0] || bus.timeFormate(bus.getOffsetTimezoneData(-1), 'yyyy-MM-dd hh:mm:ss') const step = bus.getStep(startTime, endTime) this.$nextTick(() => { const axiosArr = chartItem.elements.map((ele) => { diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 40f2ce5bc..a27ae279a 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -826,6 +826,13 @@ export default { temp.search() }, 1000) }, + searchTime: { + immediate: true, + deep: true, + handler (n) { + localStorage.setItem('panelTime', JSON.stringify(n)) + } + }, $route: { immediate: true, handler () { @@ -852,6 +859,7 @@ export default { if (this.scrollbarWrap) { this.scrollbarWrap.removeEventListener('scroll', bus.debounce) }; + localStorage.removeItem('panelTime') } }