feat: implement last 24 hours date range preset and update filters in UsageView

This commit is contained in:
Ethan0x0000
2026-03-16 19:46:24 +08:00
parent aa5846b282
commit a0b76bd608
7 changed files with 190 additions and 36 deletions
@@ -106,7 +106,7 @@ const isOpen = ref(false)
const containerRef = ref<HTMLElement | null>(null)
const localStartDate = ref(props.startDate)
const localEndDate = ref(props.endDate)
const activePreset = ref<string | null>('7days')
const activePreset = ref<string | null>('last24Hours')
const today = computed(() => {
// Use local timezone to avoid UTC timezone issues
@@ -152,6 +152,18 @@ const presets: DatePreset[] = [
return { start: yesterday, end: yesterday }
}
},
{
labelKey: 'dates.last24Hours',
value: 'last24Hours',
getRange: () => {
const end = new Date()
const start = new Date(end.getTime() - 24 * 60 * 60 * 1000)
return {
start: formatDateToString(start),
end: formatDateToString(end)
}
}
},
{
labelKey: 'dates.last7Days',
value: '7days',