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() {