fix(ui): 修复现价变量映射错误,修正负收益绿色显示丢失负号的 Bug

This commit is contained in:
kennethcheng 2026-04-29 01:40:25 +08:00
parent 1b947d563a
commit 7c2f464f2c
2 changed files with 3 additions and 1 deletions

View File

@ -57,7 +57,7 @@ function formatPnl(value: string, percent: string, baseCurrency: string): { text
const symbol = getCurrencySymbol(baseCurrency); const symbol = getCurrencySymbol(baseCurrency);
const absValue = new Big(value).abs().toFixed(2); const absValue = new Big(value).abs().toFixed(2);
const absPercent = new Big(percent).abs().toFixed(2); const absPercent = new Big(percent).abs().toFixed(2);
const text = `${symbol}${absValue} (${absPercent}%)`; const text = `${symbol}${isPositive ? '' : '-'}${absValue} (${isPositive ? '' : '-'}${absPercent}%)`;
const className = isPositive ? 'text-red-500' : 'text-green-500'; const className = isPositive ? 'text-red-500' : 'text-green-500';
return { text, className }; return { text, className };
} }

View File

@ -37,6 +37,7 @@ interface Position {
floatingPnlPercent: string; floatingPnlPercent: string;
cumulativePnlNative: string; cumulativePnlNative: string;
cumulativePnlPercent: string; cumulativePnlPercent: string;
latestPrice: string;
transactions: TransactionRecord[]; transactions: TransactionRecord[];
} }
@ -399,6 +400,7 @@ export async function getPortfolioPositions(): Promise<Position[]> {
floatingPnlPercent: floatingPnlPercent.toString(), floatingPnlPercent: floatingPnlPercent.toString(),
cumulativePnlNative: cumulativePnlNative.toString(), cumulativePnlNative: cumulativePnlNative.toString(),
cumulativePnlPercent: cumulativePnlPercent.toString(), cumulativePnlPercent: cumulativePnlPercent.toString(),
latestPrice: holding.latestPrice,
transactions: holding.transactions, transactions: holding.transactions,
}); });
} }