feat: 优化数据分析页面时间戳处理并改进日期格式

- 在 formatDate 函数中添加时间戳单位自动检测(秒/毫秒)
- 将日期格式从 M/D 改为 YYYY/M/D,提供更完整的时间信息
This commit is contained in:
2025-12-03 17:21:35 +08:00
parent 8e2fdb10f5
commit 0eee2e4f91

View File

@@ -149,8 +149,9 @@ function getTrendType(value: number): 'success' | 'error' | 'info' {
// 格式化时间戳为日期
function formatDate(timestamp: number): string {
const date = new Date(timestamp * 1000)
return `${date.getMonth() + 1}/${date.getDate()}`
// 如果时间戳超过 100亿说明是毫秒否则是秒
const date = new Date(timestamp > 10000000000 ? timestamp : timestamp * 1000)
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
}
// 从ChartData对象转换为数组并按时间戳排序