diff --git a/frontend/src/pages/News.jsx b/frontend/src/pages/News.jsx index aeba8e9..e448fe9 100644 --- a/frontend/src/pages/News.jsx +++ b/frontend/src/pages/News.jsx @@ -588,14 +588,14 @@ export default function News() { return p === pkg && c === cat }) if (items.length === 0) return null - // 按成交日期倒序排序 - items.sort((a, b) => { + // 按成交日期倒序排序(创建新数组避免引用问题) + const sortedItems = [...items].sort((a, b) => { const dateA = a.deal_date || a.created_at?.split('T')[0] || '' const dateB = b.deal_date || b.created_at?.split('T')[0] || '' return dateB.localeCompare(dateA) }) - const sum = items.reduce((a, b) => a + (b.deal_price || 0), 0) - return { avg: Math.round(sum / items.length), count: items.length, items } + const sum = sortedItems.reduce((a, b) => a + (b.deal_price || 0), 0) + return { avg: Math.round(sum / sortedItems.length), count: sortedItems.length, items: sortedItems } } return ( @@ -735,12 +735,12 @@ export default function News() { style={{ background: 'none', border: 'none', color: '#94a3b8', fontSize: '20px', cursor: 'pointer' }}>✕