From 3dcf91c573ec108dc77179645a3b7f725aeaff64 Mon Sep 17 00:00:00 2001 From: dekun Date: Tue, 2 Jun 2026 12:20:24 +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=E5=9B=BA=E5=AE=9A=E4=BA=8E=E5=8F=B3?= =?UTF-8?q?=E4=BE=A710=E6=A0=B9=E7=95=99=E7=99=BD=E5=8C=BA=EF=BC=8C?= =?UTF-8?q?=E5=80=92=E8=AE=A1=E6=97=B6=E5=9C=A8=E7=8E=B0=E4=BB=B7=E4=B8=8B?= =?UTF-8?q?=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 | 27 +++++++++++++++++- manual_trading_hub/static/chart.js | 42 +++++++++++----------------- manual_trading_hub/static/index.html | 9 ++++-- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/manual_trading_hub/static/app.css b/manual_trading_hub/static/app.css index 9797a8b..318789d 100644 --- a/manual_trading_hub/static/app.css +++ b/manual_trading_hub/static/app.css @@ -2072,10 +2072,35 @@ body.login-page { line-height: 1.25; text-align: center; transform: translate(-50%, -50%); - min-width: 68px; + min-width: 72px; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); } +.market-price-tag-head { + display: flex; + flex-direction: row; + align-items: baseline; + justify-content: center; + gap: 4px; + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +.market-price-tag-label { + font-size: 0.62rem; + font-weight: 500; + opacity: 0.9; + line-height: 1; +} + +.market-price-tag.is-up .market-price-tag-label { + color: rgba(10, 16, 24, 0.75); +} + +.market-price-tag.is-down .market-price-tag-label { + color: rgba(255, 255, 255, 0.85); +} + .market-price-tag.hidden { display: none; } diff --git a/manual_trading_hub/static/chart.js b/manual_trading_hub/static/chart.js index bb4d7cc..5b6e145 100644 --- a/manual_trading_hub/static/chart.js +++ b/manual_trading_hub/static/chart.js @@ -183,8 +183,8 @@ color: up ? "#00ff9d" : "#ff4d6d", lineWidth: 1, lineStyle: 2, - axisLabelVisible: true, - title: "现价", + axisLabelVisible: false, + title: "", }); } @@ -222,33 +222,24 @@ return 6; } - function priceTagX() { - if (!chart || !lastCandles.length) return null; - const bar = latestCandle(); - if (!bar) return null; + function plotAreaWidth() { + if (!chart) return chartHost.clientWidth || 0; const ts = chart.timeScale(); - const spacing = getBarSpacing(ts); - 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; + if (typeof ts.width === "function") { + const w = ts.width(); + if (Number.isFinite(w) && w > 0) return w; } } 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; + return chartHost.clientWidth || 0; + } + + /** 固定在右侧 10 根 K 线留白区中央,不随 K 线横向滚动 */ + function priceTagX() { + const spacing = getBarSpacing(chart && chart.timeScale()); + const plotW = plotAreaWidth(); + if (plotW <= 0 || spacing <= 0) return null; + return plotW - (RIGHT_OFFSET_BARS * spacing) / 2; } function updatePriceTag() { @@ -280,6 +271,7 @@ elPriceTag.classList.add(up ? "is-up" : "is-down"); elPriceTag.setAttribute("aria-hidden", "false"); elPriceTag.style.left = x + "px"; + elPriceTag.style.right = "auto"; elPriceTag.style.top = y + "px"; if (elPriceTagValue) elPriceTagValue.textContent = fmtPrice(bar.close); } catch (e) { diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index c8ccda8..9083edb 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -117,7 +117,10 @@
@@ -190,7 +193,7 @@
- - + +