feat: 新增综合涨幅

This commit is contained in:
hzm
2026-03-06 08:42:30 +08:00
parent 44dfb944c7
commit 99ec356fbb
4 changed files with 99 additions and 5 deletions

View File

@@ -67,11 +67,12 @@ export default function Announcement() {
<div style={{ color: 'var(--text)', lineHeight: '1.6', fontSize: '15px', overflowY: 'auto', minHeight: 0, flex: 1, paddingRight: '4px' }}> <div style={{ color: 'var(--text)', lineHeight: '1.6', fontSize: '15px', overflowY: 'auto', minHeight: 0, flex: 1, paddingRight: '4px' }}>
<p>v0.2.1 版本更新内容如下</p> <p>v0.2.1 版本更新内容如下</p>
<p>1. 改进拍照识别基金准确度</p> <p>1. 改进拍照识别基金准确度</p>
<p>2. 拍照导入支持识别持仓金额持仓收益</p> <p>2. 拍照导入支持选择分组识别持仓金额持仓收益</p>
<p>3. 个性化设置新增展示完整基金名称</p>
<p>4. 表格列新增综合涨幅(估值涨幅+持有收益涨幅)</p>
以下功能将会在下一个版本上线 以下功能将会在下一个版本上线
<p>1. 列表页查看基金详情</p> <p>1. 大盘走势数据</p>
<p>2. 大盘走势数据</p> <p>2. 关联板块</p>
<p>3. 关联板块</p>
</div> </div>
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '8px' }}> <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '8px' }}>

View File

@@ -29,6 +29,7 @@ import { ExitIcon, SettingsIcon, StarIcon } from './Icons';
const MOBILE_NON_FROZEN_COLUMN_IDS = [ const MOBILE_NON_FROZEN_COLUMN_IDS = [
'yesterdayChangePercent', 'yesterdayChangePercent',
'estimateChangePercent', 'estimateChangePercent',
'totalChangePercent',
'todayProfit', 'todayProfit',
'holdingProfit', 'holdingProfit',
'latestNav', 'latestNav',
@@ -39,6 +40,7 @@ const MOBILE_COLUMN_HEADERS = {
estimateNav: '估算净值', estimateNav: '估算净值',
yesterdayChangePercent: '昨日涨幅', yesterdayChangePercent: '昨日涨幅',
estimateChangePercent: '估值涨幅', estimateChangePercent: '估值涨幅',
totalChangePercent: '综合涨幅',
todayProfit: '当日收益', todayProfit: '当日收益',
holdingProfit: '持有收益', holdingProfit: '持有收益',
}; };
@@ -294,6 +296,7 @@ export default function MobileFundTable({
estimateNav: 64, estimateNav: 64,
yesterdayChangePercent: 72, yesterdayChangePercent: 72,
estimateChangePercent: 80, estimateChangePercent: 80,
totalChangePercent: 80,
todayProfit: 80, todayProfit: 80,
holdingProfit: 80, holdingProfit: 80,
}; };
@@ -523,6 +526,48 @@ export default function MobileFundTable({
}, },
meta: { align: 'right', cellClassName: 'est-change-cell', width: columnWidthMap.estimateChangePercent }, meta: { align: 'right', cellClassName: 'est-change-cell', width: columnWidthMap.estimateChangePercent },
}, },
{
accessorKey: 'totalChangePercent',
header: '综合涨幅',
cell: (info) => {
const original = info.row.original || {};
const estimateValue = original.estimateChangeValue;
const hasTodayEstimate = original.hasTodayEstimate;
const holdingProfitPercentStr = original.holdingProfitPercent ?? '';
let holdingProfitPercentValue = null;
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 (
<span className={cls} style={{ display: 'block', width: '100%', fontWeight: 700 }}>
<FitText maxFontSize={14} minFontSize={10}>
{displayValue}
</FitText>
</span>
);
},
meta: { align: 'right', cellClassName: 'total-change-cell', width: columnWidthMap.totalChangePercent },
},
{ {
accessorKey: 'todayProfit', accessorKey: 'todayProfit',
header: '当日收益', header: '当日收益',
@@ -689,7 +734,7 @@ export default function MobileFundTable({
const getAlignClass = (columnId) => { const getAlignClass = (columnId) => {
if (columnId === 'fundName') return ''; if (columnId === 'fundName') return '';
if (['latestNav', 'estimateNav', 'yesterdayChangePercent', 'estimateChangePercent', 'todayProfit', 'holdingProfit'].includes(columnId)) return 'text-right'; if (['latestNav', 'estimateNav', 'yesterdayChangePercent', 'estimateChangePercent', 'totalChangePercent', 'todayProfit', 'holdingProfit'].includes(columnId)) return 'text-right';
return 'text-right'; return 'text-right';
}; };

View File

@@ -30,6 +30,7 @@ import { DragIcon, ExitIcon, SettingsIcon, StarIcon, TrashIcon } from './Icons';
const NON_FROZEN_COLUMN_IDS = [ const NON_FROZEN_COLUMN_IDS = [
'yesterdayChangePercent', 'yesterdayChangePercent',
'estimateChangePercent', 'estimateChangePercent',
'totalChangePercent',
'holdingAmount', 'holdingAmount',
'todayProfit', 'todayProfit',
'holdingProfit', 'holdingProfit',
@@ -41,6 +42,7 @@ const COLUMN_HEADERS = {
estimateNav: '估算净值', estimateNav: '估算净值',
yesterdayChangePercent: '昨日涨幅', yesterdayChangePercent: '昨日涨幅',
estimateChangePercent: '估值涨幅', estimateChangePercent: '估值涨幅',
totalChangePercent: '综合涨幅',
holdingAmount: '持仓金额', holdingAmount: '持仓金额',
todayProfit: '当日收益', todayProfit: '当日收益',
holdingProfit: '持有收益', holdingProfit: '持有收益',
@@ -512,6 +514,49 @@ export default function PcFundTable({
cellClassName: 'est-change-cell', cellClassName: 'est-change-cell',
}, },
}, },
{
accessorKey: 'totalChangePercent',
header: '综合涨幅',
size: 135,
minSize: 100,
cell: (info) => {
const original = info.row.original || {};
const estimateValue = original.estimateChangeValue;
const hasTodayEstimate = original.hasTodayEstimate;
const holdingProfitPercentStr = original.holdingProfitPercent ?? '';
let holdingProfitPercentValue = null;
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 (
<FitText className={cls} style={{ fontWeight: 700 }} maxFontSize={14} minFontSize={10}>
{displayValue}
</FitText>
);
},
meta: {
align: 'right',
cellClassName: 'total-change-cell',
},
},
{ {
accessorKey: 'holdingAmount', accessorKey: 'holdingAmount',
header: '持仓金额', header: '持仓金额',
@@ -898,6 +943,7 @@ export default function PcFundTable({
'estimateNav', 'estimateNav',
'yesterdayChangePercent', 'yesterdayChangePercent',
'estimateChangePercent', 'estimateChangePercent',
'totalChangePercent',
'holdingAmount', 'holdingAmount',
'todayProfit', 'todayProfit',
'holdingProfit', 'holdingProfit',

View File

@@ -780,6 +780,7 @@ export default function HomePage() {
? (isNumber(f.estGszzl) ? Number(f.estGszzl) : null) ? (isNumber(f.estGszzl) ? Number(f.estGszzl) : null)
: (isNumber(f.gszzl) ? Number(f.gszzl) : null)); : (isNumber(f.gszzl) ? Number(f.gszzl) : null));
const estimateTime = f.noValuation ? (f.jzrq || '-') : (f.gztime || f.time || '-'); const estimateTime = f.noValuation ? (f.jzrq || '-') : (f.gztime || f.time || '-');
const hasTodayEstimate = !f.noValuation && isString(f.gztime) && f.gztime.startsWith(todayStr);
const holding = holdings[f.code]; const holding = holdings[f.code];
const profit = getHoldingProfit(f, holding); const profit = getHoldingProfit(f, holding);
@@ -829,6 +830,7 @@ export default function HomePage() {
estimateChangeValue, estimateChangeValue,
estimateChangeMuted: f.noValuation, estimateChangeMuted: f.noValuation,
estimateTime, estimateTime,
hasTodayEstimate,
holdingAmount, holdingAmount,
holdingAmountValue, holdingAmountValue,
todayProfit, todayProfit,