refactor(充值弹窗): 摊平结算弹窗里的嵌套三元 listPriceCents
- 原写法 plan / annual 两层三元叠加,扩展条件时容易漏分支 - 改为按 annual 分支 + 可选链与 ?? 兜底,保持 plan 为空时取 0 的语义不变
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user