diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index 9406967a8..e43507824 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -130,6 +130,7 @@ export default { // 参数 isRefresh 标识是否是刷新操作 getChartData (isRefresh) { this.loading = true + console.log(this.timeRange) // TODO assetInfo、endpointInfo、echarts等进行不同的处理 let startTime = '' let endTime = '' @@ -138,15 +139,15 @@ export default { const origin = new Date(this.timeRange[1]) const numInterval = now.getTime() - origin.getTime() if (numInterval >= 60000) { // 大于1分钟,则start、end均往后移numInterval,否则时间不变 - startTime = bus.getNewTime(this.timeRange[0], numInterval) - endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') + startTime = bus.getNewTime(bus.formateTimeToTime(this.timeRange[0]), numInterval) + endTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss') } else { - startTime = this.timeRange[0] - endTime = this.timeRange[1] + startTime = bus.formateTimeToTime(this.timeRange[0]) + endTime = bus.formateTimeToTime(this.timeRange[1]) } } else { - startTime = this.timeRange[0] - endTime = this.timeRange[1] + startTime = bus.formateTimeToTime(this.timeRange[0]) + endTime = bus.formateTimeToTime(this.timeRange[1]) } const step = bus.getStep(startTime, endTime) startTime = this.$stringTimeParseToUnix(startTime) diff --git a/nezha-fronted/src/components/charts/chart-alert-list.vue b/nezha-fronted/src/components/charts/chart-alert-list.vue index dfa0418f4..c20dcc758 100644 --- a/nezha-fronted/src/components/charts/chart-alert-list.vue +++ b/nezha-fronted/src/components/charts/chart-alert-list.vue @@ -892,8 +892,8 @@ export default { }, // 全屏时间条件查询 dateChange (time) { - // this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss'); - // this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss'); + // this.filter.start_time = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss'); + // this.filter.end_time = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss'); // this.showTable = false; this.seriesItemScreen = [] for (let i = 0; i < 8; i++) { @@ -1113,8 +1113,8 @@ export default { this.dialogText = row.alertRule.trbShot }, addSilence (row, type) { - this.blankSilenceObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') - this.blankSilenceObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'yyyy-MM-dd hh:mm:ss') + this.blankSilenceObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') + this.blankSilenceObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'YYYY-MM-DD HH:mm:ss') this.objectSilence = JSON.parse(JSON.stringify(this.blankSilenceObject)) this.objectSilence.name = 'Quick silence' if (type !== 'alertMessage' && type !== 'alertRule') { diff --git a/nezha-fronted/src/components/charts/chart-list-group.vue b/nezha-fronted/src/components/charts/chart-list-group.vue index da9f7ecd8..7cb49eb21 100644 --- a/nezha-fronted/src/components/charts/chart-list-group.vue +++ b/nezha-fronted/src/components/charts/chart-list-group.vue @@ -688,7 +688,7 @@ export default { const numInterval = now.getTime() - origin.getTime() if (numInterval >= 60000) { // 大于1分钟,则start、end均往后移numInterval,否则时间不变 startTime = this.getNewTime(this.filter.start_time, numInterval) - endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') + endTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss') } else { startTime = this.filter.start_time endTime = this.filter.end_time @@ -895,7 +895,7 @@ export default { } */ // let t_date = new Date(dpsItem[0] * 1000); - // let timeTmp = bus.timeFormate(t_date, 'yyyy-MM-dd hh:mm:ss'); + // let timeTmp = bus.timeFormate(t_date, 'YYYY-MM-DD HH:mm:ss'); tableData.push({ // 表格数据 // label: host.slice(host.indexOf('{') + 1,host.indexOf('}')),//label // metric: queryItem.metric.__name__?queryItem.metric.__name__:'',//metric列 @@ -1122,7 +1122,7 @@ export default { // alert('table=='+JSON.stringify(queryItem)) seriesItem.theData.data = tempArr.map((dpsItem, dpsIndex) => { const tData = new Date(dpsItem[0] * 1000) - const timeTmp = bus.timeFormate(tData, 'yyyy-MM-dd hh:mm:ss') + const timeTmp = bus.timeFormate(tData, 'YYYY-MM-DD HH:mm:ss') tableData.push({ // 表格数据 // label: host.slice(host.indexOf('{') + 1,host.indexOf('}')),//label // metric: queryItem.metric.__name__?queryItem.metric.__name__:'',//metric列 @@ -1195,8 +1195,8 @@ export default { const basicInfo = JSON.parse(JSON.stringify(this.detail)) const basicInfoReq = new Promise((resolve, reject) => { const now = new Date() - const startTime = bus.timeFormate(new Date(now).setHours(now.getHours() - 1), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(now).setHours(now.getHours() - 1), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss') // const step = bus.getStep(startTime, endTime) this.$nextTick(() => { let query = encodeURIComponent(chartInfo.elements[0].expression) @@ -1466,7 +1466,7 @@ export default { getNewTime (time, num) { const date = new Date(time) const newDate = new Date(parseInt(date.getTime(), 10) + num) - return bus.timeFormate(newDate, 'yyyy-MM-dd hh:mm:ss') + return bus.timeFormate(newDate, 'YYYY-MM-DD HH:mm:ss') }, // 删除图表 removeChart (chartId) { // from 区分从哪里点击的删除 1.从图表面板 2.从编辑框 @@ -1523,8 +1523,8 @@ export default { }, searchData (chartId, searchTime) { if (searchTime) { // 全屏时间查询 - this.filter.start_time = bus.timeFormate(searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filter.end_time = bus.timeFormate(searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filter.start_time = bus.timeFormate(searchTime[0], 'YYYY-MM-DD HH:mm:ss') + this.filter.end_time = bus.timeFormate(searchTime[1], 'YYYY-MM-DD HH:mm:ss') } this.dataList.forEach((item, index) => { if (item.id === chartId) { diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 150fa9d58..a8063ae1e 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -607,8 +607,8 @@ export default { type: '' }] }) - this.$set(this.filter, 'start_time', bus.timeFormate(new Date().getTime() - 24 * 60 * 60 * 1000, 'yyyy-MM-dd hh:mm:ss')) - this.$set(this.filter, 'end_time', bus.timeFormate(new Date().getTime(), 'yyyy-MM-dd hh:mm:ss')) + this.$set(this.filter, 'start_time', bus.timeFormate(new Date().getTime() - 24 * 60 * 60 * 1000, 'YYYY-MM-DD HH:mm:ss')) + this.$set(this.filter, 'end_time', bus.timeFormate(new Date().getTime(), 'YYYY-MM-DD HH:mm:ss')) this.$nextTick(() => { this.dataList.forEach((item, index) => { this.$set(item, 'from', params.from) @@ -910,7 +910,7 @@ export default { const numInterval = now.getTime() - origin.getTime() if (numInterval >= 60000) { // 大于1分钟,则start、end均往后移numInterval,否则时间不变 startTime = this.getNewTime(this.filter.start_time, numInterval) - endTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') + endTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss') this.filter.start_time = startTime this.filter.end_time = endTime } else { @@ -1118,7 +1118,7 @@ export default { } */ // let t_date = new Date(dpsItem[0] * 1000); - // let timeTmp = bus.timeFormate(t_date, 'yyyy-MM-dd hh:mm:ss'); + // let timeTmp = bus.timeFormate(t_date, 'YYYY-MM-DD HH:mm:ss'); tableData.push({ // 表格数据 // label: host.slice(host.indexOf('{') + 1,host.indexOf('}')),//label // metric: queryItem.metric.__name__?queryItem.metric.__name__:'',//metric列 @@ -1349,7 +1349,7 @@ export default { // alert('table=='+JSON.stringify(queryItem)) seriesItem.theData.data = tempArr.map((dpsItem, dpsIndex) => { const tData = new Date(dpsItem[0] * 1000) - const timeTmp = bus.timeFormate(tData, 'yyyy-MM-dd hh:mm:ss') + const timeTmp = bus.timeFormate(tData, 'YYYY-MM-DD HH:mm:ss') tableData.push({ // 表格数据 // label: host.slice(host.indexOf('{') + 1,host.indexOf('}')),//label // metric: queryItem.metric.__name__?queryItem.metric.__name__:'',//metric列 @@ -1687,7 +1687,7 @@ export default { getNewTime (time, num) { const date = new Date(time) const newDate = new Date(parseInt(date.getTime(), 10) + num) - return bus.timeFormate(newDate, 'yyyy-MM-dd hh:mm:ss') + return bus.timeFormate(newDate, 'YYYY-MM-DD HH:mm:ss') }, // 删除图表 removeChart (chartId) { // from 区分从哪里点击的删除 1.从图表面板 2.从编辑框 @@ -1759,8 +1759,8 @@ export default { }, searchData (chartId, searchTime) { if (searchTime) { // 全屏时间查询 - this.filter.showFullScreenStart_time = bus.timeFormate(searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filter.showFullScreenEnd_time = bus.timeFormate(searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filter.showFullScreenStart_time = bus.timeFormate(searchTime[0], 'YYYY-MM-DD HH:mm:ss') + this.filter.showFullScreenEnd_time = bus.timeFormate(searchTime[1], 'YYYY-MM-DD HH:mm:ss') } this.dataList.forEach((item, index) => { if (item.id === chartId) { diff --git a/nezha-fronted/src/components/charts/chart-table.vue b/nezha-fronted/src/components/charts/chart-table.vue index 3013c9467..ce3f0702a 100644 --- a/nezha-fronted/src/components/charts/chart-table.vue +++ b/nezha-fronted/src/components/charts/chart-table.vue @@ -204,7 +204,7 @@ export default { title: '采集时间', key: 'time', width: 160, - render: (h, params) => h('span', bus.timeFormate(params.row.time, 'yyyy-MM-dd hh:mm:ss')) + render: (h, params) => h('span', bus.timeFormate(params.row.time, 'YYYY-MM-DD HH:mm:ss')) }, { title: '数值', key: 'value', @@ -461,7 +461,7 @@ export default { result = copy.map(item => { return { element: item.element, - time: bus.timeFormate(new Date(item.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(item.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: item.data[1] } }) @@ -475,7 +475,7 @@ export default { return { element: groupMin.element, - time: bus.timeFormate(new Date(groupMin.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(groupMin.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: groupMin.data[1] } }) @@ -489,7 +489,7 @@ export default { return { element: groupMax.element, - time: bus.timeFormate(new Date(groupMax.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(groupMax.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: groupMax.data[1] } }) @@ -505,7 +505,7 @@ export default { })[0] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: avg } }) @@ -520,7 +520,7 @@ export default { })[0] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: total } }) @@ -534,7 +534,7 @@ export default { return { element: first.element, - time: bus.timeFormate(new Date(first.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(first.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: first.data[1] } }) @@ -547,7 +547,7 @@ export default { })[0] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: last.data[1] } }) @@ -566,7 +566,7 @@ export default { const range = max.data[1] - min.data[1] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: range } }) @@ -581,7 +581,7 @@ export default { const first = sort[copy.length - 1] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: last.data[1] - first.data[1] } }) @@ -593,7 +593,7 @@ export default { result = copy.map(item => { return { element: item.element, - time: bus.timeFormate(new Date(item.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(item.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: item.data[1] } }) diff --git a/nezha-fronted/src/components/charts/chartDataFormat.js b/nezha-fronted/src/components/charts/chartDataFormat.js index 677eb377b..691d58d20 100644 --- a/nezha-fronted/src/components/charts/chartDataFormat.js +++ b/nezha-fronted/src/components/charts/chartDataFormat.js @@ -392,7 +392,7 @@ function timeCompute (value, unit, dot = 0) { } function timeFormat34 (value) { - return bus.timeFormate(parseInt(value), 'yyyy-MM-dd hh:mm:ss') + return bus.timeFormate(parseInt(value), 'YYYY-MM-DD HH:mm:ss') } function timeFormat35 (value) { return bus.timeFormate(parseInt(value), 'MM/dd/yyyy h:mm:ss a') diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index 899b4d507..c98efa7d4 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -351,12 +351,12 @@ export default { } }) } else { - let startTime = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - let endTime = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + let startTime = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + let endTime = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') if (!startTime || !endTime) { // 如果时间为空,则默认取最近1小时 const now = new Date(bus.computeTimezone(new Date().getTime())) - startTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') - endTime = bus.timeFormate(now.setHours(now.getHours() - 1), 'yyyy-MM-dd hh:mm:ss') + startTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss') + endTime = bus.timeFormate(now.setHours(now.getHours() - 1), 'YYYY-MM-DD HH:mm:ss') this.searchTime[0] = startTime this.searchTime[1] = endTime } @@ -530,7 +530,7 @@ export default { // alert('table=='+JSON.stringify(queryItem)) seriesItem.theData.data = queryItem.values.map((dpsItem, dpsIndex) => { // const tData = new Date(dpsItem[0] * 1000) - // const timeTmp = bus.timeFormate(tData, 'yyyy-MM-dd hh:mm:ss') + // const timeTmp = bus.timeFormate(tData, 'YYYY-MM-DD HH:mm:ss') tableData.push({ // 表格数据 // label: host.slice(host.indexOf('{') + 1,host.indexOf('}')),//label // metric: queryItem.metric.__name__?queryItem.metric.__name__:'',//metric列 @@ -1415,7 +1415,7 @@ export default { result = copy.map(item => { return { element: item.element, - time: bus.timeFormate(new Date(item.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(item.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: item.data[1] } }) @@ -1429,7 +1429,7 @@ export default { return { element: groupMin.element, - time: bus.timeFormate(new Date(groupMin.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(groupMin.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: groupMin.data[1] } }) @@ -1443,7 +1443,7 @@ export default { return { element: groupMax.element, - time: bus.timeFormate(new Date(groupMax.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(groupMax.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: groupMax.data[1] } }) @@ -1459,7 +1459,7 @@ export default { })[0] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: avg } }) @@ -1474,7 +1474,7 @@ export default { })[0] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: total } }) @@ -1488,7 +1488,7 @@ export default { return { element: first.element, - time: bus.timeFormate(new Date(first.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(first.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: first.data[1] } }) @@ -1501,7 +1501,7 @@ export default { })[0] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: last.data[1] } }) @@ -1520,7 +1520,7 @@ export default { const range = max.data[1] - min.data[1] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: range } }) @@ -1535,7 +1535,7 @@ export default { const first = sort[copy.length - 1] return { element: last.element, - time: bus.timeFormate(new Date(last.data[0]), 'yyyy-MM-dd hh:mm:ss'), + time: bus.timeFormate(new Date(last.data[0]), 'YYYY-MM-DD HH:mm:ss'), value: last.data[1] - first.data[1] } }) @@ -1606,12 +1606,12 @@ export default { let axiosArr = [] const chartItem = this.chart this.$nextTick(() => { - let startTime = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - let endTime = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + let startTime = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + let endTime = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') if (!startTime || !endTime) { // 如果时间为空,则默认取最近1小时 const now = new Date() - startTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') - endTime = bus.timeFormate(now.setHours(now.getHours() - 1), 'yyyy-MM-dd hh:mm:ss') + startTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss') + endTime = bus.timeFormate(now.setHours(now.getHours() - 1), 'YYYY-MM-DD HH:mm:ss') this.searchTime[0] = startTime this.searchTime[1] = endTime } diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 74bb77382..5c20ef9d2 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -1613,8 +1613,8 @@ export default { dateChange (time) { const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) - this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filter.start_time = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + this.filter.end_time = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') this.filter.value = this.searchTime[2] this.filter.id = this.$refs.pickTime.$refs.timePicker.showTime.id // this.echartModalStore.clear() @@ -1628,20 +1628,20 @@ export default { }, setSearchTime (type, val, nowTimeType) { // 设置searchTime if (type === 'minute') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'm') } else if (type === 'hour') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'h') } else if (type === 'date') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'd') @@ -1658,12 +1658,12 @@ export default { const self = this let axiosArr = [] this.$nextTick(() => { - let startTime = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - let endTime = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + let startTime = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + let endTime = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') if (!startTime || !endTime) { // 如果时间为空,则默认取最近1小时 const now = new Date() - startTime = bus.timeFormate(now, 'yyyy-MM-dd hh:mm:ss') - endTime = bus.timeFormate(now.setHours(now.getHours() - 1), 'yyyy-MM-dd hh:mm:ss') + startTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss') + endTime = bus.timeFormate(now.setHours(now.getHours() - 1), 'YYYY-MM-DD HH:mm:ss') this.searchTime[0] = startTime this.searchTime[1] = endTime } @@ -1680,8 +1680,8 @@ export default { return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) }) if (this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较 - startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'YYYY-MM-DD HH:mm:ss') this.data.elements.forEach((ele) => { const filterItem = ele let query = encodeURIComponent(filterItem.expression) diff --git a/nezha-fronted/src/components/charts/logs.vue b/nezha-fronted/src/components/charts/logs.vue index eeca42553..5b7a9cc61 100644 --- a/nezha-fronted/src/components/charts/logs.vue +++ b/nezha-fronted/src/components/charts/logs.vue @@ -674,8 +674,8 @@ export default { }) }, dateChange (time) { - this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filter.start_time = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + this.filter.end_time = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') // this.echartModalStore.clear() this.showLegend = false this.$refs['localLoadingScreen' + this.chartIndex].startLoading() diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 6ea7b8465..1fff55b55 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -438,8 +438,8 @@ export default { bottom: null }, filterTime: [ - bus.timeFormate(bus.getOffsetTimezoneData(-1), 'yyyy-MM-dd hh:mm:ss'), - bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') + bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'), + bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') ], topologyInfo: { fontSize: 14, @@ -755,26 +755,26 @@ export default { // const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType // this.setSearchTime(nowTimeType.type, nowTimeType.value) this.searchTime = bus.getTimezontDateRange() - this.filterTime[0] = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filterTime[1] = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filterTime[0] = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + this.filterTime[1] = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') this.reload() }, setSearchTime (type, val) { // 设置searchTime if (type === 'minute') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'm') } else if (type === 'hour') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'h') } else if (type === 'date') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'd') diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointQuery.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointQuery.vue index f3eebc55f..c35c68f11 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointQuery.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointQuery.vue @@ -127,7 +127,7 @@ export default { timeout: null, formatTime: '', hideSameLabels: true, - endpointQueryTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss' + endpointQueryTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss' } }, methods: { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue index 2ba910315..0e8f199f8 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointQueryTab.vue @@ -175,7 +175,7 @@ export default { scrollTop: 0, scrollbarWrap: null, minusTime: 0, - endpointQueryTabTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss' + endpointQueryTabTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss' } }, methods: { @@ -453,8 +453,8 @@ export default { axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(start) + '&end=' + this.$stringTimeParseToUnix(end) + '&step=' + step)) } if (this.$refs.pickTime && this.$refs.pickTime.$refs.multipleTime && this.$refs.pickTime.$refs.multipleTime.searchTime.length) { // 判断是否需要添加比较 - const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(this.$refs.pickTime.$refs.multipleTime.searchTime[1], 'YYYY-MM-DD HH:mm:ss') for (const endpoint of this.selectedEndpoints) { axiosArr.push(axios.get('/prom/api/v1/query_range?query=' + encodeURIComponent(endpoint.element) + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)) } diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue index b323e6020..66e0e143c 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue @@ -58,8 +58,8 @@ export default { return { logData: null, filterTime: [ - bus.timeFormate(bus.getOffsetTimezoneData(-1), 'yyyy-MM-dd hh:mm:ss'), - bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') + bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'), + bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') ], expressions: [''], matchSymbol: '|=', diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue index 10a891cfe..b4148834a 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/panelTabNew.vue @@ -453,8 +453,8 @@ export default { this.chartListLoading = true if (params.start_time === '' || params.end_time === '') { const now = bus.getTimezontDateRange() - const endTimeTmp = bus.timeFormate(now[1].getTime(), 'yyyy-MM-dd hh:mm:ss') - const startTimeTmp = bus.timeFormate(now[0].getTime(), 'yyyy-MM-dd hh:mm:ss') + const endTimeTmp = bus.timeFormate(now[1].getTime(), 'YYYY-MM-DD HH:mm:ss') + const startTimeTmp = bus.timeFormate(now[0].getTime(), 'YYYY-MM-DD HH:mm:ss') params.start_time = startTimeTmp params.end_time = endTimeTmp params.from = this.from @@ -487,8 +487,8 @@ export default { const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType this.setSearchTime(nowTimeType.type, nowTimeType.value) - this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filter.start_time = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + this.filter.end_time = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') this.filter.panelId = this.showPanel.id this.getData(this.filter) } @@ -496,20 +496,20 @@ export default { /* 时间条件查询--end */ setSearchTime (type, val) { // 设置searchTime if (type === 'minute') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'm') } else if (type === 'hour') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'h') } else if (type === 'date') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'd') diff --git a/nezha-fronted/src/components/common/js/tools.js b/nezha-fronted/src/components/common/js/tools.js index a8cd74bf7..f88c3beda 100644 --- a/nezha-fronted/src/components/common/js/tools.js +++ b/nezha-fronted/src/components/common/js/tools.js @@ -392,7 +392,7 @@ export function calcDurationByStringTimeMs (startTime, endTime) { return result } -export function unixTimeParseToString (unixTime, fmt = 'yyyy-MM-dd hh:mm:ss') { +export function unixTimeParseToString (unixTime, fmt = 'YYYY-MM-DD HH:mm:ss') { const date = new Date(unixTime * 1000) const o = { 'M+': date.getMonth() + 1, // 月份 diff --git a/nezha-fronted/src/components/common/mixin/dataList.js b/nezha-fronted/src/components/common/mixin/dataList.js index 8e506ebd3..32cf2dbb3 100644 --- a/nezha-fronted/src/components/common/mixin/dataList.js +++ b/nezha-fronted/src/components/common/mixin/dataList.js @@ -245,8 +245,8 @@ export default { localStorage.setItem('dataList-layout' + this.tableId, JSON.stringify(this.dataListLayout)) }, addSilence (row, type) { - this.blankSilenceObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') - this.blankSilenceObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'yyyy-MM-dd hh:mm:ss') + this.blankSilenceObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') + this.blankSilenceObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'YYYY-MM-DD HH:mm:ss') this.objectSilence = JSON.parse(JSON.stringify(this.blankSilenceObject)) this.objectSilence.name = 'Quick silence' if (type !== 'alertMessage' && type !== 'alertRule') { diff --git a/nezha-fronted/src/components/common/multipleTime.vue b/nezha-fronted/src/components/common/multipleTime.vue index f4a66bba6..b9462885c 100644 --- a/nezha-fronted/src/components/common/multipleTime.vue +++ b/nezha-fronted/src/components/common/multipleTime.vue @@ -160,7 +160,7 @@ export default { isPopoverDisabled: false, isCustom: false, valueArr: [], - multipleTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss' + multipleTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss' } }, watch: { diff --git a/nezha-fronted/src/components/common/myDatePicker/src/picker.vue b/nezha-fronted/src/components/common/myDatePicker/src/picker.vue index 89a82eed3..770675cef 100644 --- a/nezha-fronted/src/components/common/myDatePicker/src/picker.vue +++ b/nezha-fronted/src/components/common/myDatePicker/src/picker.vue @@ -109,13 +109,13 @@ const NewPopper = { const DEFAULT_FORMATS = { date: 'yyyy-MM-dd', month: 'yyyy-MM', - datetime: 'yyyy-MM-dd HH:mm:ss', + datetime: 'YYYY-MM-DD HH:mm:ss', time: 'HH:mm:ss', week: 'yyyywWW', timerange: 'HH:mm:ss', daterange: 'yyyy-MM-dd', monthrange: 'yyyy-MM', - datetimerange: 'yyyy-MM-dd HH:mm:ss', + datetimerange: 'YYYY-MM-DD HH:mm:ss', year: 'yyyy' } const HAVE_TRIGGER_TYPES = [ diff --git a/nezha-fronted/src/components/common/pickTime.vue b/nezha-fronted/src/components/common/pickTime.vue index 5ed4d7fb3..25bf9eb19 100644 --- a/nezha-fronted/src/components/common/pickTime.vue +++ b/nezha-fronted/src/components/common/pickTime.vue @@ -81,7 +81,7 @@ export default { themeColor: '' }, timer: '', - pickTimer: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss', + pickTimer: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss', } }, created () { diff --git a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue index e3d119621..ca073408a 100644 --- a/nezha-fronted/src/components/common/project/L5/topoTooltip.vue +++ b/nezha-fronted/src/components/common/project/L5/topoTooltip.vue @@ -77,10 +77,10 @@ export default { chartDataTemp: { id: 8832, prev: null, next: null, panelId: 0, title: '123', span: 12, height: 0, createAt: '2021-01-27 07:36:19', unit: 2, weight: 0, pid: null, buildIn: null, seq: null, param: { last: 0, legendValue: { total: 'off', min: 'off', avg: 'off', last: 'off', max: 'off' }, threshold: '', url: '', nullType: 'null' }, sync: null, asset: null, isLoaded: true, from: '__vue_devtool_undefined__', draggable: true, resizable: true, editable: true }, chartData: {}, filter: { - end_time: bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss'), + end_time: bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss'), panelId: 0, searchName: '', - start_time: bus.timeFormate(bus.getOffsetTimezoneData(-1), 'yyyy-MM-dd hh:mm:ss') + start_time: bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss') } } }, @@ -131,8 +131,8 @@ export default { }) } else { 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 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) => { @@ -322,7 +322,7 @@ export default { } */ // let t_date = new Date(dpsItem[0] * 1000); - // let timeTmp = bus.timeFormate(t_date, 'yyyy-MM-dd hh:mm:ss'); + // let timeTmp = bus.timeFormate(t_date, 'YYYY-MM-DD HH:mm:ss'); tableData.push({ // 表格数据 // label: host.slice(host.indexOf('{') + 1,host.indexOf('}')),//label // metric: queryItem.metric.__name__?queryItem.metric.__name__:'',//metric列 diff --git a/nezha-fronted/src/components/common/project/popData/alertTable.vue b/nezha-fronted/src/components/common/project/popData/alertTable.vue index 51fd15fcb..de93a66b4 100644 --- a/nezha-fronted/src/components/common/project/popData/alertTable.vue +++ b/nezha-fronted/src/components/common/project/popData/alertTable.vue @@ -194,8 +194,8 @@ export default { this.$set(this.searchLabel, 'pageSize', this.pageObj.pageSize) this.$set(this.searchLabel, 'moduleIds', this.moduleId) if (this.searchTime && this.searchTime.length > 1) { - this.$set(this.searchLabel, 'startAt', bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss')) - this.$set(this.searchLabel, 'endAt', bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')) + this.$set(this.searchLabel, 'startAt', bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss')) + this.$set(this.searchLabel, 'endAt', bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss')) } else { delete this.searchLabel.startAt delete this.searchLabel.endAt diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 7be05fced..0c300d9a6 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -396,8 +396,8 @@ export default { bottom: null }, filterTime: [ - bus.timeFormate(bus.getOffsetTimezoneData(-1), 'yyyy-MM-dd hh:mm:ss'), - bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') + bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'), + bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') ], showNoData: false, topologyInfo: { @@ -742,26 +742,26 @@ export default { // const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType // this.setSearchTime(nowTimeType.type, nowTimeType.value) this.searchTime = bus.getTimezontDateRange() - this.filterTime[0] = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') - this.filterTime[1] = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filterTime[0] = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') + this.filterTime[1] = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') this.reload() }, setSearchTime (type, val) { // 设置searchTime if (type === 'minute') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'm') } else if (type === 'hour') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'h') } else if (type === 'date') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 2, val + 'd') diff --git a/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue b/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue index 666a7dcba..6eb6821d3 100644 --- a/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue +++ b/nezha-fronted/src/components/common/rightBox/alertSilenceBox.vue @@ -210,7 +210,7 @@ export default { endpointData: null, startAtTamp: '', endAtTamp: '', - alertSilenceTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss' + alertSilenceTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss' } }, mounted () { @@ -295,10 +295,10 @@ export default { }, dateChange (val, type) { if (type === 'startAt') { - this.editAlertSilence.startAt = bus.timeFormate(new Date(val), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') + this.editAlertSilence.startAt = bus.timeFormate(new Date(val), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') this.startAtTamp = new Date(val).getTime() } else if (type === 'endAt') { - this.editAlertSilence.endAt = bus.timeFormate(new Date(val), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') + this.editAlertSilence.endAt = bus.timeFormate(new Date(val), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') this.endAtTamp = new Date(val).getTime() } this.$forceUpdate() @@ -313,7 +313,7 @@ export default { } }, rangeTimeChange (val) { - const arr = [bus.timeFormate(bus.getOffsetTimezoneData(), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss'), bus.timeFormate(bus.getOffsetTimezoneData(val * 1), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss')] + const arr = [bus.timeFormate(bus.getOffsetTimezoneData(), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss'), bus.timeFormate(bus.getOffsetTimezoneData(val * 1), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss')] this.$set(this.editAlertSilence, 'startAt', arr[0]) this.$set(this.editAlertSilence, 'endAt', arr[1]) this.startAtTamp = new Date(this.editAlertSilence.startAt).getTime() diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue index 8b8c27772..cd9c3261b 100644 --- a/nezha-fronted/src/components/common/timePicker.vue +++ b/nezha-fronted/src/components/common/timePicker.vue @@ -67,7 +67,7 @@ export default { return { isPopoverDisabled: false, isCustom: false, - timePicker: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss', + timePicker: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss', searchTime: [ bus.timeFormate(bus.getOffsetTimezoneData(-1), this.timePicker), bus.timeFormate(bus.getOffsetTimezoneData(), this.timePicker) diff --git a/nezha-fronted/src/components/page/alert/alertSilence.vue b/nezha-fronted/src/components/page/alert/alertSilence.vue index 4a026b476..61d3d1db5 100644 --- a/nezha-fronted/src/components/page/alert/alertSilence.vue +++ b/nezha-fronted/src/components/page/alert/alertSilence.vue @@ -190,8 +190,8 @@ export default { }) }, add () { - this.blankObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') - this.blankObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'yyyy-MM-dd hh:mm:ss') + this.blankObject.startAt = bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') + this.blankObject.endAt = bus.timeFormate(bus.getOffsetTimezoneData(1), 'YYYY-MM-DD HH:mm:ss') this.object = JSON.parse(JSON.stringify(this.blankObject)) this.rightBox.show = true }, diff --git a/nezha-fronted/src/components/page/config/system.vue b/nezha-fronted/src/components/page/config/system.vue index 59dc522b8..69466044b 100644 --- a/nezha-fronted/src/components/page/config/system.vue +++ b/nezha-fronted/src/components/page/config/system.vue @@ -404,7 +404,7 @@ export default { system_logo: '', current_site_url: '', timezone: '', - date_format: 'yyyy-MM-dd HH:mm:ss', + date_format: 'YYYY-MM-DD HH:mm:ss', theme: 'Light', default_cabinet_usize: '', query_max_series: '', @@ -586,9 +586,9 @@ export default { { value: 'dark', label: 'Dark' } ], dateFormatList: [ - { value: 'dd/MM/yyyy HH:mm:ss', label: 'dd/MM/yyyy HH:mm:ss' }, - { value: 'MM/dd/yyyy HH:mm:ss', label: 'MM/dd/yyyy HH:mm:ss' }, - { value: 'yyyy-MM-dd HH:mm:ss', label: 'yyyy-MM-dd HH:mm:ss' } + { value: 'DD/MM/YYYY HH:mm:ss', label: 'DD/MM/YYYY HH:mm:ss' }, + { value: 'MM/DD/YYYY HH:mm:ss', label: 'MM/DD/YYYY HH:mm:ss' }, + { value: 'YYYY-MM-DD HH:mm:ss', label: 'YYYY-MM-DD HH:mm:ss' } ] } }, diff --git a/nezha-fronted/src/components/page/config/system/apiKeyTable.vue b/nezha-fronted/src/components/page/config/system/apiKeyTable.vue index 8487ef11a..760dbc7f1 100644 --- a/nezha-fronted/src/components/page/config/system/apiKeyTable.vue +++ b/nezha-fronted/src/components/page/config/system/apiKeyTable.vue @@ -166,7 +166,7 @@ export default { return time.getTime() < Date.now() - 24 * 60 * 60 * 1000 } }, - apiKeyTableTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss' + apiKeyTableTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss' } }, methods: { diff --git a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue index 838eb5ed1..cacd43504 100644 --- a/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue +++ b/nezha-fronted/src/components/page/dashboard/explore/exploreItem.vue @@ -380,8 +380,8 @@ export default { promqlKeys: [], expressions: [''], filterTime: [ - bus.timeFormate(bus.getOffsetTimezoneData(-1), 'yyyy-MM-dd hh:mm:ss'), - bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss') + bus.timeFormate(bus.getOffsetTimezoneData(-1), 'YYYY-MM-DD HH:mm:ss'), + bus.timeFormate(bus.getOffsetTimezoneData(), 'YYYY-MM-DD HH:mm:ss') ], /* 工具参数 */ @@ -754,7 +754,7 @@ export default { } this.$set(metrics, 'value#' + index, chartDataFormat.getUnit(this.chartUnit || 2).compute(result.value[1], null, 2)) - this.$set(metrics, 'time', bus.timeFormate(bus.computeTimezone(result.value[0] * 1000), 'yyyy-MM-dd hh:mm:ss')) + this.$set(metrics, 'time', bus.timeFormate(bus.computeTimezone(result.value[0] * 1000), 'YYYY-MM-DD HH:mm:ss')) for (const key in metrics) { const label = { label: key, @@ -824,20 +824,20 @@ export default { }, setSearchTime (type, val) { // 设置searchTime if (type === 'minute') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.filterTime, 0, startTime) this.$set(this.filterTime, 1, endTime) this.$set(this.filterTime, 2, val + 'm') } else if (type === 'hour') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.filterTime, 0, startTime) this.$set(this.filterTime, 1, endTime) this.$set(this.filterTime, 2, val + 'h') } else if (type === 'date') { - const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'yyyy-MM-dd hh:mm:ss') - const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val), 'YYYY-MM-DD HH:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'YYYY-MM-DD HH:mm:ss') this.$set(this.filterTime, 0, startTime) this.$set(this.filterTime, 1, endTime) this.$set(this.filterTime, 2, val + 'd') diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue index 8f005b6f7..5c4c5cbf3 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview2.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/overview2.vue @@ -758,13 +758,13 @@ export default { } else { before = new Date() before.setHours(new Date().getHours() - 1) - before = this.dateFormat('yyyy-mm-dd HH:MM:SS', before) + before = this.dateFormat('YYYY-MM-DD HH:mm:ss', before) } if (this.trendSearchParam.end) { end = this.trendSearchParam.end } else { end = new Date() - end = this.dateFormat('yyyy-mm-dd HH:MM:SS', end) + end = this.dateFormat('YYYY-MM-DD HH:mm:ss', end) } let metric let rule diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 1a94bae8b..9919117df 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -277,7 +277,7 @@ export default { scrollbarWrap: null, batchDeleteObjs: [], nowTimeType: {}, - panelDateFormatTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss' + panelDateFormatTime: localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss' } }, components: { diff --git a/nezha-fronted/src/libs/bus.js b/nezha-fronted/src/libs/bus.js index d3cea6702..e453be37f 100644 --- a/nezha-fronted/src/libs/bus.js +++ b/nezha-fronted/src/libs/bus.js @@ -39,8 +39,8 @@ export default new Vue({ end.setEnd() // let start = this.getHoursTime(-1); // let end = this.getHoursTime(0); - start = this.timeFormate(start, localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') - end = this.timeFormate(end, localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') + start = this.timeFormate(start, localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') + end = this.timeFormate(end, localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') this.selectDate = [start, end] }, getHoursTime (hours) { @@ -65,60 +65,66 @@ export default new Vue({ } return `${yy}${mm}${dd}` }, - timeFormate (date, fmt = localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') { + timeFormate (date, fmt = localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') { const time = new Date(date) let fm = fmt - // fmt 自定义格式,如:yy-MM-dd - let week = '' - switch (time.getDay()) { - case 0: - week = '周日' - break - case 1: - week = '周一' - break - case 2: - week = '周二' - break - case 3: - week = '周三' - break - case 4: - week = '周四' - break - case 5: - week = '周五' - break - case 6: - week = '周六' - break - default: - week = '' - break - } - const o = { - 'M+': time.getMonth() + 1, // 月份 - 'd+': time.getDate(), // 日 - hh: time.getHours(), // 小时 - HH: time.getHours(), // 小时 - 'm+': time.getMinutes(), // 分 - 's+': time.getSeconds(), // 秒 - 'q+': Math.floor((time.getMonth() + 3) / 3), // 季度 - S: time.getMilliseconds(), // 毫秒 - w: week - } - if (/(y+)/.test(fm)) { - fm = fm.replace(RegExp.$1, (time.getFullYear().toString()).substr(4 - RegExp.$1.length)) - } - Object.keys(o).forEach((k) => { - if (new RegExp(`(${k})`).test(fm)) { - fm = fm.replace(RegExp.$1, (RegExp.$1.length === 1) - ? (o[k]) - : ((`00${o[k]}`).substr((`${o[k]}`).length))) - } - }) + console.log(time, fm) + return moment(time).format(fm) + // // fmt 自定义格式,如:yy-MM-dd + // let week = '' + // switch (time.getDay()) { + // case 0: + // week = '周日' + // break + // case 1: + // week = '周一' + // break + // case 2: + // week = '周二' + // break + // case 3: + // week = '周三' + // break + // case 4: + // week = '周四' + // break + // case 5: + // week = '周五' + // break + // case 6: + // week = '周六' + // break + // default: + // week = '' + // break + // } + // const o = { + // 'M+': time.getMonth() + 1, // 月份 + // 'd+': time.getDate(), // 日 + // hh: time.getHours(), // 小时 + // HH: time.getHours(), // 小时 + // 'm+': time.getMinutes(), // 分 + // 's+': time.getSeconds(), // 秒 + // 'q+': Math.floor((time.getMonth() + 3) / 3), // 季度 + // S: time.getMilliseconds(), // 毫秒 + // w: week + // } + // if (/(y+)/.test(fm)) { + // fm = fm.replace(RegExp.$1, (time.getFullYear().toString()).substr(4 - RegExp.$1.length)) + // } + // Object.keys(o).forEach((k) => { + // if (new RegExp(`(${k})`).test(fm)) { + // fm = fm.replace(RegExp.$1, (RegExp.$1.length === 1) + // ? (o[k]) + // : ((`00${o[k]}`).substr((`${o[k]}`).length))) + // } + // }) return fm }, + formateTimeToTime (date, fmt = localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') { + const newDate = moment(date, fmt) + return newDate + }, // 格式化tag为字符串表达式 tagsToString (metric, arr) { let str = metric @@ -294,7 +300,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, localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : '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) diff --git a/nezha-fronted/src/main.js b/nezha-fronted/src/main.js index 553aba23a..eee55b0b0 100644 --- a/nezha-fronted/src/main.js +++ b/nezha-fronted/src/main.js @@ -104,7 +104,7 @@ Vue.mixin({ }, utcTimeToTimezoneStr: function (time) { if (time) { - return bus.timeFormate(bus.UTCTimeToConfigTimezone(time), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') + return bus.timeFormate(bus.UTCTimeToConfigTimezone(time), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') } else { return '-' } @@ -116,7 +116,7 @@ Vue.mixin({ }, timezoneToUtcTimeStr: function (time) { if (time) { - return bus.timeFormate(this.timezoneToUtcTime(time), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') + return bus.timeFormate(this.timezoneToUtcTime(time), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') } }, timestampStr: function (time) { @@ -124,7 +124,7 @@ Vue.mixin({ const localOffset = date.getTimezoneOffset() * 60 * 1000 // 默认 一分钟显示时区偏移的结果 const dateStr = new Date(time).getTime() + localOffset if (time) { - return bus.timeFormate(bus.UTCTimeToConfigTimezone(dateStr), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'yyyy-MM-dd hh:mm:ss') + return bus.timeFormate(bus.UTCTimeToConfigTimezone(dateStr), localStorage.getItem('nz-default-dateFormat') ? localStorage.getItem('nz-default-dateFormat') : 'YYYY-MM-DD HH:mm:ss') } else { return '-' }