v0.2.5 - 修复排序按created_at
This commit is contained in:
parent
9b960c1d12
commit
645819844e
|
|
@ -588,11 +588,11 @@ export default function News() {
|
||||||
return p === pkg && c === cat
|
return p === pkg && c === cat
|
||||||
})
|
})
|
||||||
if (items.length === 0) return null
|
if (items.length === 0) return null
|
||||||
// 按成交日期倒序排序(创建新数组避免引用问题)
|
// 按创建时间倒序排序
|
||||||
const sortedItems = [...items].sort((a, b) => {
|
const sortedItems = [...items].sort((a, b) => {
|
||||||
const dateA = a.deal_date || a.created_at?.split('T')[0] || ''
|
const timeA = a.created_at || '1970-01-01T00:00:00'
|
||||||
const dateB = b.deal_date || b.created_at?.split('T')[0] || ''
|
const timeB = b.created_at || '1970-01-01T00:00:00'
|
||||||
return dateB.localeCompare(dateA)
|
return timeB.localeCompare(timeA)
|
||||||
})
|
})
|
||||||
const sum = sortedItems.reduce((a, b) => a + (b.deal_price || 0), 0)
|
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 { avg: Math.round(sum / sortedItems.length), count: sortedItems.length, items: sortedItems }
|
||||||
|
|
@ -735,12 +735,10 @@ export default function News() {
|
||||||
style={{ background: 'none', border: 'none', color: '#94a3b8', fontSize: '20px', cursor: 'pointer' }}>✕</button>
|
style={{ background: 'none', border: 'none', color: '#94a3b8', fontSize: '20px', cursor: 'pointer' }}>✕</button>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
||||||
{/* 按成交日期倒序排序(创建新数组确保排序生效) */}
|
{/* 按创建时间倒序排序 */}
|
||||||
{[...dealDetailItems].sort((a, b) => {
|
{dealDetailItems
|
||||||
const dateA = a.deal_date || a.created_at?.split('T')[0] || ''
|
.sort((a, b) => (b.created_at || '').localeCompare(a.created_at || ''))
|
||||||
const dateB = b.deal_date || b.created_at?.split('T')[0] || ''
|
.map((item, idx) => {
|
||||||
return dateB.localeCompare(dateA)
|
|
||||||
}).map((item, idx) => {
|
|
||||||
const content = item.content || ''
|
const content = item.content || ''
|
||||||
const grade = content.includes('评级:') ? content.split('评级:')[1].split('\n')[0].trim() : (item.grading_score || '')
|
const grade = content.includes('评级:') ? content.split('评级:')[1].split('\n')[0].trim() : (item.grading_score || '')
|
||||||
const sizeMatch = content.match(/大小号:\s*(.+?)(?:\n|$)/)
|
const sizeMatch = content.match(/大小号:\s*(.+?)(?:\n|$)/)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue