diff --git a/manual_trading_hub/static/app.css b/manual_trading_hub/static/app.css index f2b6bd8..f8cd047 100644 --- a/manual_trading_hub/static/app.css +++ b/manual_trading_hub/static/app.css @@ -8670,6 +8670,25 @@ body.funds-fullscreen-open { background: var(--panel); overscroll-behavior: contain; } +.archive-trades-pager { + display: flex; + align-items: center; + gap: 8px; + margin-top: 8px; + font-size: 0.74rem; + color: var(--muted); +} +.archive-trades-pager[hidden] { + display: none !important; +} +.archive-trades-pager .ghost { + font-size: 0.72rem; + padding: 2px 8px; +} +.archive-trades-pager .ghost:disabled { + opacity: 0.45; + cursor: not-allowed; +} .archive-trades-table { width: 100%; min-width: 1000px; diff --git a/manual_trading_hub/static/archive.js b/manual_trading_hub/static/archive.js index 78a9824..3be3f9c 100644 --- a/manual_trading_hub/static/archive.js +++ b/manual_trading_hub/static/archive.js @@ -45,8 +45,13 @@ const elMarkAuto = document.getElementById("archive-mark-auto"); const elTrades = document.getElementById("archive-trades"); const elTradesSection = document.getElementById("archive-trades-section"); + const elTradesPager = document.getElementById("archive-trades-pager"); + const elTradesPrev = document.getElementById("archive-trades-prev"); + const elTradesNext = document.getElementById("archive-trades-next"); + const elTradesPageLabel = document.getElementById("archive-trades-page-label"); const ARCHIVE_MARK_AUTO_KEY = "hubArchiveMarkAuto"; - const TRADES_VISIBLE_ROWS_CHART_OPEN = 10; + const TRADES_PAGE_SIZE = 5; + const TRADES_VISIBLE_ROWS_CHART_OPEN = 5; const TF_MS = { "5m": 5 * 60_000, @@ -61,6 +66,7 @@ let selectedQuoteId = null; let editingQuoteId = null; let dailyTrades = []; + let tradesPage = 0; let dailyStats = { open_count: 0, by_exchange: {} }; let periodMode = "today"; let periodLabel = ""; @@ -1487,6 +1493,16 @@ ); } + function ensureTradePageVisible(tr) { + if (!tr || !dailyTrades.length) return; + const key = tradeRowKey(tr); + const idx = dailyTrades.findIndex(function (t) { + return tradeRowKey(t) === key; + }); + if (idx < 0) return; + tradesPage = Math.floor(idx / TRADES_PAGE_SIZE); + } + async function switchToTrade(tr) { if (!tr) return; const exKey = String(tr.exchange_key || "").toLowerCase(); @@ -1502,6 +1518,7 @@ selected = { exchange_key: exKey, symbol: sym }; selectedTradeKey = key; + ensureTradePageVisible(tr); renderTrades(); const needSymbolReload = prevEx !== exKey || prevSym !== sym; @@ -1535,19 +1552,49 @@ await switchToTrade(tr); } + function tradesPageCount() { + return Math.max(1, Math.ceil((dailyTrades.length || 0) / TRADES_PAGE_SIZE)); + } + + function clampTradesPage() { + const pages = tradesPageCount(); + if (tradesPage >= pages) tradesPage = pages - 1; + if (tradesPage < 0) tradesPage = 0; + } + + function updateTradesPager() { + clampTradesPage(); + const pages = tradesPageCount(); + const show = dailyTrades.length > TRADES_PAGE_SIZE; + if (elTradesPager) elTradesPager.hidden = !show; + if (elTradesPageLabel) { + elTradesPageLabel.textContent = "第 " + (tradesPage + 1) + " / " + pages + " 页"; + } + if (elTradesPrev) elTradesPrev.disabled = tradesPage <= 0; + if (elTradesNext) elTradesNext.disabled = tradesPage + 1 >= pages; + } + + function pagedDailyTrades() { + clampTradesPage(); + const start = tradesPage * TRADES_PAGE_SIZE; + return dailyTrades.slice(start, start + TRADES_PAGE_SIZE); + } + function renderTrades() { if (!elTrades) return; if (!dailyTrades.length) { elTrades.innerHTML = '
该日暂无交易记录.可调整日期或点击「同步」拉取数据.
'; + updateTradesPager(); return; } + const pageRows = pagedDailyTrades(); elTrades.innerHTML = '| 交易所 | 合约 | 开仓类型 | 开仓时间 | 平仓时间 | 持仓时长 | " + "方向 | 结果 | 盈亏 | 成交额 | 手续费 | 标签 | 备注 | 操作 | " + "
|---|