mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-06 18:36:55 +08:00
feat: 优化数据分析页面时间戳处理并改进日期格式
- 在 formatDate 函数中添加时间戳单位自动检测(秒/毫秒) - 将日期格式从 M/D 改为 YYYY/M/D,提供更完整的时间信息
This commit is contained in:
@@ -149,8 +149,9 @@ function getTrendType(value: number): 'success' | 'error' | 'info' {
|
|||||||
|
|
||||||
// 格式化时间戳为日期
|
// 格式化时间戳为日期
|
||||||
function formatDate(timestamp: number): string {
|
function formatDate(timestamp: number): string {
|
||||||
const date = new Date(timestamp * 1000)
|
// 如果时间戳超过 100亿,说明是毫秒,否则是秒
|
||||||
return `${date.getMonth() + 1}/${date.getDate()}`
|
const date = new Date(timestamp > 10000000000 ? timestamp : timestamp * 1000)
|
||||||
|
return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从ChartData对象转换为数组,并按时间戳排序
|
// 从ChartData对象转换为数组,并按时间戳排序
|
||||||
|
|||||||
Reference in New Issue
Block a user