feat(quota): add Xai plan resolution and localization for SuperGrok plans

This commit is contained in:
LTbinglingfeng
2026-06-17 13:52:09 +08:00
parent 2d77fbe13c
commit c74fa6d400
5 changed files with 40 additions and 0 deletions
+28
View File
@@ -1749,6 +1749,21 @@ const formatXaiRemainingAmount = (billing: XaiBillingSummary): string => {
return `${remaining} / ${limit}`;
};
const XAI_SUPERGROK_LIMIT_CENTS = 15_000;
const XAI_SUPERGROK_HEAVY_LIMIT_CENTS = 150_000;
const resolveXaiPlan = (
monthlyLimitCents: number | null
): { labelKey: string; premium: boolean } | null => {
if (monthlyLimitCents === XAI_SUPERGROK_LIMIT_CENTS) {
return { labelKey: 'plan_supergrok', premium: false };
}
if (monthlyLimitCents === XAI_SUPERGROK_HEAVY_LIMIT_CENTS) {
return { labelKey: 'plan_supergrok_heavy', premium: true };
}
return null;
};
const renderXaiItems = (
quota: XaiQuotaState,
t: TFunction,
@@ -1769,6 +1784,7 @@ const renderXaiItems = (
const amountLabel = formatXaiRemainingAmount(billing);
const resetLabel = formatQuotaResetTime(billing.billingPeriodEnd);
const onDemandCap = billing.onDemandCapCents ?? 0;
const plan = resolveXaiPlan(billing.monthlyLimitCents);
const payAsYouGoLabel =
onDemandCap > 0
? t('xai_quota.pay_as_you_go_enabled', { cap: formatUsdFromCents(onDemandCap) })
@@ -1777,6 +1793,18 @@ const renderXaiItems = (
return h(
Fragment,
null,
plan
? h(
'div',
{ key: 'plan', className: styleMap.codexPlan },
h('span', { className: styleMap.codexPlanLabel }, t('xai_quota.plan_label')),
h(
'span',
{ className: plan.premium ? styleMap.premiumPlanValue : styleMap.codexPlanValue },
t(`xai_quota.${plan.labelKey}`)
)
)
: null,
h(
'div',
{ key: 'pay-as-you-go', className: styleMap.codexPlan },
+3
View File
@@ -528,6 +528,9 @@
"refresh_button": "Refresh Quota",
"fetch_all": "Fetch All",
"monthly_credits": "Monthly credits",
"plan_label": "Plan",
"plan_supergrok": "SuperGrok",
"plan_supergrok_heavy": "SuperGrok Heavy",
"pay_as_you_go_label": "Pay as you go",
"pay_as_you_go_enabled": "Enabled, cap {{cap}}",
"pay_as_you_go_disabled": "Disabled"
+3
View File
@@ -515,6 +515,9 @@
"refresh_button": "Обновить квоту",
"fetch_all": "Получить все",
"monthly_credits": "Месячные кредиты",
"plan_label": "План",
"plan_supergrok": "SuperGrok",
"plan_supergrok_heavy": "SuperGrok Heavy",
"pay_as_you_go_label": "Оплата по факту",
"pay_as_you_go_enabled": "Включено, лимит {{cap}}",
"pay_as_you_go_disabled": "Отключено"
+3
View File
@@ -528,6 +528,9 @@
"refresh_button": "刷新额度",
"fetch_all": "获取全部",
"monthly_credits": "月度积分",
"plan_label": "套餐",
"plan_supergrok": "SuperGrok",
"plan_supergrok_heavy": "SuperGrok Heavy",
"pay_as_you_go_label": "按量付费",
"pay_as_you_go_enabled": "已启用,封顶 {{cap}}",
"pay_as_you_go_disabled": "未启用"
+3
View File
@@ -528,6 +528,9 @@
"refresh_button": "重新整理配額",
"fetch_all": "取得全部",
"monthly_credits": "月度點數",
"plan_label": "方案",
"plan_supergrok": "SuperGrok",
"plan_supergrok_heavy": "SuperGrok Heavy",
"pay_as_you_go_label": "按量付費",
"pay_as_you_go_enabled": "已啟用,封頂 {{cap}}",
"pay_as_you_go_disabled": "未啟用"