mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 08:44:41 +08:00
feat(usage): add live end time option for custom date range (#4438)
* add glm-5.2 pricing * feat(usage): add live end time option for custom date range Add a "End time follows current time" checkbox in the custom date range picker. When enabled, the end time becomes read-only and automatically tracks the current moment, so usage data always reflects up-to-the-second consumption from the chosen start time. This is especially useful under the Coding Plan 5-hour quota window — users can set the start time to when their 5h window began and keep the end time live to monitor real-time token consumption. * style(usage): fix prettier formatting for UsageDashboard * fix(usage): include liveEndTime in React Query cache keys Without liveEndTime in the query key, a live custom range and a fixed custom range with the same stored endpoints share the same cache entry. After the live range refreshes (endDate = now), switching to the fixed range shows stale data fetched through "now" instead of the original end time.
This commit is contained in:
@@ -108,9 +108,18 @@ export function UsageDashboard() {
|
||||
return getUsageRangePresetLabel(range.preset, t);
|
||||
}
|
||||
|
||||
return `${new Date(resolvedRange.startDate * 1000).toLocaleString(locale)} - ${new Date(
|
||||
resolvedRange.endDate * 1000,
|
||||
).toLocaleString(locale)}`;
|
||||
const startStr = new Date(resolvedRange.startDate * 1000).toLocaleString(
|
||||
locale,
|
||||
);
|
||||
|
||||
if (range.liveEndTime) {
|
||||
return `${startStr} → ${t("usage.liveEndTimeNow", "现在")}`;
|
||||
}
|
||||
|
||||
const endStr = new Date(resolvedRange.endDate * 1000).toLocaleString(
|
||||
locale,
|
||||
);
|
||||
return `${startStr} - ${endStr}`;
|
||||
}, [locale, range, resolvedRange.endDate, resolvedRange.startDate, t]);
|
||||
|
||||
// 顶栏下拉的选项池:Provider 列表只跟应用/时间范围走(不受自身选中值影响),
|
||||
|
||||
Reference in New Issue
Block a user