行情区:现价标签固定于右侧10根留白区,倒计时在现价下方

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-02 12:20:24 +08:00
parent 441bdf7e71
commit 3dcf91c573
3 changed files with 49 additions and 29 deletions
+26 -1
View File
@@ -2072,10 +2072,35 @@ body.login-page {
line-height: 1.25; line-height: 1.25;
text-align: center; text-align: center;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
min-width: 68px; min-width: 72px;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); 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 { .market-price-tag.hidden {
display: none; display: none;
} }
+17 -25
View File
@@ -183,8 +183,8 @@
color: up ? "#00ff9d" : "#ff4d6d", color: up ? "#00ff9d" : "#ff4d6d",
lineWidth: 1, lineWidth: 1,
lineStyle: 2, lineStyle: 2,
axisLabelVisible: true, axisLabelVisible: false,
title: "现价", title: "",
}); });
} }
@@ -222,33 +222,24 @@
return 6; return 6;
} }
function priceTagX() { function plotAreaWidth() {
if (!chart || !lastCandles.length) return null; if (!chart) return chartHost.clientWidth || 0;
const bar = latestCandle();
if (!bar) return null;
const ts = chart.timeScale(); const ts = chart.timeScale();
const spacing = getBarSpacing(ts);
const hostW = chartHost.clientWidth || 0;
let x = null;
try { try {
const lastIdx = lastCandles.length - 1; if (typeof ts.width === "function") {
const lastX = ts.logicalToCoordinate(lastIdx); const w = ts.width();
if (lastX != null && Number.isFinite(lastX)) { if (Number.isFinite(w) && w > 0) return w;
x = lastX + (RIGHT_OFFSET_BARS * spacing) / 2;
} }
} catch (e) {} } catch (e) {}
if (x == null) { return chartHost.clientWidth || 0;
try { }
const tx = ts.timeToCoordinate(bar.time);
if (tx != null && Number.isFinite(tx)) { /** 固定在右侧 10 根 K 线留白区中央,不随 K 线横向滚动 */
x = tx + (RIGHT_OFFSET_BARS * spacing) / 2; function priceTagX() {
} const spacing = getBarSpacing(chart && chart.timeScale());
} catch (e2) {} const plotW = plotAreaWidth();
} if (plotW <= 0 || spacing <= 0) return null;
if (x == null && hostW > 0 && spacing > 0) { return plotW - (RIGHT_OFFSET_BARS * spacing) / 2;
x = hostW - (RIGHT_OFFSET_BARS * spacing) / 2;
}
return x;
} }
function updatePriceTag() { function updatePriceTag() {
@@ -280,6 +271,7 @@
elPriceTag.classList.add(up ? "is-up" : "is-down"); elPriceTag.classList.add(up ? "is-up" : "is-down");
elPriceTag.setAttribute("aria-hidden", "false"); elPriceTag.setAttribute("aria-hidden", "false");
elPriceTag.style.left = x + "px"; elPriceTag.style.left = x + "px";
elPriceTag.style.right = "auto";
elPriceTag.style.top = y + "px"; elPriceTag.style.top = y + "px";
if (elPriceTagValue) elPriceTagValue.textContent = fmtPrice(bar.close); if (elPriceTagValue) elPriceTagValue.textContent = fmtPrice(bar.close);
} catch (e) { } catch (e) {
+6 -3
View File
@@ -117,7 +117,10 @@
<div id="market-exchange-badge" class="market-exchange-badge" aria-hidden="true"></div> <div id="market-exchange-badge" class="market-exchange-badge" aria-hidden="true"></div>
<div id="market-chart" class="market-chart-host"></div> <div id="market-chart" class="market-chart-host"></div>
<div id="market-price-tag" class="market-price-tag hidden" aria-hidden="true"> <div id="market-price-tag" class="market-price-tag hidden" aria-hidden="true">
<div id="market-price-tag-value" class="market-price-tag-value"></div> <div class="market-price-tag-head">
<span class="market-price-tag-label">现价</span>
<span id="market-price-tag-value" class="market-price-tag-value"></span>
</div>
<div id="market-price-tag-time" class="market-price-tag-time"></div> <div id="market-price-tag-time" class="market-price-tag-time"></div>
</div> </div>
<button type="button" id="market-price-auto" class="market-price-auto is-on" title="价格轴自动缩放">自动</button> <button type="button" id="market-price-auto" class="market-price-auto is-on" title="价格轴自动缩放">自动</button>
@@ -190,7 +193,7 @@
<div id="toast"></div> <div id="toast"></div>
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script> <script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
<script src="/assets/chart.js?v=20260528-hub-market10"></script> <script src="/assets/chart.js?v=20260528-hub-market11"></script>
<script src="/assets/app.js?v=20260528-hub-market10"></script> <script src="/assets/app.js?v=20260528-hub-market11"></script>
</body> </body>
</html> </html>