feat: 估算收益支持展示金额
This commit is contained in:
@@ -531,39 +531,27 @@ export default function MobileFundTable({
|
|||||||
header: '估算收益',
|
header: '估算收益',
|
||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
const original = info.row.original || {};
|
const original = info.row.original || {};
|
||||||
const estimateValue = original.estimateChangeValue;
|
const value = original.estimateProfitValue;
|
||||||
const hasTodayEstimate = original.hasTodayEstimate;
|
const hasProfit = value != null;
|
||||||
const holdingProfitPercentStr = original.holdingProfitPercent ?? '';
|
const cls = hasProfit ? (value > 0 ? 'up' : value < 0 ? 'down' : '') : 'muted';
|
||||||
|
const amountStr = hasProfit ? (original.estimateProfit ?? '') : '—';
|
||||||
let holdingProfitPercentValue = null;
|
const percentStr = original.estimateProfitPercent ?? '';
|
||||||
if (holdingProfitPercentStr && holdingProfitPercentStr !== '') {
|
|
||||||
const numStr = holdingProfitPercentStr.replace(/[+%]/g, '');
|
|
||||||
holdingProfitPercentValue = parseFloat(numStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasEstimate = hasTodayEstimate && estimateValue != null;
|
|
||||||
const hasHolding = holdingProfitPercentValue != null && !isNaN(holdingProfitPercentValue);
|
|
||||||
|
|
||||||
if (!hasEstimate && !hasHolding) {
|
|
||||||
return (
|
|
||||||
<span className="muted" style={{ display: 'block', width: '100%', fontWeight: 700 }}>
|
|
||||||
<FitText maxFontSize={14} minFontSize={10}>
|
|
||||||
—
|
|
||||||
</FitText>
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const total = (hasEstimate ? estimateValue : 0) + (hasHolding ? holdingProfitPercentValue : 0);
|
|
||||||
const cls = total > 0 ? 'up' : total < 0 ? 'down' : '';
|
|
||||||
const displayValue = `${total > 0 ? '+' : ''}${total.toFixed(2)}%`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div style={{ width: '100%' }}>
|
||||||
<span className={cls} style={{ display: 'block', width: '100%', fontWeight: 700 }}>
|
<span className={cls} style={{ display: 'block', width: '100%', fontWeight: 700 }}>
|
||||||
<FitText maxFontSize={14} minFontSize={10}>
|
<FitText maxFontSize={14} minFontSize={10}>
|
||||||
{displayValue}
|
{amountStr}
|
||||||
</FitText>
|
</FitText>
|
||||||
</span>
|
</span>
|
||||||
|
{percentStr ? (
|
||||||
|
<span className={`${cls} estimate-profit-percent`} style={{ display: 'block', width: '100%', fontSize: '0.75em', opacity: 0.9, fontWeight: 500 }}>
|
||||||
|
<FitText maxFontSize={11} minFontSize={9}>
|
||||||
|
{percentStr}
|
||||||
|
</FitText>
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: { align: 'right', cellClassName: 'total-change-cell', width: columnWidthMap.totalChangePercent },
|
meta: { align: 'right', cellClassName: 'total-change-cell', width: columnWidthMap.totalChangePercent },
|
||||||
|
|||||||
@@ -521,35 +521,25 @@ export default function PcFundTable({
|
|||||||
minSize: 100,
|
minSize: 100,
|
||||||
cell: (info) => {
|
cell: (info) => {
|
||||||
const original = info.row.original || {};
|
const original = info.row.original || {};
|
||||||
const estimateValue = original.estimateChangeValue;
|
const value = original.estimateProfitValue;
|
||||||
const hasTodayEstimate = original.hasTodayEstimate;
|
const hasProfit = value != null;
|
||||||
const holdingProfitPercentStr = original.holdingProfitPercent ?? '';
|
const cls = hasProfit ? (value > 0 ? 'up' : value < 0 ? 'down' : '') : 'muted';
|
||||||
|
const amountStr = hasProfit ? (original.estimateProfit ?? '') : '—';
|
||||||
let holdingProfitPercentValue = null;
|
const percentStr = original.estimateProfitPercent ?? '';
|
||||||
if (holdingProfitPercentStr && holdingProfitPercentStr !== '') {
|
|
||||||
const numStr = holdingProfitPercentStr.replace(/[+%]/g, '');
|
|
||||||
holdingProfitPercentValue = parseFloat(numStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasEstimate = hasTodayEstimate && estimateValue != null;
|
|
||||||
const hasHolding = holdingProfitPercentValue != null && !isNaN(holdingProfitPercentValue);
|
|
||||||
|
|
||||||
if (!hasEstimate && !hasHolding) {
|
|
||||||
return (
|
|
||||||
<FitText className="muted" style={{ fontWeight: 700 }} maxFontSize={14} minFontSize={10}>
|
|
||||||
—
|
|
||||||
</FitText>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const total = (hasEstimate ? estimateValue : 0) + (hasHolding ? holdingProfitPercentValue : 0);
|
|
||||||
const cls = total > 0 ? 'up' : total < 0 ? 'down' : '';
|
|
||||||
const displayValue = `${total > 0 ? '+' : ''}${total.toFixed(2)}%`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FitText className={cls} style={{ fontWeight: 700 }} maxFontSize={14} minFontSize={10}>
|
<div style={{ width: '100%' }}>
|
||||||
{displayValue}
|
<FitText className={cls} style={{ fontWeight: 700, display: 'block' }} maxFontSize={14} minFontSize={10}>
|
||||||
|
{amountStr}
|
||||||
</FitText>
|
</FitText>
|
||||||
|
{percentStr ? (
|
||||||
|
<span className={`${cls} estimate-profit-percent`} style={{ display: 'block', fontSize: '0.75em', opacity: 0.9, fontWeight: 500 }}>
|
||||||
|
<FitText maxFontSize={11} minFontSize={9}>
|
||||||
|
{percentStr}
|
||||||
|
</FitText>
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
28
app/page.jsx
28
app/page.jsx
@@ -815,6 +815,30 @@ export default function HomePage() {
|
|||||||
: '';
|
: '';
|
||||||
const holdingProfitValue = total;
|
const holdingProfitValue = total;
|
||||||
|
|
||||||
|
const holdingProfitPercentValue =
|
||||||
|
total != null && principal > 0 ? (total / principal) * 100 : null;
|
||||||
|
const hasEstimatePercent = hasTodayEstimate && estimateChangeValue != null;
|
||||||
|
const hasHoldingPercent = holdingProfitPercentValue != null;
|
||||||
|
const fallbackEstimateProfitPercentValue = hasEstimatePercent || hasHoldingPercent
|
||||||
|
? (hasEstimatePercent ? estimateChangeValue : 0) + (hasHoldingPercent ? holdingProfitPercentValue : 0)
|
||||||
|
: null;
|
||||||
|
const estimateProfitPercentValue = hasTodayData
|
||||||
|
? holdingProfitPercentValue
|
||||||
|
: fallbackEstimateProfitPercentValue;
|
||||||
|
const estimateProfitValue = hasTodayData
|
||||||
|
? total
|
||||||
|
: (estimateProfitPercentValue != null && principal > 0
|
||||||
|
? principal * (estimateProfitPercentValue / 100)
|
||||||
|
: null);
|
||||||
|
const estimateProfit =
|
||||||
|
estimateProfitValue == null
|
||||||
|
? ''
|
||||||
|
: `${estimateProfitValue > 0 ? '+' : estimateProfitValue < 0 ? '-' : ''}¥${Math.abs(estimateProfitValue).toFixed(2)}`;
|
||||||
|
const estimateProfitPercent =
|
||||||
|
estimateProfitPercentValue == null
|
||||||
|
? ''
|
||||||
|
: `${estimateProfitPercentValue > 0 ? '+' : ''}${estimateProfitPercentValue.toFixed(2)}%`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rawFund: f,
|
rawFund: f,
|
||||||
code: f.code,
|
code: f.code,
|
||||||
@@ -831,6 +855,10 @@ export default function HomePage() {
|
|||||||
estimateChangeMuted: f.noValuation,
|
estimateChangeMuted: f.noValuation,
|
||||||
estimateTime,
|
estimateTime,
|
||||||
hasTodayEstimate,
|
hasTodayEstimate,
|
||||||
|
totalChangePercent: estimateProfitPercent,
|
||||||
|
estimateProfit,
|
||||||
|
estimateProfitValue,
|
||||||
|
estimateProfitPercent,
|
||||||
holdingAmount,
|
holdingAmount,
|
||||||
holdingAmountValue,
|
holdingAmountValue,
|
||||||
todayProfit,
|
todayProfit,
|
||||||
|
|||||||
Reference in New Issue
Block a user