From 43f6aced94c6b2dc0b932eda19b699e405b8b679 Mon Sep 17 00:00:00 2001 From: dekun Date: Tue, 2 Jun 2026 12:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E6=83=85=E5=8C=BA=EF=BC=9A=E7=8E=B0?= =?UTF-8?q?=E4=BB=B7=E6=A0=87=E7=AD=BE=E7=A7=BB=E5=85=A5=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?10=E6=A0=B9=E7=95=99=E7=99=BD=E5=8C=BA=EF=BC=8C=E5=80=92?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=E5=9C=A8=E7=8E=B0=E4=BB=B7=E4=B8=8B=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- manual_trading_hub/static/app.css | 26 +++++++------------ manual_trading_hub/static/chart.js | 39 +++++++++++++++++++++++++--- manual_trading_hub/static/index.html | 14 +++++----- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/manual_trading_hub/static/app.css b/manual_trading_hub/static/app.css index 61ab133..9797a8b 100644 --- a/manual_trading_hub/static/app.css +++ b/manual_trading_hub/static/app.css @@ -1996,13 +1996,7 @@ body.login-page { flex: 1; min-width: 0; height: 100%; -} - -.market-price-gutter { - flex: 0 0 72px; position: relative; - border-left: 1px solid var(--border-soft); - background: #0a1018; } .market-exchange-badge { @@ -2068,18 +2062,17 @@ body.login-page { .market-price-tag { position: absolute; - left: 4px; - right: 4px; - z-index: 2; + z-index: 5; pointer-events: none; - padding: 4px 6px; + padding: 4px 8px; border-radius: 4px; font-family: var(--font); font-size: 0.72rem; font-weight: 600; - line-height: 1.2; + line-height: 1.25; text-align: center; - transform: translateY(-50%); + transform: translate(-50%, -50%); + min-width: 68px; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); } @@ -2102,19 +2095,20 @@ body.login-page { } .market-price-tag-time { - margin-top: 2px; + margin-top: 3px; font-size: 0.68rem; font-weight: 500; font-variant-numeric: tabular-nums; + line-height: 1; opacity: 0.95; } .market-price-auto { position: absolute; - left: 6px; - right: 6px; + right: 8px; bottom: 10px; - z-index: 2; + z-index: 5; + width: auto; padding: 4px 8px; font-size: 0.68rem; font-family: var(--font); diff --git a/manual_trading_hub/static/chart.js b/manual_trading_hub/static/chart.js index 86f8aa3..18e1e73 100644 --- a/manual_trading_hub/static/chart.js +++ b/manual_trading_hub/static/chart.js @@ -4,7 +4,7 @@ (function () { const AUTO_REFRESH_MS = 5000; const DEFAULT_VISIBLE_BARS = 200; - const RIGHT_OFFSET_BARS = 12; + const RIGHT_OFFSET_BARS = 10; const TF_MS = { "1m": 60_000, "5m": 5 * 60_000, @@ -24,7 +24,6 @@ const elStatus = document.getElementById("market-status"); const elUpdated = document.getElementById("market-updated"); const elBarCountdown = document.getElementById("market-bar-countdown"); - const elPriceGutter = document.querySelector(".market-price-gutter"); const elO = document.getElementById("mkt-o"); const elH = document.getElementById("mkt-h"); const elL = document.getElementById("mkt-l"); @@ -197,6 +196,35 @@ if (elBarCountdown) elBarCountdown.textContent = "距收盘 " + cd; } + function priceTagX() { + if (!chart || !lastCandles.length) return null; + const bar = latestCandle(); + if (!bar) return null; + const ts = chart.timeScale(); + const spacing = ts.barSpacing(); + const hostW = chartHost.clientWidth || 0; + let x = null; + try { + const lastIdx = lastCandles.length - 1; + const lastX = ts.logicalToCoordinate(lastIdx); + if (lastX != null && Number.isFinite(lastX)) { + x = lastX + (RIGHT_OFFSET_BARS * spacing) / 2; + } + } catch (e) {} + if (x == null) { + try { + const tx = ts.timeToCoordinate(bar.time); + if (tx != null && Number.isFinite(tx)) { + x = tx + (RIGHT_OFFSET_BARS * spacing) / 2; + } + } catch (e2) {} + } + if (x == null && hostW > 0 && spacing > 0) { + x = hostW - (RIGHT_OFFSET_BARS * spacing) / 2; + } + return x; + } + function updatePriceTag() { if (!elPriceTag || !candleSeries || !chart) return; tickLiveClock(); @@ -212,8 +240,10 @@ } catch (e) { y = null; } - const hostH = (elPriceGutter && elPriceGutter.clientHeight) || chartHost.clientHeight || 0; - if (y == null || y < 8 || y > hostH - 8) { + const x = priceTagX(); + const hostH = chartHost.clientHeight || 0; + const hostW = chartHost.clientWidth || 0; + if (y == null || x == null || y < 8 || y > hostH - 8 || x < 8 || x > hostW - 8) { elPriceTag.classList.add("hidden"); elPriceTag.setAttribute("aria-hidden", "true"); return; @@ -222,6 +252,7 @@ elPriceTag.classList.remove("hidden", "is-up", "is-down"); elPriceTag.classList.add(up ? "is-up" : "is-down"); elPriceTag.setAttribute("aria-hidden", "false"); + elPriceTag.style.left = x + "px"; elPriceTag.style.top = y + "px"; if (elPriceTagValue) elPriceTagValue.textContent = fmtPrice(bar.close); } diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index 842b4e4..fed78ca 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -116,13 +116,11 @@
-
- - + +
@@ -192,7 +190,7 @@
- - + +