From 84d889fbe5fcbe9624a3fd3030f7be45b6bf559b Mon Sep 17 00:00:00 2001 From: kennethcheng Date: Tue, 28 Apr 2026 19:00:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E5=8D=87=E7=B4=9A=E8=B3=87?= =?UTF-8?q?=E7=94=A2=E5=8D=A1=E7=89=87=E5=B1=95=E7=A4=BA=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=B4=AF=E8=A8=88=E5=88=86=E7=B4=85=E9=A1=AF=E7=A4=BA?= =?UTF-8?q?=E4=B8=A6=E4=BF=AE=E5=BE=A9=E6=95=B8=E6=93=9A=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E5=85=9C=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Memory.md | 7 ++++++- app/dashboard/page.tsx | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Memory.md b/Memory.md index 47ab059..ec340f5 100644 --- a/Memory.md +++ b/Memory.md @@ -59,4 +59,9 @@ ## 修復平均成本顯示 Bug與分紅獨立統計 (Task 35) - 修復了平均成本在前端顯示為空的問題:`totalBuyQuantity` 在 BUY 交易處理中從未累加,導致 `avgCost` 計算時除數為零而永遠返回 0。現在在 BUY 時正確執行 `totalBuyQuantity += quantity`。 - 將分紅邏輯從已實現盈虧中剝離,建立獨立的累計分紅統計維度:新增 `accumulatedDividendsCny` 字段,DIVIDEND 交易不再混入 `realizedPnlCny`,而是獨立累加至 `accumulatedDividendsCny`。 -- 重新定義總盈虧公式:`totalPnlCny = unrealizedPnlCny + realizedPnlCny + accumulatedDividendsCny`,確保分紅有獨立的統計維度且不會干擾平均成本計算。 \ No newline at end of file +- 重新定義總盈虧公式:`totalPnlCny = unrealizedPnlCny + realizedPnlCny + accumulatedDividendsCny`,確保分紅有獨立的統計維度且不會干擾平均成本計算。 + +## 升級 Dashboard 資產卡片 UI (Task 36) +- 升級了 Dashboard 資產卡片 UI,新增累計分紅展示,並優化了成本數據的格式化判斷邏輯。 +- 修復了 `avgCostFormatted` 的判空邏輯,將 `Big.eq(0)` 修正為 `Big.eq('0')`,確保當 `pos.avgCost` 存在且不為 0 時能正確格式化,不再顯示 `¥-`。 +- 在資產卡片中新增「累計分紅」行,展示 `accumulatedDividendsCny` 數據,保持與其它 CNY 數據一致的 `opacity-50` 樣式。 \ No newline at end of file diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 65f9edc..4f61b41 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -67,11 +67,12 @@ export default async function DashboardPage() { const posPnl = new Big(pos.pnlCny); const posPnlPositive = posPnl.gte(0); const formattedPosPnl = formatAmount(pos.pnlCny); + const formattedDividends = formatAmount(pos.accumulatedDividendsCny); const posPnlNative = new Big(pos.pnlNative); const posPnlNativePositive = posPnlNative.gte(0); - const avgCostFormatted = !new Big(pos.avgCost).eq(0) && pos.avgCost !== '0' ? formatAmount(pos.avgCost) : '-'; + const avgCostFormatted = !new Big(pos.avgCost).eq('0') ? formatAmount(pos.avgCost) : '-'; const dilutedCostFormatted = !new Big(pos.dilutedCost).eq(0) && pos.dilutedCost !== '0' ? formatAmount(pos.dilutedCost) : '-'; return ( @@ -141,6 +142,12 @@ export default async function DashboardPage() { {posPnlPositive ? '+' : ''}{formattedPosPnl} +
+ 累計分紅 + + {formattedDividends} + +