From 0e6c102ab24f5cafdb461982e5a04b2aa0126477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=BD=E5=B7=A5=E5=91=98?= <4846a27a-ba87-49c9-939d-7275f63efcc7@agents.multica.local> Date: Mon, 24 Aug 2026 18:01:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(HEL-80):=20=E6=8E=A5=E9=80=9A=E5=A4=8D?= =?UTF-8?q?=E6=9D=82=E9=A1=B5=E8=A1=A8=E6=A0=BC=E6=8E=92=E5=BA=8F=EF=BC=88?= =?UTF-8?q?=E6=83=85=E7=BB=AA=E5=8E=86=E5=8F=B2/=E7=AB=9E=E4=BB=B7/?= =?UTF-8?q?=E8=BD=AE=E5=8A=A8/=E9=A2=98=E6=9D=90/=E9=BE=99=E8=99=8E?= =?UTF-8?q?=E5=86=85=E5=B5=8C=E8=A1=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: multica-agent --- app/frontend/m/js/pages.js | 63 +++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/app/frontend/m/js/pages.js b/app/frontend/m/js/pages.js index b6a8fda..0f5e8a0 100644 --- a/app/frontend/m/js/pages.js +++ b/app/frontend/m/js/pages.js @@ -109,6 +109,7 @@ seq: 0, calCursor: null, sort: { key: "", dir: null }, + sortTable: { cols: null, reapply: null }, detail: null, sentimentHistory: null, sentimentRange: 20, @@ -189,10 +190,9 @@ } function toggleSort(key) { - const cfg = pageConfig(state.key); - if (!cfg) return; - const cols = columnsFor(cfg); - const col = findColumn(cols, key); + const active = state.sortTable; + if (!active || !active.cols) return; + const col = findColumn(active.cols, key); if (!col || !sortableColumn(col)) return; const firstDir = isNumericType(col.type) ? "desc" : "asc"; if (state.sort.key !== key) { @@ -202,7 +202,7 @@ } else { state.sort = { key: "", dir: null }; } - renderTableBody(); + active.reapply(); } /* ---------------------------------------------------------------- cells */ @@ -670,6 +670,7 @@ const cfg = pageConfig(key); if (!cfg) return; const cols = columnsFor(cfg); + state.sortTable = { cols: cols, reapply: renderTableBody }; const rows = sortedRows(prepareRows(key), cols); const scroll = document.getElementById("m-table-scroll"); if (!scroll) return; @@ -728,11 +729,21 @@ return cfg || null; } - function tableScrollHtml(subKey, rows, opts) { + function mountSortableTable(containerId, subKey, rowsProvider, opts) { const cols = columnsForKey(subKey); - if (!cols) return emptyHtml(); - if (!rows || !rows.length) return emptyHtml(); - return '
' + buildTable(cols, rows, opts || {}) + "
"; + if (!cols) return; + const reapply = function () { + const container = document.getElementById(containerId); + if (!container) return; + const rows = sortedRows(rowsProvider() || [], cols); + if (!rows.length) { + container.innerHTML = emptyHtml(); + return; + } + container.innerHTML = buildTable(cols, rows, opts || {}); + }; + state.sortTable = { cols: cols, reapply: reapply }; + reapply(); } function complexFrame(key, bodyHtml) { @@ -750,6 +761,7 @@ state.popularity = null; state.calCursor = null; state.sort = { key: "", dir: null }; + state.sortTable = { cols: null, reapply: null }; state.detail = null; state.sentimentHistory = null; state.rotation = null; @@ -876,7 +888,6 @@ const history = state.sentimentHistory || {}; const rawRows = history.rows || []; const latest = rawRows.length ? rawRows[rawRows.length - 1] : null; - const tableRows = rawRows.slice().reverse(); let card = ""; if (latest) { @@ -908,13 +919,15 @@ return '"; }).join(""); - const histRows = tableRows.map(function (r) { - return Object.assign({}, r, { trade_date: displayCompactDate(r.trade_date) }); - }); - scroll.innerHTML = card + '
历史明细 ' + rangeTabs + "
" + - tableScrollHtml("market/sentiment/history", histRows, {}); + '
'; + mountSortableTable("m-sentiment-hist", "market/sentiment/history", function () { + const raw = (state.sentimentHistory && state.sentimentHistory.rows) || []; + return raw.slice().reverse().map(function (r) { + return Object.assign({}, r, { trade_date: displayCompactDate(r.trade_date) }); + }); + }, {}); } function sentMetric(label, valueHtml, tone) { @@ -1109,10 +1122,12 @@ if (!body) return; if (payload.error) { body.innerHTML = emptyHtml(); return; } const meta = payload.meta || {}; - const rows = payload.rows || []; const metaLine = '
' + escapeHtml(displayCompactDate(meta.trade_date) || "--") + " · " + number(meta.quoted_count) + " / " + number(meta.member_count) + " 只
"; - body.innerHTML = metaLine + tableScrollHtml("market/rotation/members", rows, { noLink: true }); + body.innerHTML = metaLine + '
'; + mountSortableTable("m-rotation-members-table", "market/rotation/members", function () { + return (state.rotationMembers && state.rotationMembers.rows) || []; + }, { noLink: true }); } /* ----- 竞价 ----- */ @@ -1226,11 +1241,7 @@ } function renderAuctionTable() { - const table = document.getElementById("m-auction-table"); - if (!table) return; - const rows = auctionRows(); - if (!rows.length) { table.innerHTML = emptyHtml(); return; } - table.innerHTML = buildTable(columnsForKey("market/auction"), rows); + mountSortableTable("m-auction-table", "market/auction", auctionRows, {}); } /* ----- 题材库 ----- */ @@ -1325,7 +1336,10 @@ '
' + escapeHtml(theme.code || "--") + " · " + escapeHtml(displayCompactDate(meta.trade_date) || "--") + "
" + '
' + metrics + "
" + '
成分股
' + - tableScrollHtml("market/themes/members", payload.members || [], { noLink: true }); + '
'; + mountSortableTable("m-theme-members-table", "market/themes/members", function () { + return (state.themesDetail && state.themesDetail.members) || []; + }, { noLink: true }); } /* ----- 龙虎榜 ----- */ @@ -1466,10 +1480,11 @@ totRow("卖出", trader.sell_million, "down") + totRow("净额", trader.net_buy_million, changeClass(trader.net_buy_million)) + "" + - tableScrollHtml("market/dragon/operations", ops, { noLink: true }) + + '
' + "", { detail: true } ); + mountSortableTable("m-dragon-ops-table", "market/dragon/operations", function () { return ops; }, { noLink: true }); } function totRow(label, value, cls) {