feat: set last 24 hours as default date range in DashboardView

This commit is contained in:
Ethan0x0000
2026-03-16 19:46:32 +08:00
parent a0b76bd608
commit aef7c3b9bb
2 changed files with 154 additions and 3 deletions

View File

@@ -348,12 +348,20 @@ const formatLocalDate = (date: Date): string => {
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
}
const getTodayLocalDate = () => formatLocalDate(new Date())
const getLast24HoursRangeDates = (): { start: string; end: string } => {
const end = new Date()
const start = new Date(end.getTime() - 24 * 60 * 60 * 1000)
return {
start: formatLocalDate(start),
end: formatLocalDate(end)
}
}
// Date range
const granularity = ref<'day' | 'hour'>('hour')
const startDate = ref(getTodayLocalDate())
const endDate = ref(getTodayLocalDate())
const defaultRange = getLast24HoursRangeDates()
const startDate = ref(defaultRange.start)
const endDate = ref(defaultRange.end)
// Granularity options for Select component
const granularityOptions = computed(() => [