v0.2.4 - 修复排序(创建新数组+修复NULL日期)
This commit is contained in:
parent
9b7f634ad3
commit
b1d5398220
|
|
@ -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' }}>✕</button>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
||||
{/* 按成交日期倒序排序 */}
|
||||
{([...dealDetailItems].sort((a, b) => {
|
||||
{/* 按成交日期倒序排序(创建新数组确保排序生效) */}
|
||||
{[...dealDetailItems].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)
|
||||
})).map((item, idx) => {
|
||||
}).map((item, idx) => {
|
||||
const content = item.content || ''
|
||||
const grade = content.includes('评级:') ? content.split('评级:')[1].split('\n')[0].trim() : (item.grading_score || '')
|
||||
const sizeMatch = content.match(/大小号:\s*(.+?)(?:\n|$)/)
|
||||
|
|
|
|||
Loading…
Reference in New Issue