fix: PC表格支持以百分比显示持有收益
This commit is contained in:
11
app/page.jsx
11
app/page.jsx
@@ -721,10 +721,17 @@ export default function HomePage() {
|
|||||||
const todayProfitValue = profitToday;
|
const todayProfitValue = profitToday;
|
||||||
|
|
||||||
const total = profit ? profit.profitTotal : null;
|
const total = profit ? profit.profitTotal : null;
|
||||||
|
const principal =
|
||||||
|
holding && isNumber(holding.cost) && isNumber(holding.share)
|
||||||
|
? holding.cost * holding.share
|
||||||
|
: 0;
|
||||||
|
const asPercent = !!percentModes[f.code];
|
||||||
const holdingProfit =
|
const holdingProfit =
|
||||||
total == null
|
total == null
|
||||||
? ''
|
? ''
|
||||||
: `${total > 0 ? '+' : total < 0 ? '-' : ''}¥${Math.abs(total).toFixed(2)}`;
|
: (asPercent && principal > 0
|
||||||
|
? `${total > 0 ? '+' : total < 0 ? '-' : ''}${Math.abs((total / principal) * 100).toFixed(2)}%`
|
||||||
|
: `${total > 0 ? '+' : total < 0 ? '-' : ''}¥${Math.abs(total).toFixed(2)}`);
|
||||||
const holdingProfitValue = total;
|
const holdingProfitValue = total;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -748,7 +755,7 @@ export default function HomePage() {
|
|||||||
holdingProfitValue,
|
holdingProfitValue,
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
[displayFunds, holdings, isTradingDay, todayStr, getHoldingProfit],
|
[displayFunds, holdings, isTradingDay, todayStr, getHoldingProfit, percentModes],
|
||||||
);
|
);
|
||||||
|
|
||||||
// 自动滚动选中 Tab 到可视区域
|
// 自动滚动选中 Tab 到可视区域
|
||||||
|
|||||||
Reference in New Issue
Block a user