From 510664c4d315e79892e5275726138cb6239a9324 Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Fri, 27 Feb 2026 10:50:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20PC=E8=A1=A8=E6=A0=BC=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BB=A5=E7=99=BE=E5=88=86=E6=AF=94=E6=98=BE=E7=A4=BA=E6=8C=81?= =?UTF-8?q?=E6=9C=89=E6=94=B6=E7=9B=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/page.jsx b/app/page.jsx index 16ce931..4e155b4 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -721,10 +721,17 @@ export default function HomePage() { const todayProfitValue = profitToday; const total = profit ? profit.profitTotal : null; + const principal = + holding && isNumber(holding.cost) && isNumber(holding.share) + ? holding.cost * holding.share + : 0; + const asPercent = !!percentModes[f.code]; const holdingProfit = total == null ? '' - : `${total > 0 ? '+' : total < 0 ? '-' : ''}¥${Math.abs(total).toFixed(2)}`; + : (asPercent && principal > 0 + ? `${total > 0 ? '+' : total < 0 ? '-' : ''}${Math.abs((total / principal) * 100).toFixed(2)}%` + : `${total > 0 ? '+' : total < 0 ? '-' : ''}¥${Math.abs(total).toFixed(2)}`); const holdingProfitValue = total; return { @@ -748,7 +755,7 @@ export default function HomePage() { holdingProfitValue, }; }), - [displayFunds, holdings, isTradingDay, todayStr, getHoldingProfit], + [displayFunds, holdings, isTradingDay, todayStr, getHoldingProfit, percentModes], ); // 自动滚动选中 Tab 到可视区域