diff --git a/src/components/usage/UsageDashboard.tsx b/src/components/usage/UsageDashboard.tsx index d0aeb75cd..0740dc376 100644 --- a/src/components/usage/UsageDashboard.tsx +++ b/src/components/usage/UsageDashboard.tsx @@ -21,7 +21,6 @@ import { LayoutGrid, } from "lucide-react"; import { ProviderIcon } from "@/components/ProviderIcon"; -import { Button } from "@/components/ui/button"; import { Select, SelectContent, @@ -47,6 +46,9 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; const APP_FILTER_OPTIONS: AppTypeFilter[] = ["all", ...KNOWN_APP_TYPES]; +// 0 表示关闭自动刷新(refetchInterval=false) +const REFRESH_INTERVAL_OPTIONS_MS = [0, 5000, 10000, 30000, 60000] as const; + // 与 AppSwitcher 的 appIconName 保持一致(codex 复用 openai 图标) const APP_FILTER_ICON: Record = { claude: "claude", @@ -93,14 +95,7 @@ export function UsageDashboard() { // usage 查询,实现实时刷新(仅在 Dashboard 挂载时生效,离开页面自动取消监听) useUsageEventBridge(); - const refreshIntervalOptionsMs = [0, 5000, 10000, 30000, 60000] as const; - const changeRefreshInterval = () => { - const currentIndex = refreshIntervalOptionsMs.indexOf( - refreshIntervalMs as (typeof refreshIntervalOptionsMs)[number], - ); - const safeIndex = currentIndex >= 0 ? currentIndex : 3; - const nextIndex = (safeIndex + 1) % refreshIntervalOptionsMs.length; - const next = refreshIntervalOptionsMs[nextIndex]; + const changeRefreshInterval = (next: number) => { setRefreshIntervalMs(next); queryClient.invalidateQueries({ queryKey: usageKeys.all }); }; @@ -211,7 +206,7 @@ export function UsageDashboard() { onValueChange={(v) => changeProviderName(decodeOptionValue(v))} > @@ -257,17 +252,28 @@ export function UsageDashboard() {
- + + + + + + + + {REFRESH_INTERVAL_OPTIONS_MS.map((ms) => ( + + {ms > 0 ? `${ms / 1000}s` : t("usage.refreshOff")} + + ))} + + - + {triggerLabel} diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index b5f72703d..6c2f1b1d0 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -1446,6 +1446,8 @@ "allModels": "All Models", "filterBySource": "Filter by source", "filterByModel": "Filter by model", + "refreshInterval": "Auto-refresh interval", + "refreshOff": "Off", "timeRange": "Time Range", "customRange": "Calendar Filter", "customRangeHint": "Supports both date and time", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 18dbec841..b7130d992 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -1446,6 +1446,8 @@ "allModels": "すべてのモデル", "filterBySource": "ソースで絞り込む", "filterByModel": "モデルで絞り込む", + "refreshInterval": "自動更新間隔", + "refreshOff": "オフ", "timeRange": "期間", "customRange": "カレンダーフィルター", "customRangeHint": "日付と時刻の両方に対応", diff --git a/src/i18n/locales/zh-TW.json b/src/i18n/locales/zh-TW.json index 1eb23c40d..55bdafa22 100644 --- a/src/i18n/locales/zh-TW.json +++ b/src/i18n/locales/zh-TW.json @@ -1418,6 +1418,8 @@ "allModels": "全部模型", "filterBySource": "依來源篩選", "filterByModel": "依模型篩選", + "refreshInterval": "自動重新整理間隔", + "refreshOff": "關閉", "timeRange": "時間範圍", "customRange": "日曆篩選", "customRangeHint": "支援日期與時間", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index c914c00ad..2b915d8f4 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -1446,6 +1446,8 @@ "allModels": "全部模型", "filterBySource": "按来源筛选", "filterByModel": "按模型筛选", + "refreshInterval": "自动刷新间隔", + "refreshOff": "关闭", "timeRange": "时间范围", "customRange": "日历筛选", "customRangeHint": "支持日期与时间",