From fa2f13ad9a90ef9afbed96019d791a139fccb79c Mon Sep 17 00:00:00 2001 From: zyh Date: Wed, 27 Mar 2024 15:07:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E6=97=B6=E5=BA=8F?= =?UTF-8?q?=E5=9B=BE=20x=E8=BD=B4=E6=97=B6=E9=97=B4=E6=AE=B5=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/chart/uplot/chartTimeSeriesMixin.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js index 166e3558f..1e247b48c 100644 --- a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js +++ b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js @@ -532,9 +532,6 @@ export default { let minute = tData.getMinutes() minute = minute > 9 ? minute : '0' + minute // 如果分钟小于10,则在前面加0补充为两位数字 if (minTime !== null && maxTime !== null) { - const diffSec = (maxTime - minTime) - const secOneDay = 12 * 60 * 60// 0.5天的秒数 - const secOneMonth = secOneDay * 30// 30天的秒数 const dateFormatStr = self.timeFormatMain.split(' ')[0] let str = '' const month = tData.getMonth() + 1 @@ -546,9 +543,15 @@ export default { } else { str += [month, day].join('-') } - if (diffSec <= secOneDay - 100) { // 同一天 + + const moment1 = moment((minTime * 1000 - localOffset + offset * 60 * 1000)) + const moment2 = moment((maxTime * 1000 - localOffset + offset * 60 * 1000)) + const isSameDay = moment1.isSame(moment2, 'day') + const isSameMonth = moment1.isSame(moment2, 'month') + + if (isSameDay) { // 同一天 return [hour, minute].join(':') - } else if (diffSec < secOneMonth) { // 大于1天,小于30天 + } else if (isSameMonth) { // 同一月 return str + '\n' + [hour, minute].join(':') } else { // 大于等于30天 return str