From 510bee53e390ed221c0aabebded15d1f0ba6a2dd Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Sun, 15 Mar 2026 21:18:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=81=E4=BB=93?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.jsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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]);