Skip to content

Commit 6093aa6

Browse files
committed
feat(ui): show routing cooldown as secondary state
1 parent 07517e3 commit 6093aa6

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

frontend/src/features/accounts/AccountsPage.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ const statusTextMap: Record<string, string> = {
108108
disabled: "已停用",
109109
};
110110

111+
const routingCooldownTextMap: Record<string, string> = {
112+
official_remaining_below_3pct: "路由冷却",
113+
usage_limited: "路由冷却",
114+
capacity_failed: "路由冷却",
115+
rate_limited: "路由冷却",
116+
routing_cooldown: "路由冷却",
117+
};
118+
111119
const authModeTextMap: Record<string, string> = {
112120
api_key: "API Key",
113121
oauth: "官方授权",
@@ -513,6 +521,16 @@ function formatDeletedAccountMessage(
513521
: `已删除账户 ${accountName}`;
514522
}
515523

524+
function getRoutingCooldownSeconds(record: AccountRecord): number | undefined {
525+
return (
526+
record.routing_cooldown_remaining_seconds ?? record.cooldown_remaining_seconds
527+
);
528+
}
529+
530+
function getRoutingCooldownLabel(record: AccountRecord): string {
531+
return routingCooldownTextMap[record.routing_cooldown_reason ?? ""] ?? "路由冷却";
532+
}
533+
516534
function formatActiveAccountMessage(
517535
language: AppLanguage,
518536
accountName: string,
@@ -1408,6 +1426,9 @@ export function AccountsPage({
14081426
<Tag color={statusColorMap[record.status] ?? "default"}>
14091427
{t(statusTextMap[record.status] ?? record.status)}
14101428
</Tag>
1429+
{getRoutingCooldownSeconds(record) ? (
1430+
<Tag color="gold">{t(getRoutingCooldownLabel(record))}</Tag>
1431+
) : null}
14111432
{record.is_active ? (
14121433
<Tag color="green">{t("当前使用中")}</Tag>
14131434
) : null}
@@ -1800,6 +1821,14 @@ export function AccountsPage({
18001821
detailAccount.status,
18011822
)}
18021823
</Descriptions.Item>
1824+
<Descriptions.Item label={t("路由状态")}>
1825+
{getRoutingCooldownSeconds(detailAccount)
1826+
? `${t(getRoutingCooldownLabel(detailAccount))} · ${Math.max(
1827+
Math.floor((getRoutingCooldownSeconds(detailAccount) ?? 0) / 60),
1828+
0,
1829+
)}m`
1830+
: t("正常")}
1831+
</Descriptions.Item>
18031832
<Descriptions.Item label={t("认证方式")}>
18041833
{t(
18051834
authModeTextMap[detailAccount.auth_mode] ??

frontend/src/lib/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export type AccountRecord = {
1616
is_active: boolean;
1717
supports_responses?: boolean;
1818
cooldown_remaining_seconds?: number;
19+
routing_cooldown_remaining_seconds?: number;
20+
routing_cooldown_reason?: string;
1921
balance: number;
2022
quota_remaining: number;
2123
rpm_remaining: number;

0 commit comments

Comments
 (0)