feat(ui): 升級資產卡片展示,支持累計分紅顯示並修復數據格式化兜底
This commit is contained in:
parent
03e8e98260
commit
84d889fbe5
@ -59,4 +59,9 @@
|
|||||||
## 修復平均成本顯示 Bug與分紅獨立統計 (Task 35)
|
## 修復平均成本顯示 Bug與分紅獨立統計 (Task 35)
|
||||||
- 修復了平均成本在前端顯示為空的問題:`totalBuyQuantity` 在 BUY 交易處理中從未累加,導致 `avgCost` 計算時除數為零而永遠返回 0。現在在 BUY 時正確執行 `totalBuyQuantity += quantity`。
|
- 修復了平均成本在前端顯示為空的問題:`totalBuyQuantity` 在 BUY 交易處理中從未累加,導致 `avgCost` 計算時除數為零而永遠返回 0。現在在 BUY 時正確執行 `totalBuyQuantity += quantity`。
|
||||||
- 將分紅邏輯從已實現盈虧中剝離,建立獨立的累計分紅統計維度:新增 `accumulatedDividendsCny` 字段,DIVIDEND 交易不再混入 `realizedPnlCny`,而是獨立累加至 `accumulatedDividendsCny`。
|
- 將分紅邏輯從已實現盈虧中剝離,建立獨立的累計分紅統計維度:新增 `accumulatedDividendsCny` 字段,DIVIDEND 交易不再混入 `realizedPnlCny`,而是獨立累加至 `accumulatedDividendsCny`。
|
||||||
- 重新定義總盈虧公式:`totalPnlCny = unrealizedPnlCny + realizedPnlCny + accumulatedDividendsCny`,確保分紅有獨立的統計維度且不會干擾平均成本計算。
|
- 重新定義總盈虧公式:`totalPnlCny = unrealizedPnlCny + realizedPnlCny + accumulatedDividendsCny`,確保分紅有獨立的統計維度且不會干擾平均成本計算。
|
||||||
|
|
||||||
|
## 升級 Dashboard 資產卡片 UI (Task 36)
|
||||||
|
- 升級了 Dashboard 資產卡片 UI,新增累計分紅展示,並優化了成本數據的格式化判斷邏輯。
|
||||||
|
- 修復了 `avgCostFormatted` 的判空邏輯,將 `Big.eq(0)` 修正為 `Big.eq('0')`,確保當 `pos.avgCost` 存在且不為 0 時能正確格式化,不再顯示 `¥-`。
|
||||||
|
- 在資產卡片中新增「累計分紅」行,展示 `accumulatedDividendsCny` 數據,保持與其它 CNY 數據一致的 `opacity-50` 樣式。
|
||||||
@ -67,11 +67,12 @@ export default async function DashboardPage() {
|
|||||||
const posPnl = new Big(pos.pnlCny);
|
const posPnl = new Big(pos.pnlCny);
|
||||||
const posPnlPositive = posPnl.gte(0);
|
const posPnlPositive = posPnl.gte(0);
|
||||||
const formattedPosPnl = formatAmount(pos.pnlCny);
|
const formattedPosPnl = formatAmount(pos.pnlCny);
|
||||||
|
const formattedDividends = formatAmount(pos.accumulatedDividendsCny);
|
||||||
|
|
||||||
const posPnlNative = new Big(pos.pnlNative);
|
const posPnlNative = new Big(pos.pnlNative);
|
||||||
const posPnlNativePositive = posPnlNative.gte(0);
|
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) : '-';
|
const dilutedCostFormatted = !new Big(pos.dilutedCost).eq(0) && pos.dilutedCost !== '0' ? formatAmount(pos.dilutedCost) : '-';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -141,6 +142,12 @@ export default async function DashboardPage() {
|
|||||||
{posPnlPositive ? '+' : ''}{formattedPosPnl}
|
{posPnlPositive ? '+' : ''}{formattedPosPnl}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex justify-between opacity-50">
|
||||||
|
<span className="text-muted-foreground">累計分紅</span>
|
||||||
|
<span className="font-medium">
|
||||||
|
{formattedDividends}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user