feat: show force-close badge and countdown when FORCE_CLOSE is enabled

Add shared lib/UI for midnight force-close indicator on instance and hub pages, and document Gate intraday 0-point exit alignment.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-06 02:17:47 +08:00
parent 7fb87d6030
commit a268a93027
22 changed files with 974 additions and 18 deletions
@@ -944,6 +944,9 @@ function refreshPriceSnapshot(){
if(data.updated_at && updatedEl){
updatedEl.innerText = data.updated_at;
}
if(data.force_close && window.TimeCloseUI && TimeCloseUI.paintForceCloseHeader){
TimeCloseUI.paintForceCloseHeader(data.force_close);
}
(data.key_prices || []).forEach(k=>{
const pEl = document.getElementById(`key-price-${k.id}`);
if(pEl){
@@ -1015,6 +1018,7 @@ function refreshPriceSnapshot(){
if(o.exchange_tpsl) paintExchangeTpslRow(o.id, o.exchange_tpsl);
paintPlanTpslDisplay(o.id, o);
if(window.TimeCloseUI) TimeCloseUI.paintOrderTimeClose(o);
if(window.TimeCloseUI) TimeCloseUI.paintOrderForceClose(o);
});
}).catch(()=>{});
}
@@ -1074,6 +1078,9 @@ function refreshAccountSnapshot(){
}
}
}
if (data.force_close && window.TimeCloseUI && TimeCloseUI.paintForceCloseHeader) {
TimeCloseUI.paintForceCloseHeader(data.force_close);
}
let canTradeText = "可开仓";
if (!data.can_trade) {
const parts = [];
@@ -1247,6 +1254,9 @@ function refreshPriceSnapshotConditional(){
fetch("/api/price_snapshot").then(r=>r.json()).then(data=>{
const updatedEl = document.getElementById("price-last-updated");
if(data.updated_at && updatedEl) updatedEl.innerText = data.updated_at;
if(data.force_close && window.TimeCloseUI && TimeCloseUI.paintForceCloseHeader){
TimeCloseUI.paintForceCloseHeader(data.force_close);
}
if(page === "key_monitor"){
(data.key_prices || []).forEach(k=>{
const pEl = document.getElementById(`key-price-${k.id}`);
@@ -1296,6 +1306,7 @@ function refreshPriceSnapshotConditional(){
paintExchangeTpslRow(o.id, o.exchange_tpsl || {});
paintPlanTpslDisplay(o.id, o);
if(window.TimeCloseUI) TimeCloseUI.paintOrderTimeClose(o);
if(window.TimeCloseUI) TimeCloseUI.paintOrderForceClose(o);
const holdEl = document.getElementById(`order-hold-duration-${o.id}`);
if(holdEl && o.opened_at_ms != null && o.opened_at_ms !== ""){
holdEl.setAttribute("data-order-opened-ms", String(o.opened_at_ms));