refactor(充值弹窗): 摊平结算弹窗里的嵌套三元 listPriceCents

- 原写法 plan / annual 两层三元叠加,扩展条件时容易漏分支
- 改为按 annual 分支 + 可选链与 ?? 兜底,保持 plan 为空时取 0 的语义不变
This commit is contained in:
2026-10-04 15:49:31 +08:00
parent 87f3cd4462
commit 349af04034
@@ -996,11 +996,9 @@ function PlatformRechargeCheckoutDialog({
membershipPlans.find((item) => item.plan === target.plan) ?? null;
const annual = target.cycleKind === 'yearly';
const cycleLabel = annual ? '年付' : '月付';
const listPriceCents = plan
? annual
? plan.yearPriceCents
: plan.monthPriceCents
: 0;
const listPriceCents = annual
? (plan?.yearPriceCents ?? 0)
: (plan?.monthPriceCents ?? 0);
const isUpgrade = target.mode === 'upgrade';
const currentPlan =
membershipPlans.find((item) => item.plan === membership?.plan) ?? null;