From 349af04034d4c6af11bb8c8515db803335c61366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sun, 4 Oct 2026 15:49:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=85=85=E5=80=BC=E5=BC=B9=E7=AA=97):?= =?UTF-8?q?=20=E6=91=8A=E5=B9=B3=E7=BB=93=E7=AE=97=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E9=87=8C=E7=9A=84=E5=B5=8C=E5=A5=97=E4=B8=89=E5=85=83=20listPr?= =?UTF-8?q?iceCents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 原写法 plan / annual 两层三元叠加,扩展条件时容易漏分支 - 改为按 annual 分支 + 可选链与 ?? 兜底,保持 plan 为空时取 0 的语义不变 --- .../src/components/PlatformProfileRechargeModal/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/shared/src/components/PlatformProfileRechargeModal/index.tsx b/packages/shared/src/components/PlatformProfileRechargeModal/index.tsx index 0f9c9eaea..e5341e48b 100644 --- a/packages/shared/src/components/PlatformProfileRechargeModal/index.tsx +++ b/packages/shared/src/components/PlatformProfileRechargeModal/index.tsx @@ -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;