From 28ca7df2978576230d968dac733b003dbb338f0e Mon Sep 17 00:00:00 2001 From: QTom Date: Sat, 28 Feb 2026 01:34:33 +0800 Subject: [PATCH] feat: add RPM display to AccountCapacityCell --- .../account/AccountCapacityCell.vue | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/frontend/src/components/account/AccountCapacityCell.vue b/frontend/src/components/account/AccountCapacityCell.vue index ae338aca..849bacb3 100644 --- a/frontend/src/components/account/AccountCapacityCell.vue +++ b/frontend/src/components/account/AccountCapacityCell.vue @@ -52,6 +52,24 @@ {{ account.max_sessions }} + + +
+ + + + + {{ currentRPM }} + / + {{ account.base_rpm }} + +
@@ -191,6 +209,50 @@ const sessionLimitTooltip = computed(() => { return t('admin.accounts.capacity.sessions.normal', { idle }) }) +// 是否显示 RPM 限制 +const showRpmLimit = computed(() => { + return ( + isAnthropicOAuthOrSetupToken.value && + props.account.base_rpm !== undefined && + props.account.base_rpm !== null && + props.account.base_rpm > 0 + ) +}) + +// 当前 RPM 计数 +const currentRPM = computed(() => props.account.current_rpm ?? 0) + +// RPM 状态样式 +const rpmClass = computed(() => { + if (!showRpmLimit.value) return '' + + const current = currentRPM.value + const base = props.account.base_rpm ?? 0 + if (base <= 0) return 'bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-400' + + const strategy = props.account.rpm_strategy || 'tiered' + if (strategy === 'tiered') { + const buffer = props.account.rpm_sticky_buffer ?? Math.max(1, Math.floor(base / 5)) + if (current >= base + buffer) return 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400' + if (current >= base) return 'bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400' + } else { + if (current >= base) return 'bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400' + } + if (current >= base * 0.8) return 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400' + return 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400' +}) + +// RPM 提示文字 +const rpmTooltip = computed(() => { + if (!showRpmLimit.value) return '' + + const current = currentRPM.value + const base = props.account.base_rpm ?? 0 + if (current >= base) return t('admin.accounts.capacity.rpm.full') + if (current >= base * 0.8) return t('admin.accounts.capacity.rpm.warning') + return t('admin.accounts.capacity.rpm.normal') +}) + // 格式化费用显示 const formatCost = (value: number | null | undefined) => { if (value === null || value === undefined) return '0'