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
|
||||
})
|
||||
if (items.length === 0) return null
|
||||
// 按成交日期倒序排序(创建新数组避免引用问题)
|
||||
// 按创建时间倒序排序
|
||||
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 timeA = a.created_at || '1970-01-01T00:00:00'
|
||||
const timeB = b.created_at || '1970-01-01T00:00:00'
|
||||
return timeB.localeCompare(timeA)
|
||||
})
|
||||
const sum = sortedItems.reduce((a, b) => a + (b.deal_price || 0), 0)
|
||||
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>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
||||
{/* 按成交日期倒序排序(创建新数组确保排序生效) */}
|
||||
{[...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) => {
|
||||
{/* 按创建时间倒序排序 */}
|
||||
{dealDetailItems
|
||||
.sort((a, b) => (b.created_at || '').localeCompare(a.created_at || ''))
|
||||
.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