Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
refactor(desktop): 使用情况和计费页分组拉平,金额与日期跟随应用语言
xd-bobo73999130bf6f
diff --git a/apps/desktop/src/renderer/features/billing/AlipayIcon.tsx b/apps/desktop/src/renderer/features/billing/AlipayIcon.tsxnew file mode 100644index 0000000000..45f780da6e--- /dev/null+++ b/apps/desktop/src/renderer/features/billing/AlipayIcon.tsx@@ -0,0 +1,11 @@+/**+ * Alipay brand mark (Simple Icons, CC0). Rendered with currentColor so it+ * follows the surrounding text token in both Light and Dark modes.+ */+export function AlipayIcon({ className }: { className?: string }) {+ return (+ <svg viewBox="0 0 24 24" fill="currentColor" className={className} aria-hidden="true">+ <path d="M19.695 15.07c3.426 1.158 4.203 1.22 4.203 1.22V3.846c0-2.124-1.705-3.845-3.81-3.845H3.914C1.808.001.102 1.722.102 3.846v16.31c0 2.123 1.706 3.845 3.813 3.845h16.173c2.105 0 3.81-1.722 3.81-3.845v-.157s-6.19-2.602-9.315-4.119c-2.096 2.602-4.8 4.181-7.607 4.181-4.75 0-6.361-4.19-4.112-6.949.49-.602 1.324-1.175 2.617-1.497 2.025-.502 5.247.313 8.266 1.317a16.796 16.796 0 0 0 1.341-3.302H5.781v-.952h4.799V6.975H4.77v-.953h5.81V3.591s0-.409.411-.409h2.347v2.84h5.744v.951h-5.744v1.704h4.69a19.453 19.453 0 0 1-1.986 5.06c1.424.52 2.702 1.011 3.654 1.333m-13.81-2.032c-.596.06-1.71.325-2.321.869-1.83 1.608-.735 4.55 2.968 4.55 2.151 0 4.301-1.388 5.99-3.61-2.403-1.182-4.438-2.028-6.637-1.809" />+ </svg>+ );+}diff --git a/apps/desktop/src/renderer/features/billing/BillingPage.tsx b/apps/desktop/src/renderer/features/billing/BillingPage.tsxindex 89498a79bc..c70ae6b557 100644--- a/apps/desktop/src/renderer/features/billing/BillingPage.tsx+++ b/apps/desktop/src/renderer/features/billing/BillingPage.tsx@@ -33,6 +33,7 @@ import type {ModelAccessCreditUsage,ModelAccessPromotionalGrantState,} from '../../../shared/modelAccess';+import { AlipayIcon } from './AlipayIcon';import { billingApi } from './api';import { BillingCheckoutDialog } from './BillingCheckoutDialog';import { formatBillingAmount as formatMoney } from './money';@@ -124,11 +125,11 @@ function usagePercent(pool: ModelAccessCreditPoolUsage): number | null {return Number(tenths > 1_000n ? 1_000n : tenths) / 10;}-function formatLedgerTimestamp(value: string): string {+function formatLedgerTimestamp(value: string, locale: string): string {const timestamp = Date.parse(value);if (!Number.isFinite(timestamp)) return value;try {- return new Intl.DateTimeFormat(undefined, {+ return new Intl.DateTimeFormat(locale, {dateStyle: 'medium',timeStyle: 'short',}).format(timestamp);@@ -408,12 +409,12 @@ export function BillingSettingsSection({ accountId }: { accountId: string | nullmaxComparison > 0) {return t('billing.amount.rangeError', {- min: formatMoney(min, selected.offer.currency),- max: formatMoney(max, selected.offer.currency),+ min: formatMoney(min, selected.offer.currency, billingLocale),+ max: formatMoney(max, selected.offer.currency, billingLocale),});}return null;- }, [customAmount, selected, t]);+ }, [billingLocale, customAmount, selected, t]);const subscriptionPurchaseBlocked =currentSubscription !== null &&@@ -436,11 +437,6 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null[catalog],);- const currentPlanName = useMemo(- () => planNameOf(currentSubscription?.effectivePlan?.product.code),- [planNameOf, currentSubscription],- );-const currentPlan = currentSubscription?.effectivePlan ?? null;const pendingPlanChange = currentSubscription?.pendingPlanChange ?? null;const planChangeable =@@ -453,7 +449,7 @@ export function BillingSettingsSection({ accountId }: { accountId: string | nullreturn {name: planNameOf(plan?.product.code) ?? t('billing.settings.subscriptionCard.unnamedPlan'),status: currentSubscription.status,- price: plan ? formatMoney(plan.terms.amount, plan.terms.currency) : null,+ price: plan ? formatMoney(plan.terms.amount, plan.terms.currency, billingLocale) : null,interval: plan?.offer.interval ?? null,includedCredits: plan?.terms.creditAmount ?? null,periodEndAt: formatBillingDate(currentSubscription.currentPeriodEndAt, billingLocale),@@ -569,14 +565,9 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null<><div><div className="flex items-start justify-between gap-6">- <div>- <h2 className="text-20 font-medium tracking-[-0.01em] text-[var(--settings-section-title)]">- {t('billing.settings.title')}- </h2>- <p className="mt-1.5 max-w-[620px] text-13 leading-5 text-[var(--settings-section-desc)]">- {t('billing.settings.subtitle')}- </p>- </div>+ <h2 className="text-20 font-medium tracking-[-0.01em] text-[var(--settings-section-title)]">+ {t('billing.settings.title')}+ </h2><buttontype="button"onClick={() => void loadBillingState()}@@ -606,35 +597,63 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null/>)}- <div className="mt-5 overflow-hidden rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)]">- <BillingUsageSummary- usage={creditUsage}- balance={balance}- issue={balanceError}- loading={loadingBalance}- detailsUnavailable={usageDetailsUnavailable}- />- </div>+ <div className="mt-6 flex flex-col gap-8">+ <BillingGroup title={t('billing.settings.subscriptionCard.title')}>+ <SubscriptionOverviewCard+ facts={currentPlanFacts}+ loading={loadingSubscription}+ error={subscriptionError}+ planChangeable={planChangeable}+ actionDisabled={loadingSubscription || subscriptionError}+ pendingPlanChange={pendingPlanChange}+ pendingTargetName={planNameOf(pendingPlanChange?.targetPlan?.product.code)}+ onChangePlan={openPlanChange}+ onPurchase={() => openPurchaseDialog('SUBSCRIPTION')}+ onResumePending={() => {+ if (pendingPlanChange) planChange.resumePending(pendingPlanChange);+ }}+ onCancelPending={() => {+ if (pendingPlanChange)+ void planChange.cancelChange(pendingPlanChange.planChangeId);+ }}+ />+ </BillingGroup>++ <BillingGroup titleId="billing-balance-title" title={t('billing.balance.title')}>+ <BalanceOverviewCard+ usage={creditUsage}+ balance={balance}+ issue={balanceError}+ loading={loadingBalance}+ onPurchase={() => openPurchaseDialog('CREDIT_TOPUP')}+ />+ </BillingGroup>++ {(creditUsage || balance) && (+ <BillingGroup+ title={t('billing.usage.title')}+ description={+ usageDetailsUnavailable ? t('billing.usage.detailsUnavailable') : undefined+ }+ >+ <UsageBreakdownCard usage={creditUsage} balance={balance} />+ </BillingGroup>+ )}- <div className="mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2">- <SubscriptionOverviewCard- facts={currentPlanFacts}- loading={loadingSubscription}- error={subscriptionError}- planChangeable={planChangeable}- actionDisabled={loadingSubscription || subscriptionError}- pendingPlanChange={pendingPlanChange}- pendingTargetName={planNameOf(pendingPlanChange?.targetPlan?.product.code)}- onChangePlan={openPlanChange}- onPurchase={() => openPurchaseDialog('SUBSCRIPTION')}- onResumePending={() => {- if (pendingPlanChange) planChange.resumePending(pendingPlanChange);- }}- onCancelPending={() => {- if (pendingPlanChange) void planChange.cancelChange(pendingPlanChange.planChangeId);- }}- />- <TopupOverviewCard onPurchase={() => openPurchaseDialog('CREDIT_TOPUP')} />+ {creditUsage && (+ <BillingGroup+ title={t('billing.usage.promotionalDetails.title')}+ badge={+ <span className="shrink-0 rounded-full bg-[var(--surface-chip)] px-2.5 py-1 text-10 font-medium text-[var(--text-secondary)]">+ {t('billing.usage.promotionalDetails.count', {+ count: creditUsage.promotionalGrants.length,+ })}+ </span>+ }+ >+ <PromotionalGrantsCard usage={creditUsage} />+ </BillingGroup>+ )}</div></div>@@ -689,7 +708,6 @@ export function BillingSettingsSection({ accountId }: { accountId: string | null<PlanChangeTargetDialogopen={planChangeTargetOpen}candidates={planChangeCandidates}- currentPlanName={currentPlanName}onClose={() => setPlanChangeTargetOpen(false)}onSelect={selectPlanChangeTarget}/>@@ -724,7 +742,8 @@ function BillingRecoveryNotice({onResumeSubscription: (subscription: BillingSubscription) => void;onResumeFailed: () => void;}) {- const { t } = useTranslation();+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;return (<section className="mt-5 rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] px-5 py-4"><p className="text-sm font-medium text-[var(--text-primary)]">@@ -742,7 +761,7 @@ function BillingRecoveryNotice({className="select-none rounded-full border border-[var(--border-default)] px-3 py-1.5 text-12 font-medium transition-colors hover:bg-[var(--surface-hover-soft)]">{t('billing.recovery.continueTopup', {- amount: formatMoney(order.amount, order.currency),+ amount: formatMoney(order.amount, order.currency, billingLocale),})}</button>))}@@ -800,70 +819,72 @@ function SubscriptionOverviewCard({(facts.cancelAtPeriodEnd || facts.status === 'ACTIVE' || facts.status === 'TRIALING');return (- <section className="flex min-h-[220px] flex-col rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] p-5">- <p className="text-11 font-medium text-[var(--text-tertiary)]">- {t('billing.settings.subscriptionCard.title')}- </p>- <div className="mt-3 min-h-0 flex-1">- {loading ? (- <Spinner size={15} />- ) : error ? (- <p className="text-12 leading-5 text-[var(--text-secondary)]">- {t('billing.settings.subscriptionCard.unavailable')}- </p>- ) : facts ? (- <>- <div className="flex flex-wrap items-center gap-2">- <h3 className="text-16 font-medium text-[var(--text-primary)]">{facts.name}</h3>- <span className="select-none rounded-full bg-[var(--surface-chip)] px-2.5 py-1 text-10 font-medium text-[var(--text-secondary)]">- {t(`billing.subscriptionStatus.${facts.status}`)}- </span>- </div>- {facts.price && facts.interval && (- <p className="mt-3 text-13 text-[var(--text-primary)]">- {t('billing.settings.subscriptionCard.priceInterval', {- price: facts.price,- interval: t(`billing.intervals.${facts.interval}`),- })}- </p>- )}- {facts.includedCredits && facts.interval && (- <p className="mt-1 text-12 text-[var(--text-secondary)]">- {t('billing.settings.subscriptionCard.includedCredits', {- amount: facts.includedCredits,- interval: t(`billing.intervals.${facts.interval}`),- })}- </p>- )}- {showPeriodDate && (- <p className="mt-3 text-12 text-[var(--text-secondary)]">- {facts.cancelAtPeriodEnd- ? t('billing.settings.subscriptionCard.endsAt', {- date: facts.periodEndAt,- })- : t('billing.settings.subscriptionCard.renewsAt', {- date: facts.periodEndAt,- })}- </p>- )}- </>- ) : (- <>- <h3 className="text-16 font-medium text-[var(--text-primary)]">- {t('billing.settings.subscriptionCard.emptyTitle')}- </h3>- <p className="mt-2 text-12 leading-5 text-[var(--text-secondary)]">- {t('billing.settings.subscriptionCard.empty')}+ <section className="rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)]">+ <div className="flex min-h-[72px] flex-wrap items-center justify-between gap-x-6 gap-y-3 px-5 py-4">+ <div className="min-w-0 flex-1">+ {loading ? (+ <Spinner size={15} />+ ) : error ? (+ <p className="text-12 leading-5 text-[var(--text-secondary)]">+ {t('billing.settings.subscriptionCard.unavailable')}</p>- </>- )}- </div>- <div className="mt-5 flex flex-wrap gap-2">+ ) : facts ? (+ <>+ <div className="flex flex-wrap items-center gap-2">+ <h4 className="text-14 font-medium text-[var(--text-primary)]">{facts.name}</h4>+ <span className="select-none rounded-full bg-[var(--surface-chip)] px-2.5 py-1 text-10 font-medium text-[var(--text-secondary)]">+ {t(`billing.subscriptionStatus.${facts.status}`)}+ </span>+ </div>+ {(facts.price || facts.includedCredits) && facts.interval && (+ <p className="mt-1.5 text-12 text-[var(--text-secondary)]">+ {facts.price && (+ <span>+ {t('billing.settings.subscriptionCard.priceInterval', {+ price: facts.price,+ interval: t(`billing.intervals.${facts.interval}`),+ })}+ </span>+ )}+ {facts.price && facts.includedCredits && <span aria-hidden> · </span>}+ {facts.includedCredits && (+ <span>+ {t('billing.settings.subscriptionCard.includedCredits', {+ amount: facts.includedCredits,+ interval: t(`billing.intervals.${facts.interval}`),+ })}+ </span>+ )}+ </p>+ )}+ {showPeriodDate && (+ <p className="mt-1 text-12 text-[var(--text-tertiary)]">+ {facts.cancelAtPeriodEnd+ ? t('billing.settings.subscriptionCard.endsAt', {+ date: facts.periodEndAt,+ })+ : t('billing.settings.subscriptionCard.renewsAt', {+ date: facts.periodEndAt,+ })}+ </p>+ )}+ </>+ ) : (+ <>+ <h4 className="text-14 font-medium text-[var(--text-primary)]">+ {t('billing.settings.subscriptionCard.emptyTitle')}+ </h4>+ <p className="mt-1 text-12 leading-5 text-[var(--text-secondary)]">+ {t('billing.settings.subscriptionCard.empty')}+ </p>+ </>+ )}+ </div><buttontype="button"onClick={planChangeable ? onChangePlan : onPurchase}disabled={actionDisabled}- className="h-8 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)] disabled:cursor-not-allowed disabled:opacity-40"+ className="h-8 shrink-0 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)] disabled:cursor-not-allowed disabled:opacity-40">{planChangeable? t('billing.settings.subscriptionCard.changeAction')@@ -882,32 +903,6 @@ function SubscriptionOverviewCard({);}-function TopupOverviewCard({ onPurchase }: { onPurchase: () => void }) {- const { t } = useTranslation();- return (- <section className="flex min-h-[220px] flex-col rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)] p-5">- <p className="text-11 font-medium text-[var(--text-tertiary)]">- {t('billing.settings.topupCard.title')}- </p>- <div className="mt-3 flex-1">- <h3 className="text-16 font-medium text-[var(--text-primary)]">- {t('billing.settings.topupCard.cardTitle')}- </h3>- <p className="mt-2 max-w-[420px] text-12 leading-5 text-[var(--text-secondary)]">- {t('billing.settings.topupCard.cardDescription')}- </p>- </div>- <button- type="button"- onClick={onPurchase}- className="mt-5 h-8 w-fit select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)]"- >- {t('billing.settings.topupCard.action')}- </button>- </section>- );-}-function PendingPlanChangeBanner({pending,targetName,@@ -919,16 +914,12 @@ function PendingPlanChangeBanner({onResume: () => void;onUndo: () => void;}) {- const { t } = useTranslation();- const effectiveDate = useMemo(() => {- const timestamp = Date.parse(pending.effectiveAt);- if (!Number.isFinite(timestamp)) return pending.effectiveAt;- try {- return new Intl.DateTimeFormat(undefined, { dateStyle: 'medium' }).format(timestamp);- } catch {- return pending.effectiveAt;- }- }, [pending.effectiveAt]);+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;+ const effectiveDate = useMemo(+ () => formatBillingDate(pending.effectiveAt, billingLocale) ?? pending.effectiveAt,+ [billingLocale, pending.effectiveAt],+ );const label =pending.status === 'SCHEDULED'? t('billing.planChange.pendingDowngrade', {@@ -943,7 +934,7 @@ function PendingPlanChangeBanner({name: targetName ?? t('billing.settings.subscriptionCard.unnamedPlan'),});return (- <div className="mt-5 flex flex-wrap items-center gap-3 rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] px-4 py-3">+ <div className="flex flex-wrap items-center gap-3 border-t border-[var(--border-default)] px-5 py-3"><p className="min-w-0 flex-1 text-12 leading-5 text-[var(--text-secondary)]">{label}</p>{pending.status === 'SCHEDULED' ? (<button@@ -966,43 +957,56 @@ function PendingPlanChangeBanner({);}-function BillingUsageSummary({+const BILLING_CURRENCY = CURRENT_CINDY_REGION === 'global' ? 'usd' : 'cny';++function BillingGroup({+ title,+ titleId,+ description,+ badge,+ children,+}: {+ title: string;+ titleId?: string;+ description?: string;+ badge?: React.ReactNode;+ children: React.ReactNode;+}) {+ return (+ <section aria-labelledby={titleId}>+ <div className="flex flex-wrap items-center justify-between gap-x-4 gap-y-1">+ <h3 id={titleId} className="text-14 font-medium text-[var(--text-primary)]">+ {title}+ </h3>+ {badge}+ </div>+ {description && (+ <p className="mt-1 max-w-[620px] text-12 leading-5 text-[var(--text-secondary)]">+ {description}+ </p>+ )}+ <div className="mt-3">{children}</div>+ </section>+ );+}++function BalanceOverviewCard({usage,balance,issue,loading,- detailsUnavailable,+ onPurchase,}: {usage: ModelAccessCreditUsage | null;balance: ModelAccessBalance | null;issue: BalanceIssue;loading: boolean;- detailsUnavailable: boolean;+ onPurchase: () => void;}) {- const { t } = useTranslation();- const currency = CURRENT_CINDY_REGION === 'global' ? 'usd' : 'cny';- const legacyPools = balance- ? [- { key: 'plan', label: t('billing.balance.plan'), amount: balance.planCredits },- {- key: 'purchased',- label: t('billing.balance.purchased'),- amount: balance.purchasedCredits,- },- {- key: 'promotional',- label: t('billing.balance.promotional'),- amount: balance.promotionalCredits,- },- ]- : [];- const usagePools = usage- ? [- { key: 'plan', label: t('billing.balance.plan'), pool: usage.plan },- { key: 'purchased', label: t('billing.balance.purchased'), pool: usage.purchased },- { key: 'promotional', label: t('billing.balance.promotional'), pool: usage.promotional },- ]- : [];+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;+ const available = usage?.available ?? balance?.available ?? null;+ const observedAt = usage?.observedAt ?? balance?.observedAt ?? null;const issueDescription =issue === 'NOT_PROVISIONED'? t('billing.balance.notProvisioned')@@ -1011,190 +1015,162 @@ function BillingUsageSummary({: t('billing.balance.unavailable');return (- <section aria-labelledby="billing-balance-title" aria-live="polite" aria-busy={loading}>- {loading ? (- <div className="flex h-[118px] items-center px-5 py-5">- <Spinner size={15} />- </div>- ) : usage ? (- <>- <div className="px-5 py-5">- <p- id="billing-balance-title"- className="text-11 font-medium text-[var(--text-tertiary)]"- >- {t('billing.balance.title')}- </p>- <p className="mt-1 text-[28px] font-medium leading-9 tracking-[-0.03em] tabular-nums text-[var(--text-primary)]">- {formatMoney(usage.available, currency)}- </p>- <p className="mt-1 text-11 text-[var(--text-tertiary)]">- {t('billing.usage.observedAt', {- date: formatLedgerTimestamp(usage.observedAt),- })}- </p>- </div>- <div className="border-t border-[var(--border-default)] px-5 py-5">- <div className="grid grid-cols-1 gap-3 lg:grid-cols-3">- {usagePools.map(({ key, label, pool }) => (- <CreditPoolCard key={key} label={label} pool={pool} currency={currency} />- ))}- </div>- </div>- <PromotionalGrantLedger usage={usage} currency={currency} />- </>- ) : balance ? (- <div className="px-5 py-5">- <p id="billing-balance-title" className="text-11 font-medium text-[var(--text-tertiary)]">- {t('billing.balance.title')}- </p>- <p className="mt-1 text-[28px] font-medium leading-9 tracking-[-0.03em] tabular-nums text-[var(--text-primary)]">- {formatMoney(balance.available, currency)}- </p>- <div className="mt-4 grid grid-cols-3 divide-x divide-[var(--border-default)] rounded-xl bg-[var(--surface-chip)] px-1 py-2.5">- {legacyPools.map(({ key, label, amount }) => (- <div key={key} className="min-w-0 px-3">- <p className="truncate text-11 text-[var(--text-tertiary)]">{label}</p>- <p className="mt-1 truncate text-13 font-medium tabular-nums text-[var(--text-primary)]">- {formatMoney(amount, currency)}+ <section+ aria-live="polite"+ aria-busy={loading}+ className="rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)]"+ >+ <div className="flex min-h-[72px] flex-wrap items-center justify-between gap-x-6 gap-y-3 px-5 py-4">+ <div className="min-w-0 flex-1">+ {loading ? (+ <Spinner size={15} />+ ) : available !== null ? (+ <>+ <p className="text-20 font-medium leading-7 tracking-[-0.02em] tabular-nums text-[var(--text-primary)]">+ {formatMoney(available, BILLING_CURRENCY, billingLocale)}+ </p>+ {observedAt && (+ <p className="mt-1 text-11 text-[var(--text-tertiary)]">+ {t('billing.usage.observedAt', {+ date: formatLedgerTimestamp(observedAt, billingLocale),+ })}</p>- </div>- ))}- </div>- {detailsUnavailable && (- <p className="mt-3 text-11 leading-4 text-[var(--text-secondary)]">- {t('billing.usage.detailsUnavailable')}+ )}+ </>+ ) : (+ <p role="status" className="text-12 leading-5 text-[var(--text-secondary)]">+ {issueDescription}</p>)}</div>- ) : (- <div- role="status"- className="flex min-h-[118px] items-center px-5 text-12 leading-5 text-[var(--text-secondary)]"+ <button+ type="button"+ onClick={onPurchase}+ className="h-8 shrink-0 select-none rounded-full border border-[var(--border-default)] px-3.5 text-12 font-medium text-[var(--text-primary)] transition-colors hover:bg-[var(--surface-hover-soft)]">- {issueDescription}- </div>- )}+ {t('billing.settings.topupCard.action')}+ </button>+ </div></section>);}-function CreditPoolCard({- label,- pool,- currency,+function UsageBreakdownCard({+ usage,+ balance,}: {- label: string;- pool: ModelAccessCreditPoolUsage;- currency: string;+ usage: ModelAccessCreditUsage | null;+ balance: ModelAccessBalance | null;}) {- const { t } = useTranslation();- const percent = usagePercent(pool);- const stats = [- { key: 'used', label: t('billing.usage.used'), amount: pool.used },- { key: 'total', label: t('billing.usage.total'), amount: pool.total },- { key: 'remaining', label: t('billing.usage.remaining'), amount: pool.remaining },- ];+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;+ const poolLabels = {+ plan: t('billing.balance.plan'),+ purchased: t('billing.balance.purchased'),+ promotional: t('billing.balance.promotional'),+ };return (- <article className="min-w-0 rounded-xl border border-[var(--border-default)] bg-[var(--surface)] p-4">- <p className="truncate text-12 font-medium text-[var(--text-primary)]">{label}</p>- <p className="mt-3 text-11 text-[var(--text-tertiary)]">{t('billing.usage.remaining')}</p>- <p className="mt-0.5 truncate text-lg font-medium tracking-[-0.02em] tabular-nums text-[var(--text-primary)]">- {formatMoney(pool.remaining, currency)}- </p>- <div- className="mt-3 h-1.5 overflow-hidden rounded-full bg-[var(--surface-chip)]"- role={percent === null ? undefined : 'progressbar'}- aria-label={t('billing.usage.progressLabel', { label })}- aria-valuemin={percent === null ? undefined : 0}- aria-valuemax={percent === null ? undefined : 100}- aria-valuenow={percent ?? undefined}- >- {percent !== null && (- <div- className="h-full rounded-full bg-[var(--text-primary)]"- style={{ width: `${percent}%` }}- />- )}- </div>- {percent === null ? (- <p className="mt-2 min-h-8 text-10 leading-4 text-[var(--text-tertiary)]">- {t('billing.usage.historyUnavailable')}- </p>- ) : (- <p className="mt-2 min-h-8 text-10 leading-4 text-[var(--text-tertiary)]">- {t('billing.usage.percentUsed', {- percent: new Intl.NumberFormat(undefined, {- maximumFractionDigits: 1,- }).format(percent),- })}- </p>- )}- <dl className="mt-3 grid grid-cols-3 gap-2 border-t border-[var(--border-default)] pt-3">- {stats.map(({ key, label: statLabel, amount }) => (- <div key={key} className="min-w-0">- <dt className="truncate text-10 text-[var(--text-tertiary)]">{statLabel}</dt>- <dd className="mt-0.5 truncate text-11 font-medium tabular-nums text-[var(--text-primary)]">- {amount === null ? '—' : formatMoney(amount, currency)}- </dd>- </div>- ))}- </dl>- </article>+ <section className="divide-y divide-[var(--border-default)] rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)]">+ {usage+ ? (+ [+ ['plan', usage.plan],+ ['purchased', usage.purchased],+ ['promotional', usage.promotional],+ ] as const+ ).map(([key, pool]) => (+ <CreditPoolRow key={key} label={poolLabels[key]} pool={pool} />+ ))+ : balance+ ? (+ [+ ['plan', balance.planCredits],+ ['purchased', balance.purchasedCredits],+ ['promotional', balance.promotionalCredits],+ ] as const+ ).map(([key, amount]) => (+ <div+ key={key}+ className="flex flex-wrap items-center justify-between gap-x-6 gap-y-1 px-5 py-3.5"+ >+ <p className="text-13 font-medium text-[var(--text-primary)]">{poolLabels[key]}</p>+ <p className="text-13 font-medium tabular-nums text-[var(--text-primary)]">+ {formatMoney(amount, BILLING_CURRENCY, billingLocale)}+ </p>+ </div>+ ))+ : null}+ </section>);}-function PromotionalGrantLedger({- usage,- currency,-}: {- usage: ModelAccessCreditUsage;- currency: string;-}) {- const { t } = useTranslation();+function CreditPoolRow({ label, pool }: { label: string; pool: ModelAccessCreditPoolUsage }) {+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;+ const percent = usagePercent(pool);+ const detail =+ pool.used !== null && pool.total !== null+ ? `${t('billing.usage.used')} ${formatMoney(pool.used, BILLING_CURRENCY, billingLocale)} · ${t('billing.usage.total')} ${formatMoney(pool.total, BILLING_CURRENCY, billingLocale)}`+ : t('billing.usage.historyUnavailable');return (- <div className="border-t border-[var(--border-default)] px-5 py-5">- <div className="flex items-start justify-between gap-4">- <div>- <h3 className="text-13 font-medium text-[var(--text-primary)]">- {t('billing.usage.promotionalDetails.title')}- </h3>- <p className="mt-1 max-w-[620px] text-11 leading-4 text-[var(--text-secondary)]">- {t('billing.usage.promotionalDetails.description')}- </p>+ <div className="flex flex-wrap items-center justify-between gap-x-6 gap-y-2 px-5 py-3.5">+ <div className="min-w-0">+ <p className="truncate text-13 font-medium text-[var(--text-primary)]">{label}</p>+ <p className="mt-1 text-11 leading-4 text-[var(--text-tertiary)]">{detail}</p>+ </div>+ <div className="flex shrink-0 items-center gap-3">+ <div+ className="h-1 w-40 overflow-hidden rounded-full bg-[var(--surface-chip)]"+ role={percent === null ? undefined : 'progressbar'}+ aria-label={t('billing.usage.progressLabel', { label })}+ aria-valuemin={percent === null ? undefined : 0}+ aria-valuemax={percent === null ? undefined : 100}+ aria-valuenow={percent ?? undefined}+ >+ {percent !== null && (+ <div+ className="h-full rounded-full bg-[var(--text-primary)]"+ style={{ width: `${percent}%` }}+ />+ )}</div>- <span className="shrink-0 rounded-full bg-[var(--surface-chip)] px-2.5 py-1 text-10 font-medium text-[var(--text-secondary)]">- {t('billing.usage.promotionalDetails.count', {- count: usage.promotionalGrants.length,- })}- </span>+ <p className="text-11 text-[var(--text-tertiary)]">+ {t('billing.usage.remaining')}+ <span className="ml-1.5 text-13 font-medium tabular-nums text-[var(--text-primary)]">+ {formatMoney(pool.remaining, BILLING_CURRENCY, billingLocale)}+ </span>+ </p></div>+ </div>+ );+}+function PromotionalGrantsCard({ usage }: { usage: ModelAccessCreditUsage }) {+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;+ return (+ <section className="overflow-hidden rounded-xl border border-[var(--border-default)] bg-[var(--surface-elevated)]">{!usage.promotionalGrantsComplete && (- <p className="mt-3 rounded-lg bg-[var(--surface-chip)] px-3 py-2 text-11 leading-4 text-[var(--text-secondary)]">+ <p className="border-b border-[var(--border-default)] px-5 py-3 text-11 leading-4 text-[var(--text-tertiary)]">{t('billing.usage.promotionalDetails.incomplete', {count: usage.promotionalGrants.length,})}</p>)}-{usage.promotionalGrants.length === 0 ? (- <p className="mt-4 rounded-xl border border-[var(--border-default)] px-4 py-5 text-12 text-[var(--text-secondary)]">+ <p className="px-5 py-4 text-12 text-[var(--text-secondary)]">{t('billing.usage.promotionalDetails.empty')}</p>) : (<div- className="mt-4 max-h-[360px] overflow-y-auto rounded-xl border border-[var(--border-default)] [scrollbar-gutter:stable]"+ className="max-h-[360px] divide-y divide-[var(--border-default)] overflow-y-auto [scrollbar-gutter:stable]"role="list">- {usage.promotionalGrants.map((grant, index) => (+ {usage.promotionalGrants.map((grant) => (<divkey={grant.grantId}role="listitem"- className={cn(- 'grid grid-cols-3 gap-x-3 gap-y-2 px-4 py-3 lg:grid-cols-[minmax(0,1.5fr)_repeat(3,minmax(80px,0.7fr))] lg:items-center',- index > 0 && 'border-t border-[var(--border-default)]',- )}+ className="grid grid-cols-3 gap-x-3 gap-y-2 px-5 py-3 lg:grid-cols-[minmax(0,1.5fr)_repeat(3,minmax(80px,0.7fr))] lg:items-center"><div className="col-span-3 min-w-0 lg:col-span-1"><div className="flex min-w-0 items-center gap-2">@@ -1205,30 +1181,27 @@ function PromotionalGrantLedger({</div><p className="mt-1 truncate text-10 text-[var(--text-tertiary)]">{t('billing.usage.promotionalDetails.expiresAt', {- date: formatLedgerTimestamp(grant.expiresAt),+ date: formatLedgerTimestamp(grant.expiresAt, billingLocale),})}</p></div><GrantAmountlabel={t('billing.usage.promotionalDetails.original')}amount={grant.originalAmount}- currency={currency}/><GrantAmountlabel={t('billing.usage.promotionalDetails.used')}amount={grant.usedAmount}- currency={currency}/><GrantAmountlabel={t('billing.usage.promotionalDetails.remaining')}amount={grant.remainingAmount}- currency={currency}/></div>))}</div>)}- </div>+ </section>);}@@ -1241,20 +1214,14 @@ function PromotionalGrantStatus({ state }: { state: ModelAccessPromotionalGrantS);}-function GrantAmount({- label,- amount,- currency,-}: {- label: string;- amount: string;- currency: string;-}) {+function GrantAmount({ label, amount }: { label: string; amount: string }) {+ const { i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;return (<div className="min-w-0 text-right"><p className="truncate text-10 text-[var(--text-tertiary)]">{label}</p><p className="mt-0.5 truncate text-11 font-medium tabular-nums text-[var(--text-primary)]">- {formatMoney(amount, currency)}+ {formatMoney(amount, BILLING_CURRENCY, billingLocale)}</p></div>);@@ -1297,21 +1264,19 @@ function BillingOfferDialog({onCustomAmountChange: (amount: string) => void;onSubmit: () => void;}) {- const { t } = useTranslation();+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;const title =kind === 'SUBSCRIPTION'? t('billing.dialogs.subscription.title'): t('billing.dialogs.topup.title');- const description =- kind === 'SUBSCRIPTION'- ? t('billing.dialogs.subscription.description')- : t('billing.dialogs.topup.description');return (<Dialog.Root open={open} onOpenChange={(nextOpen) => !nextOpen && onClose()}><Dialog.Portal><Dialog.Overlay className="fixed inset-0 z-[9990] bg-[var(--overlay-modal)]" /><Dialog.Content+ aria-describedby={undefined}className={cn('fixed left-1/2 top-1/2 z-[9991] flex max-h-[min(720px,calc(100vh-48px))]','w-[calc(100vw-48px)] max-w-[680px] -translate-x-1/2 -translate-y-1/2 flex-col',@@ -1319,15 +1284,8 @@ function BillingOfferDialog({'bg-[var(--surface-elevated)] text-[var(--text-primary)] focus:outline-none',)}>- <div className="flex items-start justify-between gap-4 px-6 pb-4 pt-5">- <div>- <Dialog.Title className="text-16 font-medium tracking-[-0.01em]">- {title}- </Dialog.Title>- <Dialog.Description className="mt-1.5 max-w-[520px] text-12 leading-5 text-[var(--text-secondary)]">- {description}- </Dialog.Description>- </div>+ <div className="flex items-center justify-between gap-4 px-6 pb-4 pt-5">+ <Dialog.Title className="text-16 font-medium tracking-[-0.01em]">{title}</Dialog.Title><Dialog.Close asChild><buttontype="button"@@ -1365,7 +1323,7 @@ function BillingOfferDialog({/>) : (<>- <div className="space-y-2.5">+ <div className="divide-y divide-[var(--border-default)] overflow-hidden rounded-xl border border-[var(--border-default)]">{offers.map((entry) => {const { product, offer } = entry;const active = selected?.offer.code === offer.code;@@ -1378,26 +1336,18 @@ function BillingOfferDialog({disabled={unavailableReason !== null}aria-pressed={active}className={cn(- 'group relative flex min-h-[88px] w-full items-center gap-5 rounded-xl border px-4 py-3.5 text-left',- 'transition-[background-color,border-color,box-shadow] focus-visible:outline-none',- 'focus-visible:ring-2 focus-visible:ring-[var(--text-primary)] focus-visible:ring-offset-2',- 'focus-visible:ring-offset-[var(--surface-elevated)]',- 'disabled:cursor-not-allowed disabled:bg-[var(--surface)] disabled:hover:bg-[var(--surface)]',- active- ? 'border-[var(--text-primary)] bg-[var(--surface)] shadow-[inset_3px_0_0_var(--text-primary)]'- : 'border-[var(--border-default)] hover:bg-[var(--surface-hover-soft)]',+ 'flex w-full items-center justify-between gap-4 px-4 py-3 text-left transition-colors',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset',+ 'focus-visible:ring-[var(--text-primary)]',+ 'disabled:cursor-not-allowed disabled:opacity-55 disabled:hover:bg-transparent',+ active ? 'bg-[var(--surface)]' : 'hover:bg-[var(--surface-hover-soft)]',)}><div className="min-w-0 flex-1">- <p className="truncate text-sm font-medium text-[var(--text-primary)]">- {product.name}- </p>- <div className="mt-1 flex flex-wrap items-center gap-2">- <span className="text-11 text-[var(--text-tertiary)]">- {kind === 'SUBSCRIPTION'- ? t('billing.offerKinds.subscription')- : t('billing.offerKinds.topup')}- </span>+ <div className="flex flex-wrap items-center gap-2">+ <p className="truncate text-13 font-medium text-[var(--text-primary)]">+ {product.name}+ </p>{unavailableReason && (<span className="rounded-full bg-[var(--surface-chip)] px-2 py-0.5 text-10 font-medium text-[var(--text-secondary)]">{t(`billing.catalog.unavailableReasons.${unavailableReason}`)}@@ -1405,11 +1355,11 @@ function BillingOfferDialog({)}</div></div>- <div className="flex shrink-0 items-center gap-4">+ <div className="flex shrink-0 items-center gap-3"><div className="text-right">- <p className="text-lg font-medium tracking-[-0.02em]">+ <p className="text-13 font-medium tabular-nums text-[var(--text-primary)]">{offer.amount- ? formatMoney(offer.amount, offer.currency)+ ? formatMoney(offer.amount, offer.currency, billingLocale): t('billing.amount.custom')}{offer.interval && (<span className="ml-1 text-11 font-normal text-[var(--text-tertiary)]">@@ -1418,7 +1368,7 @@ function BillingOfferDialog({)}</p>{offer.creditAmount && (- <p className="mt-1 text-11 text-[var(--text-secondary)]">+ <p className="mt-0.5 text-11 text-[var(--text-tertiary)]">{t('billing.credits', { amount: offer.creditAmount })}</p>)}@@ -1431,14 +1381,13 @@ function BillingOfferDialog({</div>{selected && (- <div className="mt-5 border-t border-[var(--border-default)] pt-4">- <h3 className="text-13 font-medium">{t('billing.steps.channel.title')}</h3>- <p className="mt-1 text-12 text-[var(--text-secondary)]">- {t('billing.steps.channel.description')}- </p>- <div className="mt-3 space-y-2">+ <div className="mt-5">+ <h3 className="text-13 font-medium text-[var(--text-primary)]">+ {t('billing.steps.channel.title')}+ </h3>+ <div className="mt-3 divide-y divide-[var(--border-default)] overflow-hidden rounded-xl border border-[var(--border-default)]">{selected.purchaseOptions.map((option) => (- <PaymentOptionCard+ <PaymentOptionRowkey={option.id}option={option}active={selectedPurchaseOptionId === option.id}@@ -1449,11 +1398,11 @@ function BillingOfferDialog({{kind === 'CREDIT_TOPUP' && isCustomTopup(selected.offer) && (<label className="mt-5 block">- <span className="text-12 font-medium text-[var(--text-secondary)]">+ <span className="text-13 font-medium text-[var(--text-primary)]">{t('billing.amount.label')}</span>- <div className="mt-2 flex h-11 items-center rounded-xl border border-[var(--border-default)] bg-[var(--surface)] px-4 focus-within:border-[var(--text-primary)]">- <span className="mr-2 text-sm text-[var(--text-tertiary)]">+ <div className="mt-2 flex h-10 items-center rounded-full border border-[var(--border-default)] bg-[var(--surface)] px-4 focus-within:border-[var(--text-primary)]">+ <span className="mr-2 text-13 text-[var(--text-tertiary)]">{selected.offer.currency.toUpperCase()}</span><input@@ -1461,7 +1410,7 @@ function BillingOfferDialog({onChange={(event) => onCustomAmountChange(event.target.value)}inputMode="decimal"placeholder={t('billing.amount.placeholder')}- className="min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-[var(--text-tertiary)]"+ className="min-w-0 flex-1 bg-transparent text-13 outline-none placeholder:text-[var(--text-placeholder)]"/></div><p@@ -1474,15 +1423,23 @@ function BillingOfferDialog({>{amountError ??t('billing.amount.rangeHint', {- min: formatMoney(selected.offer.minAmount!, selected.offer.currency),- max: formatMoney(selected.offer.maxAmount!, selected.offer.currency),+ min: formatMoney(+ selected.offer.minAmount!,+ selected.offer.currency,+ billingLocale,+ ),+ max: formatMoney(+ selected.offer.maxAmount!,+ selected.offer.currency,+ billingLocale,+ ),})}</p></label>)}{kind === 'SUBSCRIPTION' && subscriptionPurchaseBlocked && (- <p className="mt-5 rounded-lg bg-[var(--surface-chip)] px-4 py-3 text-12 leading-5 text-[var(--text-secondary)]">+ <p className="mt-4 text-12 leading-5 text-[var(--text-secondary)]">{t('billing.currentSubscription.purchaseBlocked')}</p>)}@@ -1515,11 +1472,14 @@ function BillingOfferDialog({function CatalogSkeleton() {return (- <div className="space-y-2.5" aria-hidden>+ <div+ className="divide-y divide-[var(--border-default)] overflow-hidden rounded-xl border border-[var(--border-default)]"+ aria-hidden+ >{[0, 1, 2].map((item) => (<divkey={item}- className="h-[88px] animate-pulse rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] motion-reduce:animate-none"+ className="h-[52px] animate-pulse bg-[var(--surface-chip)] motion-reduce:animate-none"/>))}</div>@@ -1549,7 +1509,7 @@ function StateCard({);}-function PaymentOptionCard({+function PaymentOptionRow({option,active,onSelect,@@ -1566,21 +1526,22 @@ function PaymentOptionCard({onClick={onSelect}aria-pressed={active}className={cn(- 'flex min-h-[64px] w-full items-center gap-3 rounded-xl border px-3.5 py-2.5 text-left',- 'transition-colors focus-visible:outline-none focus-visible:ring-2',- 'focus-visible:ring-[var(--text-primary)] focus-visible:ring-offset-2',- 'focus-visible:ring-offset-[var(--surface-elevated)]',- active- ? 'border-[var(--text-primary)] bg-[var(--surface)]'- : 'border-[var(--border-default)] hover:bg-[var(--surface-hover-soft)]',+ 'flex w-full items-center gap-3 px-4 py-3 text-left transition-colors',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset',+ 'focus-visible:ring-[var(--text-primary)]',+ active ? 'bg-[var(--surface)]' : 'hover:bg-[var(--surface-hover-soft)]',)}>- <div className="grid size-9 shrink-0 place-items-center rounded-full bg-[var(--surface-chip)]">- <Icon size={16} />- </div>+ {option.provider === 'alipay' ? (+ <AlipayIcon className="size-4 shrink-0 text-[var(--text-secondary)]" />+ ) : (+ <Icon size={16} className="shrink-0 text-[var(--text-secondary)]" />+ )}<div className="min-w-0 flex-1">- <p className="truncate text-sm font-medium">{providerLabel(option.provider, t)}</p>- <p className="mt-1 text-11 text-[var(--text-tertiary)]">+ <p className="truncate text-13 font-medium text-[var(--text-primary)]">+ {providerLabel(option.provider, t)}+ </p>+ <p className="mt-0.5 text-11 text-[var(--text-tertiary)]">{option.paymentAction === 'QR_CODE'? t('billing.paymentActions.QR_CODE'): t('billing.paymentActions.REDIRECT')}diff --git a/apps/desktop/src/renderer/features/billing/PlanChangeDialog.tsx b/apps/desktop/src/renderer/features/billing/PlanChangeDialog.tsxindex 3acc4f6433..ed122c4212 100644--- a/apps/desktop/src/renderer/features/billing/PlanChangeDialog.tsx+++ b/apps/desktop/src/renderer/features/billing/PlanChangeDialog.tsx@@ -35,11 +35,11 @@ export type PlanChangeCandidate = {direction: 'UPGRADE' | 'DOWNGRADE';};-function formatEffectiveDate(iso: string): string {+function formatEffectiveDate(iso: string, locale: string): string {const timestamp = Date.parse(iso);if (!Number.isFinite(timestamp)) return iso;try {- return new Intl.DateTimeFormat(undefined, {+ return new Intl.DateTimeFormat(locale, {dateStyle: 'medium',timeStyle: 'short',}).format(timestamp);@@ -51,22 +51,22 @@ function formatEffectiveDate(iso: string): string {export function PlanChangeTargetDialog({open,candidates,- currentPlanName,onClose,onSelect,}: {open: boolean;candidates: PlanChangeCandidate[];- currentPlanName: string | null;onClose: () => void;onSelect: (candidate: PlanChangeCandidate) => void;}) {- const { t } = useTranslation();+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;return (<Dialog.Root open={open} onOpenChange={(nextOpen) => !nextOpen && onClose()}><Dialog.Portal><Dialog.Overlay className="fixed inset-0 z-[9990] bg-[var(--overlay-modal)]" /><Dialog.Content+ aria-describedby={undefined}className={cn('fixed left-1/2 top-1/2 z-[9991] flex max-h-[min(640px,calc(100vh-48px))]','w-[calc(100vw-48px)] max-w-[640px] -translate-x-1/2 -translate-y-1/2 flex-col',@@ -74,19 +74,10 @@ export function PlanChangeTargetDialog({'bg-[var(--surface-elevated)] text-[var(--text-primary)] focus:outline-none',)}>- <div className="flex items-start justify-between gap-4 px-6 pb-4 pt-5">- <div>- <Dialog.Title className="text-16 font-medium tracking-[-0.01em]">- {t('billing.planChange.targetTitle')}- </Dialog.Title>- <Dialog.Description className="mt-1.5 max-w-[500px] text-12 leading-5 text-[var(--text-secondary)]">- {currentPlanName- ? t('billing.planChange.targetDescriptionWithCurrent', {- plan: currentPlanName,- })- : t('billing.planChange.targetDescription')}- </Dialog.Description>- </div>+ <div className="flex items-center justify-between gap-4 px-6 pb-4 pt-5">+ <Dialog.Title className="text-16 font-medium tracking-[-0.01em]">+ {t('billing.planChange.targetTitle')}+ </Dialog.Title><Dialog.Close asChild><buttontype="button"@@ -110,7 +101,7 @@ export function PlanChangeTargetDialog({</p></div>) : (- <div className="space-y-2.5">+ <div className="divide-y divide-[var(--border-default)] overflow-hidden rounded-xl border border-[var(--border-default)]">{candidates.map((candidate) => {const DirectionIcon =candidate.direction === 'UPGRADE' ? ArrowUpRight : ArrowDownRight;@@ -120,17 +111,17 @@ export function PlanChangeTargetDialog({type="button"onClick={() => onSelect(candidate)}className={cn(- 'group relative flex min-h-[84px] w-full items-center gap-5 rounded-xl border px-4 py-3.5 text-left',- 'border-[var(--border-default)] transition-colors hover:bg-[var(--surface-hover-soft)]',- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--text-primary)]',- 'focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--surface-elevated)]',+ 'flex w-full items-center justify-between gap-4 px-4 py-3 text-left',+ 'transition-colors hover:bg-[var(--surface-hover-soft)]',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset',+ 'focus-visible:ring-[var(--text-primary)]',)}><div className="min-w-0 flex-1">- <p className="truncate text-sm font-medium text-[var(--text-primary)]">+ <p className="truncate text-13 font-medium text-[var(--text-primary)]">{candidate.product.name}</p>- <p className="mt-1 inline-flex items-center gap-1 text-11 text-[var(--text-tertiary)]">+ <p className="mt-0.5 inline-flex items-center gap-1 text-11 text-[var(--text-tertiary)]"><DirectionIcon size={12} />{candidate.direction === 'UPGRADE'? t('billing.planChange.upgradeBadge')@@ -138,9 +129,13 @@ export function PlanChangeTargetDialog({</p></div><div className="shrink-0 text-right">- <p className="text-lg font-medium tracking-[-0.02em]">+ <p className="text-13 font-medium tabular-nums text-[var(--text-primary)]">{candidate.offer.amount- ? formatMoney(candidate.offer.amount, candidate.offer.currency)+ ? formatMoney(+ candidate.offer.amount,+ candidate.offer.currency,+ billingLocale,+ ): '—'}{candidate.offer.interval && (<span className="ml-1 text-11 font-normal text-[var(--text-tertiary)]">@@ -149,7 +144,7 @@ export function PlanChangeTargetDialog({)}</p>{candidate.offer.creditAmount && (- <p className="mt-1 text-11 text-[var(--text-secondary)]">+ <p className="mt-0.5 text-11 text-[var(--text-tertiary)]">{t('billing.credits', { amount: candidate.offer.creditAmount })}</p>)}@@ -198,7 +193,8 @@ export function PlanChangeStatusDialog({onRefresh: () => void;onAbandon: () => void;}) {- const { t } = useTranslation();+ const { t, i18n } = useTranslation();+ const billingLocale = i18n.resolvedLanguage ?? i18n.language;const change = state.planChange;const action: BillingPaymentAction | null = change?.paymentAction ?? null;const [qrDataUrl, setQrDataUrl] = useState<string | null>(null);@@ -255,7 +251,7 @@ export function PlanChangeStatusDialog({const isUpgrade = change?.changeType === 'UPGRADE';const quotedAmount =change && change.quotedAmountMinor !== null && change.quotedCurrency- ? formatPlanChangeMinorAmount(change.quotedAmountMinor, change.quotedCurrency)+ ? formatPlanChangeMinorAmount(change.quotedAmountMinor, change.quotedCurrency, billingLocale): null;const settled =state.phase === 'SCHEDULED' ||@@ -328,7 +324,7 @@ export function PlanChangeStatusDialog({? t('billing.planChange.upgradeDueNow', { amount: quotedAmount }): t('billing.planChange.upgradeNoAmount'): t('billing.planChange.downgradeAt', {- date: formatEffectiveDate(change.effectiveAt),+ date: formatEffectiveDate(change.effectiveAt, billingLocale),})}</p><p className="mt-2 max-w-[400px] text-12 leading-5 text-[var(--text-secondary)]">@@ -421,7 +417,7 @@ export function PlanChangeStatusDialog({? t('billing.planChange.appliedBody'): change? t('billing.planChange.scheduledBody', {- date: formatEffectiveDate(change.effectiveAt),+ date: formatEffectiveDate(change.effectiveAt, billingLocale),}): t('billing.planChange.scheduledTitle')}</p>diff --git a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsxindex 0b06ee07c9..b57fb58323 100644--- a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx+++ b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx@@ -343,9 +343,7 @@ describe('BillingPage remote catalog rendering', () => {expect(screen.getByText('billing.balance.promotional')).toBeTruthy();expect(screen.getByText(- new Intl.NumberFormat(undefined, { style: 'currency', currency: 'CNY' }).format(- 12.345678901,- ),+ new Intl.NumberFormat('en', { style: 'currency', currency: 'CNY' }).format(12.345678901),),).toBeTruthy();expect(screen.getByText('billing.usage.detailsUnavailable')).toBeTruthy();@@ -449,11 +447,11 @@ describe('BillingPage remote catalog rendering', () => {const offerNames = await screen.findAllByText('Ordered top-up');const offerButtons = offerNames.map((name) => name.closest('button')!);- const twenty = new Intl.NumberFormat(undefined, {+ const twenty = new Intl.NumberFormat('en', {style: 'currency',currency: 'CNY',}).format(20);- const hundred = new Intl.NumberFormat(undefined, {+ const hundred = new Intl.NumberFormat('en', {style: 'currency',currency: 'CNY',}).format(100);@@ -619,7 +617,7 @@ describe('BillingPage remote catalog rendering', () => {expect(screen.getByText('billing.usage.promotionalDetails.states.voided')).toBeTruthy();const grantRows = within(screen.getByRole('list')).getAllByRole('listitem');- const formatter = new Intl.NumberFormat(undefined, { style: 'currency', currency: 'CNY' });+ const formatter = new Intl.NumberFormat('en', { style: 'currency', currency: 'CNY' });for (const [row, usedAmount] of [[grantRows[0], 4],[grantRows[1], 2],@@ -693,7 +691,7 @@ describe('BillingPage remote catalog rendering', () => {expect(await screen.findByText('billing.balance.notProvisioned')).toBeTruthy();expect(screen.queryByText(- new Intl.NumberFormat(undefined, { style: 'currency', currency: 'CNY' }).format(0),+ new Intl.NumberFormat('en', { style: 'currency', currency: 'CNY' }).format(0),),).toBeNull();await waitFor(() =>diff --git a/apps/desktop/src/renderer/features/billing/__tests__/PlanChangeDialog.test.tsx b/apps/desktop/src/renderer/features/billing/__tests__/PlanChangeDialog.test.tsxindex 7896be8d54..eed78a68d7 100644--- a/apps/desktop/src/renderer/features/billing/__tests__/PlanChangeDialog.test.tsx+++ b/apps/desktop/src/renderer/features/billing/__tests__/PlanChangeDialog.test.tsx@@ -5,6 +5,7 @@ import { describe, expect, it, vi } from 'vitest';vi.mock('react-i18next', () => ({useTranslation: () => ({+ i18n: { language: 'en', resolvedLanguage: 'en' },t: (key: string, params?: Record<string, string>) =>params ? `${key}:${JSON.stringify(params)}` : key,}),diff --git a/apps/desktop/src/renderer/features/billing/money.ts b/apps/desktop/src/renderer/features/billing/money.tsindex ea811d80bb..621f993884 100644--- a/apps/desktop/src/renderer/features/billing/money.ts+++ b/apps/desktop/src/renderer/features/billing/money.ts@@ -48,9 +48,9 @@ function formatMinorUnits(.join('');}-export function formatBillingAmount(amount: string, currency: string): string {+export function formatBillingAmount(amount: string, currency: string, locale?: string): string {try {- const fmt = new Intl.NumberFormat(undefined, {+ const fmt = new Intl.NumberFormat(locale, {style: 'currency',currency: currency.toUpperCase(),});@@ -64,10 +64,14 @@ export function formatBillingAmount(amount: string, currency: string): string {}}-export function formatBillingMinorAmount(minor: number, currency: string): string {+export function formatBillingMinorAmount(+ minor: number,+ currency: string,+ locale?: string,+): string {try {if (!Number.isSafeInteger(minor)) return `${minor} ${currency.toUpperCase()}`;- const fmt = new Intl.NumberFormat(undefined, {+ const fmt = new Intl.NumberFormat(locale, {style: 'currency',currency: currency.toUpperCase(),});diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex db08176b9a..bc935a92f8 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -7100,7 +7100,6 @@"sidebar": "Credits & plans","settings": {"title": "Usage and billing",- "subtitle": "Review your available credits and current plan, or buy more credits as needed.","subscriptionCard": {"title": "Current plan","empty": "No active subscription",@@ -7115,10 +7114,6 @@"endsAt": "Plan ends {{date}}"},"topupCard": {- "title": "Credits",- "description": "Purchase credits for usage-based models and features.",- "cardTitle": "Buy credits as needed",- "cardDescription": "Add to your available credits as needed. The checkout page shows the final amount.","action": "Buy credits"}},@@ -7132,17 +7127,16 @@"unavailable": "Balance is temporarily unavailable. Refresh to try again."},"usage": {+ "title": "Credit usage","observedAt": "Balance updated {{date}}","used": "Used","total": "Total","remaining": "Remaining","progressLabel": "{{label}} usage","historyUnavailable": "Usage history is incomplete. Only the remaining balance is available.",- "percentUsed": "{{percent}}% used","detailsUnavailable": "Usage details are temporarily unavailable. Current balances are shown instead.","promotionalDetails": {"title": "Promotional Credit Details",- "description": "Current grants and the total balance use the same credit snapshot. Used amounts include model consumption only.","count": "{{count}} grants","empty": "No promotional credit grants are available.","incomplete": "There are many grant records. Only the latest {{count}} are shown.",@@ -7161,31 +7155,15 @@},"dialogs": {"subscription": {- "title": "Choose a subscription plan",- "description": "Server-published subscription plans are shown. Plans that cannot be purchased yet include a status."+ "title": "Choose a subscription plan"},"topup": {- "title": "Buy credits",- "description": "Server-published credit products are shown. Products that cannot be purchased yet include a status."+ "title": "Buy credits"}},- "eyebrow": "Account & usage",- "title": "Choose the plan that fits",- "subtitle": "Plans and payment methods are delivered by the server. Choose a plan first to see its currently supported payment methods.","steps": {- "offer": {- "title": "Choose a plan",- "description": "Server-published credit and subscription offers are shown."- },"channel": {- "title": "Choose a payment method",- "description": "Supported payment methods can differ by plan.",- "selectOfferFirst": "Choose a plan to see its supported payment methods"- },- "confirm": {- "title": "Review and pay",- "description": "Review the plan and payment method before creating payment.",- "selectChannelFirst": "Choose a payment method to continue"+ "title": "Choose a payment method"}},"actions": {@@ -7206,10 +7184,6 @@"NO_AVAILABLE_PAYMENT_CHANNEL": "No Payment Method Available"}},- "offerKinds": {- "topup": "Credit top-up",- "subscription": "Subscription"- },"amount": {"custom": "Custom amount","label": "Top-up amount",@@ -7281,8 +7255,6 @@},"planChange": {"targetTitle": "Change subscription plan",- "targetDescription": "Plan changes keep your current payment method. The final price and effective time are confirmed on the next step.",- "targetDescriptionWithCurrent": "Current plan: {{plan}}. Plan changes keep your current payment method; the final price and effective time are confirmed on the next step.","upgradeBadge": "Upgrade","downgradeBadge": "Downgrade","emptyTitle": "No plans available to switch to",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex f53983462e..0a571a62fd 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -7089,7 +7089,6 @@"sidebar": "クレジットとプラン","settings": {"title": "使用状況と請求",- "subtitle": "利用可能なクレジットと現在のプランを確認し、必要に応じてクレジットを購入できます。","subscriptionCard": {"title": "現在のプラン","empty": "有効なサブスクリプションはありません",@@ -7104,10 +7103,6 @@"endsAt": "{{date}} にプラン終了"},"topupCard": {- "title": "クレジット",- "description": "従量制のモデルや機能で使うクレジットを購入します。",- "cardTitle": "必要に応じてクレジットを購入",- "cardDescription": "必要に応じて利用可能なクレジットを追加できます。最終金額は決済ページに表示されます。","action": "クレジットを購入"}},@@ -7121,17 +7116,16 @@"unavailable": "残高を取得できません。更新してもう一度お試しください。"},"usage": {+ "title": "クレジット使用状況","observedAt": "クレジット更新: {{date}}","used": "使用済み","total": "合計","remaining": "残り","progressLabel": "{{label}}の使用状況","historyUnavailable": "使用履歴が完全ではないため、残りのクレジットのみ表示しています。",- "percentUsed": "{{percent}}% 使用済み","detailsUnavailable": "使用量の詳細を取得できないため、現在の残高のみ表示しています。","promotionalDetails": {"title": "特典クレジット明細",- "description": "現在の付与明細と合計残高は同じクレジットスナップショットに基づき、使用済み額には実際のモデル利用分のみが含まれます。","count": "{{count}}件","empty": "特典クレジットの付与履歴はありません。","incomplete": "付与履歴が多いため、最新の{{count}}件のみ表示しています。",@@ -7150,31 +7144,15 @@},"dialogs": {"subscription": {- "title": "サブスクリプションプランを選択",- "description": "サーバーで公開中のサブスクリプションプランを表示します。購入できないプランには状態を表示します。"+ "title": "サブスクリプションプランを選択"},"topup": {- "title": "クレジットを購入",- "description": "サーバーで公開中のクレジット商品を表示します。購入できない商品には状態を表示します。"+ "title": "クレジットを購入"}},- "eyebrow": "アカウントと使用量",- "title": "最適なプランを選択",- "subtitle": "プランと支払い方法はサーバーから配信されます。先にプランを選ぶと、現在利用可能な支払い方法が表示されます。","steps": {- "offer": {- "title": "プランを選択",- "description": "サーバーで公開中のチャージとサブスクリプションを表示します。"- },"channel": {- "title": "支払い方法を選択",- "description": "利用できる支払い方法はプランごとに異なります。",- "selectOfferFirst": "プランを選ぶと、対応する支払い方法が表示されます"- },- "confirm": {- "title": "確認して支払う",- "description": "プランと支払い方法を確認して決済を作成します。",- "selectChannelFirst": "支払い方法を選択してください"+ "title": "支払い方法を選択"}},"actions": {@@ -7195,10 +7173,6 @@"NO_AVAILABLE_PAYMENT_CHANNEL": "利用可能な支払い方法なし"}},- "offerKinds": {- "topup": "クレジットチャージ",- "subscription": "サブスクリプション"- },"amount": {"custom": "金額を指定","label": "チャージ金額",@@ -7270,8 +7244,6 @@},"planChange": {"targetTitle": "サブスクリプションプランの変更",- "targetDescription": "プラン変更は現在の支払い方法を引き継ぎます。最終的な金額と適用時期は次のステップで確認します。",- "targetDescriptionWithCurrent": "現在のプラン:{{plan}}。変更は現在の支払い方法を引き継ぎ、最終的な金額と適用時期は次のステップで確認します。","upgradeBadge": "アップグレード","downgradeBadge": "ダウングレード","emptyTitle": "切り替え可能なプランがありません",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 4963687d3e..bd69b703a1 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -7089,7 +7089,6 @@"sidebar": "크레딧 및 요금제","settings": {"title": "사용량 및 결제",- "subtitle": "사용 가능한 크레딧과 현재 요금제를 확인하거나 필요할 때 크레딧을 구매할 수 있습니다.","subscriptionCard": {"title": "현재 요금제","empty": "활성 구독이 없습니다",@@ -7104,10 +7103,6 @@"endsAt": "{{date}}에 요금제 종료"},"topupCard": {- "title": "크레딧",- "description": "사용량 기반 모델과 기능을 위한 크레딧을 구매합니다.",- "cardTitle": "필요할 때 크레딧 구매",- "cardDescription": "필요할 때 사용 가능한 크레딧을 추가할 수 있습니다. 최종 금액은 결제 페이지에서 확인하세요.","action": "크레딧 구매"}},@@ -7121,17 +7116,16 @@"unavailable": "잔액을 불러올 수 없습니다. 새로고침 후 다시 시도하세요."},"usage": {+ "title": "크레딧 사용량","observedAt": "크레딧 업데이트: {{date}}","used": "사용","total": "전체","remaining": "잔여","progressLabel": "{{label}} 사용량","historyUnavailable": "사용 기록이 완전하지 않아 잔여 크레딧만 표시합니다.",- "percentUsed": "{{percent}}% 사용","detailsUnavailable": "사용량 상세를 불러올 수 없어 현재 잔액만 표시합니다.","promotionalDetails": {"title": "프로모션 크레딧 상세",- "description": "현재 지급 내역과 총 잔액은 동일한 크레딧 스냅샷을 기준으로 하며, 사용 금액에는 실제 모델 사용량만 포함됩니다.","count": "{{count}}건","empty": "프로모션 크레딧 지급 내역이 없습니다.","incomplete": "지급 내역이 많아 최근 {{count}}건만 표시합니다.",@@ -7150,31 +7144,15 @@},"dialogs": {"subscription": {- "title": "구독 요금제 선택",- "description": "서버에서 공개한 구독 요금제를 표시합니다. 아직 구매할 수 없는 요금제에는 상태가 표시됩니다."+ "title": "구독 요금제 선택"},"topup": {- "title": "크레딧 구매",- "description": "서버에서 공개한 크레딧 상품을 표시합니다. 아직 구매할 수 없는 상품에는 상태가 표시됩니다."+ "title": "크레딧 구매"}},- "eyebrow": "계정 및 사용량",- "title": "알맞은 요금제 선택",- "subtitle": "요금제와 결제 수단은 서버에서 실시간으로 제공됩니다. 요금제를 먼저 선택하면 현재 지원되는 결제 수단을 볼 수 있습니다.","steps": {- "offer": {- "title": "요금제 선택",- "description": "서버에서 공개한 충전 및 구독 상품을 표시합니다."- },"channel": {- "title": "결제 수단 선택",- "description": "지원되는 결제 수단은 요금제마다 다를 수 있습니다.",- "selectOfferFirst": "요금제를 선택하면 지원되는 결제 수단이 표시됩니다"- },- "confirm": {- "title": "확인 및 결제",- "description": "요금제와 결제 수단을 확인한 뒤 결제를 생성합니다.",- "selectChannelFirst": "계속하려면 결제 수단을 선택하세요"+ "title": "결제 수단 선택"}},"actions": {@@ -7195,10 +7173,6 @@"NO_AVAILABLE_PAYMENT_CHANNEL": "사용 가능한 결제 수단 없음"}},- "offerKinds": {- "topup": "크레딧 충전",- "subscription": "구독"- },"amount": {"custom": "금액 직접 입력","label": "충전 금액",@@ -7270,8 +7244,6 @@},"planChange": {"targetTitle": "구독 플랜 변경",- "targetDescription": "플랜 변경은 현재 결제 수단을 그대로 사용합니다. 최종 금액과 적용 시점은 다음 단계에서 확인합니다.",- "targetDescriptionWithCurrent": "현재 플랜: {{plan}}. 변경은 현재 결제 수단을 그대로 사용하며, 최종 금액과 적용 시점은 다음 단계에서 확인합니다.","upgradeBadge": "업그레이드","downgradeBadge": "다운그레이드","emptyTitle": "전환 가능한 플랜이 없습니다",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex b447723a2a..93ddeb2bbb 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -7089,7 +7089,6 @@"sidebar": "点数与订阅","settings": {"title": "使用情况和计费",- "subtitle": "查看可用额度与当前套餐,或按需购买点数。","subscriptionCard": {"title": "当前套餐","empty": "当前没有生效中的订阅",@@ -7104,10 +7103,6 @@"endsAt": "套餐将于 {{date}} 结束"},"topupCard": {- "title": "点数",- "description": "购买点数,为按量使用的模型和功能充值。",- "cardTitle": "按需购买点数",- "cardDescription": "按需补充可用额度,购买金额以结算页为准。","action": "购买点数"}},@@ -7121,17 +7116,16 @@"unavailable": "暂时无法获取额度,请刷新后重试。"},"usage": {+ "title": "额度使用","observedAt": "额度更新于 {{date}}","used": "已用","total": "总额","remaining": "剩余","progressLabel": "{{label}}使用进度","historyUnavailable": "历史记录不完整,暂时仅显示剩余额度。",- "percentUsed": "已使用 {{percent}}%","detailsUnavailable": "用量明细暂时不可用,当前仅显示各类余额。","promotionalDetails": {"title": "赠送额度明细",- "description": "当前赠送与总余额基于同一次额度快照,已用额度仅统计实际模型消费。","count": "{{count}} 笔","empty": "当前没有赠送额度记录。","incomplete": "赠送记录较多,当前仅显示最近的 {{count}} 笔。",@@ -7150,31 +7144,15 @@},"dialogs": {"subscription": {- "title": "选择订阅套餐",- "description": "展示服务端当前公开的订阅套餐;暂不可购买的套餐会标注状态。"+ "title": "选择订阅套餐"},"topup": {- "title": "购买点数",- "description": "展示服务端当前公开的点数商品;暂不可购买的商品会标注状态。"+ "title": "购买点数"}},- "eyebrow": "账户与用量",- "title": "选择适合你的方案",- "subtitle": "套餐和支付方式均由服务端实时下发。先选择方案,再查看该方案当前支持的支付方式。","steps": {- "offer": {- "title": "选择套餐",- "description": "展示服务端当前公开的充值和订阅方案。"- },"channel": {- "title": "选择支付方式",- "description": "不同套餐支持的支付方式可能不同。",- "selectOfferFirst": "选择套餐后,这里会显示该套餐支持的支付方式"- },- "confirm": {- "title": "确认并支付",- "description": "核对方案与支付方式后创建支付。",- "selectChannelFirst": "选择支付方式后即可确认订单"+ "title": "选择支付方式"}},"actions": {@@ -7195,10 +7173,6 @@"NO_AVAILABLE_PAYMENT_CHANNEL": "暂无可用支付方式"}},- "offerKinds": {- "topup": "点数充值",- "subscription": "订阅套餐"- },"amount": {"custom": "自定义金额","label": "充值金额",@@ -7270,8 +7244,6 @@},"planChange": {"targetTitle": "更改订阅套餐",- "targetDescription": "套餐变更沿用当前支付方式,最终价格与生效时间以下一步确认为准。",- "targetDescriptionWithCurrent": "当前套餐:{{plan}}。变更沿用当前支付方式,最终价格与生效时间以下一步确认为准。","upgradeBadge": "升级","downgradeBadge": "降级","emptyTitle": "暂无可切换的套餐",