fix(admin-spa): 修复使用趋势图表按小时粒度不显示数据的问题

This commit is contained in:
shaw
2025-07-30 08:54:43 +08:00
parent 4f0860f352
commit 53d6f77753
14 changed files with 44 additions and 39 deletions

View File

@@ -55,8 +55,12 @@ const createChart = () => {
const labels = dashboardStore.trendData.map(item => {
if (granularity.value === 'hour') {
const date = new Date(item.date)
return `${date.getMonth() + 1}/${date.getDate()} ${date.getHours()}:00`
// 小时粒度使用hour字段
const date = new Date(item.hour)
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hour = String(date.getHours()).padStart(2, '0')
return `${month}/${day} ${hour}:00`
}
return item.date
})