feat(custom): recharge bonus pay-1-get-2, topup page & docs & about promo display, Chinese-first i18n

- payment_setting.amount_bonus: uniform top-up bonus (1 = pay ¥1 credit ¥2),
  applied to credited quota in model/topupQuotaFromAmount and
  controller/getTopUpQuota (epay/waffo/pancake/manual paths), exposed via
  /api/user/topup/info; regression test TestTopUpQuotaAppliesAmountBonus
- wallet recharge card: bonus banner, credited amount per preset,
  custom-amount credited line, credited row in payment confirm dialog;
  hardcoded Chinese copy (支付/到账/最低充值)
- list locale defaults: Chinese-first, browser locale no longer auto-selects
  English; new localStorage key resets stale language caches
- /docs top-up section: bonus notice box
- README: record the recharge-bonus update in 'About This Custom Fork'
This commit is contained in:
CaIon committed 2026-09-24 15:47:06 +08:00
1 parent 14a9acd368
commit cf06cd72be
19 files changed
+172 -22

No files matched your search

+5
View File
@@ -216,6 +216,11 @@ export function Docs() {
,页面会自动跳回本站
</li>
</ol>
<div className='rounded-lg border border-green-200 bg-green-50 p-3 text-sm text-green-700 dark:border-green-500/40 dark:bg-green-950 dark:text-green-300'>
🎉 <b>充值优惠</b>:充值 <b>¥1 实际到账 ¥2</b>
,以此类推——充多少送多少(100% 赠送)。例如支付 ¥10 到账 ¥20
,支付 ¥100 到账 ¥200,到账额度可用于全部模型与套餐。
</div>
<h3>方式二:包月套餐(推荐)</h3>
<p>
前往{' '}
@@ -47,6 +47,7 @@ interface PaymentConfirmDialogProps {
processing: boolean
discountRate?: number
usdExchangeRate?: number
amountBonus?: number
}
export function PaymentConfirmDialog({
@@ -60,11 +61,13 @@ export function PaymentConfirmDialog({
processing,
discountRate = DEFAULT_DISCOUNT_RATE,
usdExchangeRate = 1,
amountBonus = 0,
}: PaymentConfirmDialogProps) {
const { t } = useTranslation()
const hasDiscount = discountRate > 0 && discountRate < 1 && paymentAmount > 0
const originalAmount = hasDiscount ? paymentAmount / discountRate : 0
const discountAmount = hasDiscount ? originalAmount - paymentAmount : 0
const creditedAmount = topupAmount * usdExchangeRate * (1 + amountBonus)
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
@@ -92,6 +95,21 @@ export function PaymentConfirmDialog({
</span>
</div>
{amountBonus > 0 && (
<div className='flex items-center justify-between'>
<span className='text-muted-foreground text-sm'>
到账金额
</span>
<span className='text-lg font-semibold text-green-600'>
{formatLocalCurrencyAmount(creditedAmount, {
digitsLarge: 2,
digitsSmall: 2,
abbreviate: false,
})}
</span>
</div>
)}
<div className='flex items-center justify-between'>
<span className='text-muted-foreground text-sm'>
{t('You Pay')}
@@ -72,6 +72,7 @@ interface RechargeFormCardProps {
loading?: boolean
priceRatio?: number
usdExchangeRate?: number
amountBonus?: number
onOpenBilling?: () => void
creemProducts?: CreemProduct[]
enableCreemTopup?: boolean
@@ -102,6 +103,7 @@ export function RechargeFormCard({
loading,
priceRatio = 1,
usdExchangeRate = 1,
amountBonus = 0,
onOpenBilling,
creemProducts,
enableCreemTopup,
@@ -219,6 +221,12 @@ export function RechargeFormCard({
{/* Online Topup Section */}
{hasAnyTopup ? (
<div className='space-y-4 sm:space-y-6'>
{hasConfigurableTopup && amountBonus > 0 && (
<div className='flex items-center gap-2.5 rounded-lg border border-green-200 bg-green-500/10 px-3 py-2.5 text-sm font-medium text-green-700 dark:border-green-500/40 dark:text-green-400'>
<Gift className='h-4 w-4 shrink-0' aria-hidden='true' />
<span>充值优惠:充值 1 元实际到账 {(1 + amountBonus) * 1} 元,以此类推,充多少送多少。</span>
</div>
)}
{hasConfigurableTopup && (
<>
{presetAmounts.length > 0 && (
@@ -266,11 +274,17 @@ export function RechargeFormCard({
)}
</div>
<div className='text-muted-foreground mt-1.5 w-full text-xs sm:mt-2'>
Pay {formatCurrency(actualPrice)}
{amountBonus > 0 && (
<span className='font-semibold text-green-600'>
{`到账 ${formatNumber(displayValue * (1 + amountBonus))}`}
{' · '}
</span>
)}
{`支付 ${formatCurrency(actualPrice)}`}
{hasDiscount && savedAmount > 0 && (
<span className='text-green-600'>
{' '}
• Save {formatCurrency(savedAmount)}
{`· 已省 ${formatCurrency(savedAmount)}`}
</span>
)}
</div>
@@ -295,19 +309,33 @@ export function RechargeFormCard({
value={localAmount}
onChange={(e) => handleAmountChange(e.target.value)}
min={minTopup}
placeholder={`Minimum ${minTopup}`}
placeholder={`最低充值 ${minTopup}`}
className='h-9 text-base sm:h-10 sm:text-lg'
/>
<div className='bg-muted/30 flex min-h-9 items-center justify-between gap-2 rounded-md border px-3 lg:min-w-52'>
<span className='text-muted-foreground truncate text-xs'>
{t('Amount to pay:')}
</span>
{calculating ? (
<Skeleton className='h-5 w-16' />
) : (
<span className='text-sm font-semibold'>
{formatCurrency(paymentAmount)}
<div className='bg-muted/30 flex min-h-9 flex-col items-center justify-center gap-0 rounded-md border px-3 lg:min-w-52'>
<div className='flex items-center justify-between gap-2 self-stretch'>
<span className='text-muted-foreground truncate text-xs'>
待支付金额:
</span>
{calculating ? (
<Skeleton className='h-5 w-16' />
) : (
<span className='text-sm font-semibold'>
{formatCurrency(paymentAmount)}
</span>
)}
</div>
{amountBonus > 0 && (
<div className='flex items-center justify-between gap-2 self-stretch text-[11px] leading-4'>
<span className='text-muted-foreground truncate'>
到账金额
</span>
<span className='font-semibold text-green-600'>
{formatNumber(
topupAmount * usdExchangeRate * (1 + amountBonus)
)}
</span>
</div>
)}
</div>
</div>
@@ -188,6 +188,10 @@ export function useTopupInfo() {
),
amount_options: parseAmountOptions(response.data.amount_options),
discount: parseDiscountMap(response.data.discount),
amount_bonus: Math.max(
Number(response.data.amount_bonus) || 0,
0
),
creem_products: parseCreemProducts(response.data.creem_products),
waffo_pay_methods: parseWaffoPayMethods(
response.data.waffo_pay_methods
+2
View File
@@ -323,6 +323,7 @@ export function Wallet(props: WalletProps) {
: (status?.price as number) || 1
}
usdExchangeRate={effectiveUsdExchangeRate}
amountBonus={topupInfo?.amount_bonus ?? 0}
onOpenBilling={() => setBillingDialogOpen(true)}
creemProducts={topupInfo?.creem_products}
enableCreemTopup={topupInfo?.enable_creem_topup}
@@ -369,6 +370,7 @@ export function Wallet(props: WalletProps) {
processing={processing || waffoProcessing || pancakeProcessing}
discountRate={getDiscountRate()}
usdExchangeRate={effectiveUsdExchangeRate}
amountBonus={topupInfo?.amount_bonus ?? 0}
/>
<TransferDialog
+2
View File
@@ -134,6 +134,8 @@ export interface TopupInfo {
amount_options: number[]
/** Discount rates by amount */
discount: Record<number, number>
/** Uniform credited bonus ratio (1 = pay 1 get 2), 0 means no bonus */
amount_bonus: number
/** Optional topup link for purchasing codes */
topup_link?: string
/** Whether Creem topup is enabled */
+6 -2
View File
@@ -44,7 +44,8 @@ i18n
.use(initReactI18next)
.init({
resources,
fallbackLng: 'en',
// 站点面向中文用户:无语言偏好缓存时默认中文,同时支持在界面上手动切换语言
fallbackLng: 'zhCN',
supportedLngs: ['en', 'zhCN', 'fr', 'ru', 'ja', 'vi', 'zhTW'],
load: 'currentOnly',
nsSeparator: false, // Allow literal colons in keys (e.g., URLs, labels)
@@ -53,7 +54,10 @@ i18n
escapeValue: false, // not needed for react as it escapes by default
},
detection: {
order: ['localStorage', 'navigator'],
// 仅信任已保存的语言偏好,不再跟随浏览器语言,避免英文环境误显示英文
order: ['localStorage'],
// 使用新的存储键名:丢弃旧版本残留的浏览器语言缓存(如曾识别为 en 的用户)
lookupLocalStorage: 'i18nextLngV2',
caches: ['localStorage'],
// Browsers report `zh-CN`/`zh-TW`/`zh`; map them onto our `zhCN`/`zhTW`
// codes (non-Chinese codes pass through for normal supportedLngs matching).
+4 -1
View File
@@ -6145,5 +6145,8 @@
"Zhipu": "Zhipu",
"Zhipu V4": "Zhipu V4",
"Zoom": "Zoom"
}
},
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Recharge bonus: pay ¥{{pay}}, get ¥{{credit}} credited — the more you top up, the more you get.",
"Credited amount": "Credited amount",
"Credited {{amount}}": "Credited {{amount}}"
}
+4 -1
View File
@@ -6145,5 +6145,8 @@
"Zhipu": "Zhipu",
"Zhipu V4": "Zhipu V4",
"Zoom": "Zoom"
}
},
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Bonus de recharge : payez ¥{{pay}} et recevez ¥{{credit}} — plus vous rechargez, plus vous gagnez.",
"Credited amount": "Montant crédité",
"Credited {{amount}}": "Crédité {{amount}}"
}
+4 -1
View File
@@ -6145,5 +6145,8 @@
"Zhipu": "Zhipu",
"Zhipu V4": "Zhipu V 4",
"Zoom": "ズーム"
}
},
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "チャージ特典:{{pay}}元の支払いで{{credit}}元が付与されます。金額が多いほどお得です。",
"Credited amount": "付与額",
"Credited {{amount}}": "付与 {{amount}}"
}
+4 -1
View File
@@ -6145,5 +6145,8 @@
"Zhipu": "Zhipu",
"Zhipu V4": "Zhipu V4",
"Zoom": "Zoom"
}
},
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Бонус за пополнение: платите ¥{{pay}} — получаете ¥{{credit}}. Чем больше пополнение, тем больше бонус.",
"Credited amount": "Начислено",
"Credited {{amount}}": "Начислено {{amount}}"
}
+4 -1
View File
@@ -6145,5 +6145,8 @@
"Zhipu": "Zhipu",
"Zhipu V4": "Zhipu V4",
"Zoom": "Zoom"
}
},
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Ưu đãi nạp tiền: nạp {{pay}} nhận {{credit}} — nạp càng nhiều nhận càng nhiều.",
"Credited amount": "Số tiền nhận được",
"Credited {{amount}}": "Nhận {{amount}}"
}
+4 -1
View File
@@ -6145,5 +6145,8 @@
"Zhipu": "智譜",
"Zhipu V4": "智譜 V4",
"Zoom": "縮放"
}
},
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "儲值優惠:儲值 {{pay}} 元實際入帳 {{credit}} 元,以此類推,儲多少送多少。",
"Credited amount": "入帳金額",
"Credited {{amount}}": "入帳 {{amount}}"
}
+4 -1
View File
@@ -6145,5 +6145,8 @@
"Zhipu": "智谱",
"Zhipu V4": "智谱 V4",
"Zoom": "缩放"
}
},
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "充值优惠:充值 {{pay}} 元实际到账 {{credit}} 元,以此类推,充多少送多少。",
"Credited amount": "到账金额",
"Credited {{amount}}": "到账 {{amount}}"
}