From 1b947d563a16119ef5e7f131e42b6e0514998bba Mon Sep 17 00:00:00 2001 From: kennethcheng Date: Wed, 29 Apr 2026 01:16:51 +0800 Subject: [PATCH] =?UTF-8?q?style(ui):=20=E8=A7=84=E8=8C=83=E7=BA=A2?= =?UTF-8?q?=E6=B6=A8=E7=BB=BF=E8=B7=8C=E8=A7=86=E8=A7=89=E4=B9=A0=E6=83=AF?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E7=A7=BB=E9=99=A4=E7=9B=88=E4=BA=8F=E6=95=B0?= =?UTF-8?q?=E5=80=BC=E5=A4=9A=E4=BD=99=E7=9A=84=E6=AD=A3=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Memory.md | 6 ++++++ app/dashboard/page.tsx | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Memory.md b/Memory.md index ac41987..300d2ba 100644 --- a/Memory.md +++ b/Memory.md @@ -78,6 +78,12 @@ - 利用 `Big.js` 剥离了流水明细中无意义的尾随零,提升了高精度数据的可读性。 - 在 `app/dashboard/page.tsx` 的流水明細子表格中,将 `tx.quantity`、`tx.price`、`tx.fee` 的渲染逻辑改为 `new Big(value).toString()`,安全剥离因数据库 `numeric(36,18)` 配置导致的如 `0.041000000000000000` 这类冗余尾随零。 +## 盈亏红绿视觉规范 (Task 42c) +- 依据中文金融习惯(红涨绿跌),规范了盈亏数值的颜色与正负号显示。 +- 移除了 `formatPnl()` 函数及概览行内硬编码拼接的 `+` 号前缀,正收益直接展示数值,负收益保留原生 `-` 号。 +- 统一颜色逻辑:值 `> 0` 应用 `text-red-500`(红色),值 `< 0` 应用 `text-green-500`(绿色),值 `=== 0` 使用默认文字颜色。 +- 括号内的百分比同步遵循相同逻辑,格式如 `$2447.48 (114.20%)`。 + ## 持倉引擎 Native 幣種算法重構 (Task 38) - 重構底層盈虧引擎,全面轉向 Native 原生幣種計算,新增浮動/累計盈虧及百分比指標。 - 徹底分離 Native 與 CNY 計算:單隻股票的成本與盈虧全部改用 Native (原幣種) 進行計算。 diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 2f2f84b..a888e27 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -57,8 +57,7 @@ function formatPnl(value: string, percent: string, baseCurrency: string): { text const symbol = getCurrencySymbol(baseCurrency); const absValue = new Big(value).abs().toFixed(2); const absPercent = new Big(percent).abs().toFixed(2); - const sign = isPositive ? '+' : ''; - const text = `${sign}${symbol}${absValue} (${sign}${absPercent}%)`; + const text = `${symbol}${absValue} (${absPercent}%)`; const className = isPositive ? 'text-red-500' : 'text-green-500'; return { text, className }; } @@ -157,14 +156,14 @@ export default function DashboardPage() {
持仓盈亏: - - {unrealizedIsPositive ? '+' : ''}{formattedUnrealized} + + {formattedUnrealized}
总盈亏: - - {totalPnlIsPositive ? '+' : ''}{formattedTotalPnl} + + {formattedTotalPnl}