From 7957a62c65709c5f926ba091d6c1b397208c7988 Mon Sep 17 00:00:00 2001 From: dekun Date: Wed, 3 Jun 2026 23:20:34 +0800 Subject: [PATCH] fix(hub): use single position table header on desktop monitor cards Render all exchange positions in one table row group instead of repeating column headers per symbol. Co-authored-by: Cursor --- manual_trading_hub/static/app.css | 8 +++ manual_trading_hub/static/app.js | 92 ++++++++++++++++++++-------- manual_trading_hub/static/index.html | 2 +- 3 files changed, 76 insertions(+), 26 deletions(-) diff --git a/manual_trading_hub/static/app.css b/manual_trading_hub/static/app.css index b47dfb3..144923f 100644 --- a/manual_trading_hub/static/app.css +++ b/manual_trading_hub/static/app.css @@ -1272,6 +1272,14 @@ body.market-chart-fs-open { margin-bottom: 0; } +.pos-table-wrap { + margin-bottom: 8px; +} + +.data-table-positions tbody tr:not(:last-child) td { + border-bottom: 1px dashed var(--border-soft); +} + .pos-action-group { display: inline-flex; flex-direction: row; diff --git a/manual_trading_hub/static/app.js b/manual_trading_hub/static/app.js index f44d74d..105684e 100644 --- a/manual_trading_hub/static/app.js +++ b/manual_trading_hub/static/app.js @@ -1537,16 +1537,25 @@ .join(""); } - function renderPositionBlock(exchangeId, exchangeKey, x, monitorOrder, trendPlan, tickMap, opts) { + function renderPositionTableRow( + exchangeId, + exchangeKey, + x, + monitorOrder, + trendPlan, + tickMap, + opts + ) { const options = opts || {}; const compact = !!options.compact; const symAttr = esc(x.symbol || "").replace(/"/g, """); - const exKeyAttr = esc(exchangeKey || exchangeId || "").replace(/"/g, """); const sideAttr = esc((x.side || "").toLowerCase()).replace(/"/g, """); const side = sideAttr || "long"; - const contractsAttr = esc(String(x.contracts != null ? x.contracts : "")).replace(/"/g, """); + const contractsAttr = esc(String(x.contracts != null ? x.contracts : "")).replace( + /"/g, + """ + ); const cond = condOrdersFromPosition(x); - const reg = Array.isArray(x.regular_orders) ? x.regular_orders : []; const tpsl = resolvePositionTpsl(x, monitorOrder, trendPlan); const beSecured = isBreakevenSecured(side, tpsl.entry, monitorOrder, cond, x); const slAttr = esc(String(tpsl.sl)).replace(/"/g, """); @@ -1559,13 +1568,7 @@ `; - const ordersBlock = compact - ? "" - : renderOrdersCollapse(exchangeId, x.symbol, cond, reg, tickMap); - return `
-
- - + return ` @@ -1573,13 +1576,57 @@ - + `; + } + + function renderPositionBlock(exchangeId, exchangeKey, x, monitorOrder, trendPlan, tickMap, opts) { + const options = opts || {}; + const compact = !!options.compact; + const reg = Array.isArray(x.regular_orders) ? x.regular_orders : []; + const cond = condOrdersFromPosition(x); + const ordersBlock = compact + ? "" + : renderOrdersCollapse(exchangeId, x.symbol, cond, reg, tickMap); + const rowHtml = renderPositionTableRow( + exchangeId, + exchangeKey, + x, + monitorOrder, + trendPlan, + tickMap, + opts + ); + return `
+
+
合约方向开仓价标记价张数浮盈操作
${symBeBadge} ${renderDirectionHtml(x.side)} ${fmtEntryPrice(x, tickMap)}${fmt(x.contracts, 4)} ${fmt(x.unrealized_pnl, 2)} ${actionCell}
+ ${rowHtml}
合约方向开仓价标记价张数浮盈操作
${ordersBlock}
`; } + function renderGridPositionsTable(exchangeId, exchangeKey, positions, orders, trends, tickMap) { + const rows = positions + .map((p) => + renderPositionTableRow( + exchangeId, + exchangeKey, + p, + findMonitorOrder(orders, p.symbol, p.side), + findTrendPlan(trends, p.symbol, p.side), + tickMap, + { compact: true } + ) + ) + .join(""); + return `
+ + ${rows} +
合约方向开仓价标记价张数浮盈操作
+
`; + } + function renderGridBody(row, ag, pos, hm, flaskOk, keys, orders, trends, rolls, kmap) { const tickMap = buildPriceTickMap(row); let inner = `
@@ -1588,19 +1635,14 @@
`; inner += `
交易所持仓 · ${pos.length} 仓
`; if (pos.length) { - inner += pos - .map((p) => - renderPositionBlock( - row.id, - row.key || row.id, - p, - findMonitorOrder(orders, p.symbol, p.side), - findTrendPlan(trends, p.symbol, p.side), - tickMap, - { compact: true } - ) - ) - .join(""); + inner += renderGridPositionsTable( + row.id, + row.key || row.id, + pos, + orders, + trends, + tickMap + ); } else { inner += '
无持仓
'; } diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index e168fe8..8abd24a 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -246,6 +246,6 @@
- +