Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
678b088a
Commit
678b088a
authored
Jan 04, 2026
by
shaw
Browse files
Merge PR #137: fix(frontend): 修复跨时区日期范围筛选问题
parents
fac19d25
600f9ce2
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/common/DateRangePicker.vue
View file @
678b088a
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
<input
<input
type=
"date"
type=
"date"
v-model=
"localStartDate"
v-model=
"localStartDate"
:max=
"localEndDate || to
day
"
:max=
"localEndDate || to
morrow
"
class=
"date-picker-input"
class=
"date-picker-input"
@
change=
"onDateChange"
@
change=
"onDateChange"
/>
/>
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
type=
"date"
type=
"date"
v-model=
"localEndDate"
v-model=
"localEndDate"
:min=
"localStartDate"
:min=
"localStartDate"
:max=
"to
day
"
:max=
"to
morrow
"
class=
"date-picker-input"
class=
"date-picker-input"
@
change=
"onDateChange"
@
change=
"onDateChange"
/>
/>
...
@@ -144,6 +144,14 @@ const today = computed(() => {
...
@@ -144,6 +144,14 @@ const today = computed(() => {
return
`
${
year
}
-
${
month
}
-
${
day
}
`
return
`
${
year
}
-
${
month
}
-
${
day
}
`
})
})
// Tomorrow's date - used for max date to handle timezone differences
// When user is in a timezone behind the server, "today" on server might be "tomorrow" locally
const
tomorrow
=
computed
(()
=>
{
const
d
=
new
Date
()
d
.
setDate
(
d
.
getDate
()
+
1
)
return
formatDateToString
(
d
)
})
// Helper function to format date to YYYY-MM-DD using local timezone
// Helper function to format date to YYYY-MM-DD using local timezone
const
formatDateToString
=
(
date
:
Date
):
string
=>
{
const
formatDateToString
=
(
date
:
Date
):
string
=>
{
const
year
=
date
.
getFullYear
()
const
year
=
date
.
getFullYear
()
...
...
frontend/src/views/admin/UsageView.vue
View file @
678b088a
...
@@ -888,13 +888,17 @@ const formatLocalDate = (date: Date): string => {
...
@@ -888,13 +888,17 @@ const formatLocalDate = (date: Date): string => {
}
}
// Initialize date range immediately
// Initialize date range immediately
// Use tomorrow as end date to handle timezone differences between client and server
// e.g., when server is in Asia/Shanghai and client is in America/Chicago
const
now
=
new
Date
()
const
now
=
new
Date
()
const
tomorrow
=
new
Date
(
now
)
tomorrow
.
setDate
(
tomorrow
.
getDate
()
+
1
)
const
weekAgo
=
new
Date
(
now
)
const
weekAgo
=
new
Date
(
now
)
weekAgo
.
setDate
(
weekAgo
.
getDate
()
-
6
)
weekAgo
.
setDate
(
weekAgo
.
getDate
()
-
6
)
// Date range state
// Date range state
const
startDate
=
ref
(
formatLocalDate
(
weekAgo
))
const
startDate
=
ref
(
formatLocalDate
(
weekAgo
))
const
endDate
=
ref
(
formatLocalDate
(
n
ow
))
const
endDate
=
ref
(
formatLocalDate
(
tomorr
ow
))
const
filters
=
ref
<
AdminUsageQueryParams
>
({
const
filters
=
ref
<
AdminUsageQueryParams
>
({
user_id
:
undefined
,
user_id
:
undefined
,
...
@@ -1215,12 +1219,14 @@ const resetFilters = () => {
...
@@ -1215,12 +1219,14 @@ const resetFilters = () => {
end_date
:
undefined
end_date
:
undefined
}
}
granularity
.
value
=
'
day
'
granularity
.
value
=
'
day
'
// Reset date range to default (last 7 days)
// Reset date range to default (last 7 days
, with tomorrow as end to handle timezone differences
)
const
now
=
new
Date
()
const
now
=
new
Date
()
const
tomorrowDate
=
new
Date
(
now
)
tomorrowDate
.
setDate
(
tomorrowDate
.
getDate
()
+
1
)
const
weekAgo
=
new
Date
(
now
)
const
weekAgo
=
new
Date
(
now
)
weekAgo
.
setDate
(
weekAgo
.
getDate
()
-
6
)
weekAgo
.
setDate
(
weekAgo
.
getDate
()
-
6
)
startDate
.
value
=
formatLocalDate
(
weekAgo
)
startDate
.
value
=
formatLocalDate
(
weekAgo
)
endDate
.
value
=
formatLocalDate
(
now
)
endDate
.
value
=
formatLocalDate
(
tomorrowDate
)
filters
.
value
.
start_date
=
startDate
.
value
filters
.
value
.
start_date
=
startDate
.
value
filters
.
value
.
end_date
=
endDate
.
value
filters
.
value
.
end_date
=
endDate
.
value
pagination
.
value
.
page
=
1
pagination
.
value
.
page
=
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment