diff --git a/frontend/src/pages/News.jsx b/frontend/src/pages/News.jsx index 2e864ca..2c16d42 100644 --- a/frontend/src/pages/News.jsx +++ b/frontend/src/pages/News.jsx @@ -104,7 +104,23 @@ export default function News() { } const data = await res.json() console.log('资讯列表:', data) - setInfoList(data || []) + + // 成交行情按分类排序 + let sortedData = data || [] + if (activeTab === 'deal') { + const categoryOrder = ['带4号', '带7号', '永恒号', '天马号', '天马王', '金山号', '金山王', '钻石号', '朦胧号', '朦胧王', '金马号', '金马王', '倒置号', '圆圆号'] + sortedData = [...(data || [])].sort((a, b) => { + const contentA = a.content || '' + const contentB = b.content || '' + const catA = contentA.match(/分类:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || a.category || '' + const catB = contentB.match(/分类:\s*(.+?)(?:\n|$)/)?.[1]?.trim() || b.category || '' + const idxA = categoryOrder.indexOf(catA) + const idxB = categoryOrder.indexOf(catB) + return (idxA === -1 ? 999 : idxA) - (idxB === -1 ? 999 : idxB) + }) + } + + setInfoList(sortedData) } catch (e) { console.error(e) setInfoList([])