From 40ef947d534a4dbcfcc6a035ba8faefceb2e6780 Mon Sep 17 00:00:00 2001 From: admin <1297598740@qq.com> Date: Wed, 28 Jan 2026 16:36:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E4=BE=9B=E8=B4=A6=E6=88=B7=E6=A6=82=E8=A7=88?= =?UTF-8?q?=E3=80=81=E4=BA=A4=E6=98=93=E8=B6=8B=E5=8A=BF=E3=80=81=E5=BF=AB?= =?UTF-8?q?=E9=80=9F=E8=AE=B0=E8=B4=A6=E3=80=81AI=E8=AE=B0=E8=B4=A6?= =?UTF-8?q?=E5=92=8C=E8=B4=A1=E7=8C=AE=E5=9B=BE=E7=AD=89=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Home/Home.css | 10 ++++++++++ src/pages/Home/Home.tsx | 43 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/pages/Home/Home.css b/src/pages/Home/Home.css index b681990..52bc7c9 100644 --- a/src/pages/Home/Home.css +++ b/src/pages/Home/Home.css @@ -323,6 +323,16 @@ border: 1px solid rgba(255, 255, 255, 0.2); } +/* 金额单位后缀样式 (万/亿) */ +.card-value-suffix { + font-size: 1.5rem; + font-weight: 600; + margin-left: 4px; + opacity: 0.9; + align-self: flex-end; + padding-bottom: 4px; +} + /* Secondary Cards */ .assets-card, .liabilities-card { diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index 07697a6..44170df 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -166,13 +166,47 @@ function Home() { const totalLiabilities = calculateTotalLiabilities(accounts); const netWorth = totalAssets - totalLiabilities; + // 标准金额格式化(带完整小数) const formatCurrency = (amount: number): string => { return new Intl.NumberFormat('zh-CN', { style: 'currency', currency: 'CNY', + minimumFractionDigits: 0, + maximumFractionDigits: amount % 1 === 0 ? 0 : 2, // 整数不显示小数 }).format(amount); }; + // 大数字简洁显示(用于净资产等主要展示) + const formatLargeNumber = (amount: number): { value: string; suffix: string } => { + const absAmount = Math.abs(amount); + const sign = amount < 0 ? '-' : ''; + + if (absAmount >= 100000000) { + // 亿 + const value = absAmount / 100000000; + return { + value: sign + value.toLocaleString('zh-CN', { maximumFractionDigits: 2 }), + suffix: '亿' + }; + } else if (absAmount >= 10000) { + // 万 + const value = absAmount / 10000; + return { + value: sign + value.toLocaleString('zh-CN', { maximumFractionDigits: 2 }), + suffix: '万' + }; + } else { + // 直接显示 + return { + value: sign + absAmount.toLocaleString('zh-CN', { + minimumFractionDigits: 0, + maximumFractionDigits: absAmount % 1 === 0 ? 0 : 2 + }), + suffix: '' + }; + } + }; + // Lock body scroll when modal is open useEffect(() => { if (showAccountForm) { @@ -367,9 +401,14 @@ function Home() {