diff --git a/app/page.jsx b/app/page.jsx index 29362a1..e6a81ee 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -167,12 +167,14 @@ export default function HomePage() { { id: 'default', label: '默认', enabled: true }, // 估值涨幅为原始名称,“涨跌幅”为别名 { id: 'yield', label: '估值涨幅', alias: '涨跌幅', enabled: true }, + // 持仓金额排序:默认隐藏 + { id: 'holdingAmount', label: '持仓金额', enabled: false }, { id: 'holding', label: '持有收益', enabled: true }, - { id: 'name', label: '名称', enabled: true }, + { id: 'name', label: '基金名称', alias: '名称', enabled: true }, ]; // 排序状态 - const [sortBy, setSortBy] = useState('default'); // default, name, yield, holding + const [sortBy, setSortBy] = useState('default'); // default, name, yield, holding, holdingAmount const [sortOrder, setSortOrder] = useState('desc'); // asc | desc const [isSortLoaded, setIsSortLoaded] = useState(false); const [sortRules, setSortRules] = useState(DEFAULT_SORT_RULES); @@ -652,6 +654,13 @@ export default function HomePage() { return sortOrder === 'asc' ? valA - valB : valB - valA; } + if (sortBy === 'holdingAmount') { + const pa = getHoldingProfit(a, holdings[a.code]); + const pb = getHoldingProfit(b, holdings[b.code]); + const amountA = pa?.amount ?? Number.NEGATIVE_INFINITY; + const amountB = pb?.amount ?? Number.NEGATIVE_INFINITY; + return sortOrder === 'asc' ? amountA - amountB : amountB - amountA; + } if (sortBy === 'holding') { const pa = getHoldingProfit(a, holdings[a.code]); const pb = getHoldingProfit(b, holdings[b.code]);