Revert "修复实例页长时间后不自动刷新:回前台强制拉数、SSE假连接兜底、快照请求超时防卡死。"
This reverts commit dbf935a570.
This commit is contained in:
@@ -1173,17 +1173,6 @@ function accountSnapshotFundingMissing(data){
|
||||
return !hasFunding && !hasTotal && !hasTrading;
|
||||
}
|
||||
let accountSnapshotRetryCount = 0;
|
||||
let accountSnapshotInflight = false;
|
||||
let priceSnapshotInflight = false;
|
||||
|
||||
function fetchJsonWithTimeout(url, timeoutMs) {
|
||||
const ms = timeoutMs != null ? timeoutMs : 25000;
|
||||
const ac = new AbortController();
|
||||
const timer = setTimeout(function () { ac.abort(); }, ms);
|
||||
return fetch(url, { signal: ac.signal, credentials: "same-origin" })
|
||||
.then(function (r) { return r.json(); })
|
||||
.finally(function () { clearTimeout(timer); });
|
||||
}
|
||||
function applyAccountSnapshot(data){
|
||||
if(!data || typeof data !== "object") return;
|
||||
if(typeof data.show_perp_funds !== "undefined"){
|
||||
@@ -1274,10 +1263,8 @@ function applyAccountSnapshot(data){
|
||||
}
|
||||
function refreshAccountSnapshot(opts){
|
||||
const options = opts || {};
|
||||
if(accountSnapshotInflight && !options.force) return;
|
||||
accountSnapshotInflight = true;
|
||||
const qs = options.force ? "?force=1" : "";
|
||||
fetchJsonWithTimeout("/api/account_snapshot" + qs, 25000).then(data=>{
|
||||
fetch("/api/account_snapshot" + qs).then(r=>r.json()).then(data=>{
|
||||
applyAccountSnapshot(data);
|
||||
if(accountSnapshotFundingMissing(data) && !options.force && accountSnapshotRetryCount < 3){
|
||||
accountSnapshotRetryCount += 1;
|
||||
@@ -1290,7 +1277,7 @@ function refreshAccountSnapshot(opts){
|
||||
accountSnapshotRetryCount += 1;
|
||||
setTimeout(() => refreshAccountSnapshot({ silent: true }), 1200 * accountSnapshotRetryCount);
|
||||
}
|
||||
}).finally(()=>{ accountSnapshotInflight = false; });
|
||||
});
|
||||
}
|
||||
|
||||
const orderSymbolEl = document.getElementById("order-symbol");
|
||||
@@ -1432,10 +1419,8 @@ refreshOrderDefaults();
|
||||
if(typeof initOrderEntryModelSelect === "function") initOrderEntryModelSelect();
|
||||
refreshPriceSnapshotConditional();
|
||||
function refreshPriceSnapshotConditional(){
|
||||
if(priceSnapshotInflight) return;
|
||||
priceSnapshotInflight = true;
|
||||
const page = document.body.getAttribute("data-page") || "";
|
||||
fetchJsonWithTimeout("/api/price_snapshot", 25000).then(data=>{
|
||||
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){
|
||||
@@ -1489,7 +1474,7 @@ function refreshPriceSnapshotConditional(){
|
||||
} else if (typeof data.options_unrealized_pnl !== "undefined") {
|
||||
paintRealtimePnlFromSnapshot(data);
|
||||
}
|
||||
}).catch(()=>{}).finally(()=>{ priceSnapshotInflight = false; });
|
||||
}).catch(()=>{});
|
||||
}
|
||||
function formatLiveHoldDurationFromMs(openedMs, nowMs){
|
||||
if(openedMs == null || openedMs === "" || !Number.isFinite(Number(openedMs))) return "—";
|
||||
|
||||
@@ -171,7 +171,7 @@ const ORDER_ENTRY_MODEL_CODE_TO_CATEGORY = {{ entry_model_code_to_category | toj
|
||||
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
||||
</script>
|
||||
<script src="/static/instance_settings_prefs.js?v=21"></script>
|
||||
<script src="/static/instance_live.js?v=7"></script>
|
||||
<script src="/static/instance_live.js?v=6"></script>
|
||||
<script src="/static/instance_embed.js?v=31"></script>
|
||||
<script src="/static/instance_mobile_nav.js?v=2"></script>
|
||||
</body>
|
||||
|
||||
@@ -1654,17 +1654,6 @@ function accountSnapshotFundingMissing(data){
|
||||
return !hasFunding && !hasTotal && !hasTrading;
|
||||
}
|
||||
let accountSnapshotRetryCount = 0;
|
||||
let accountSnapshotInflight = false;
|
||||
let priceSnapshotInflight = false;
|
||||
|
||||
function fetchJsonWithTimeout(url, timeoutMs) {
|
||||
const ms = timeoutMs != null ? timeoutMs : 25000;
|
||||
const ac = new AbortController();
|
||||
const timer = setTimeout(function () { ac.abort(); }, ms);
|
||||
return fetch(url, { signal: ac.signal, credentials: "same-origin" })
|
||||
.then(function (r) { return r.json(); })
|
||||
.finally(function () { clearTimeout(timer); });
|
||||
}
|
||||
function applyAccountSnapshot(data){
|
||||
if(!data || typeof data !== "object") return;
|
||||
if(typeof data.show_perp_funds !== "undefined"){
|
||||
@@ -1764,10 +1753,8 @@ function applyAccountSnapshot(data){
|
||||
}
|
||||
function refreshAccountSnapshot(opts){
|
||||
const options = opts || {};
|
||||
if(accountSnapshotInflight && !options.force) return;
|
||||
accountSnapshotInflight = true;
|
||||
const qs = options.force ? "?force=1" : "";
|
||||
fetchJsonWithTimeout("/api/account_snapshot" + qs, 25000).then(data=>{
|
||||
fetch("/api/account_snapshot" + qs).then(r=>r.json()).then(data=>{
|
||||
applyAccountSnapshot(data);
|
||||
if(accountSnapshotFundingMissing(data) && !options.force && accountSnapshotRetryCount < 3){
|
||||
accountSnapshotRetryCount += 1;
|
||||
@@ -1780,7 +1767,7 @@ function refreshAccountSnapshot(opts){
|
||||
accountSnapshotRetryCount += 1;
|
||||
setTimeout(() => refreshAccountSnapshot({ silent: true }), 1200 * accountSnapshotRetryCount);
|
||||
}
|
||||
}).finally(()=>{ accountSnapshotInflight = false; });
|
||||
});
|
||||
}
|
||||
|
||||
{% if ui_open_guard_enabled %}
|
||||
@@ -1938,10 +1925,8 @@ refreshOrderDefaults();
|
||||
refreshPriceSnapshotConditional();
|
||||
setInterval(refreshAccountSnapshot, {{ balance_refresh_seconds * 1000 }});
|
||||
function refreshPriceSnapshotConditional(){
|
||||
if(priceSnapshotInflight) return;
|
||||
priceSnapshotInflight = true;
|
||||
const page = document.body.getAttribute("data-page") || "";
|
||||
fetchJsonWithTimeout("/api/price_snapshot", 25000).then(data=>{
|
||||
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){
|
||||
@@ -2015,7 +2000,7 @@ function refreshPriceSnapshotConditional(){
|
||||
} else if (typeof data.options_unrealized_pnl !== "undefined") {
|
||||
paintRealtimePnlFromSnapshot(data);
|
||||
}
|
||||
}).catch(()=>{}).finally(()=>{ priceSnapshotInflight = false; });
|
||||
}).catch(()=>{});
|
||||
}
|
||||
function formatLiveHoldDurationFromMs(openedMs, nowMs){
|
||||
if(openedMs == null || openedMs === "" || !Number.isFinite(Number(openedMs))) return "—";
|
||||
@@ -2048,7 +2033,6 @@ setInterval(refreshPriceSnapshotConditional, {{ price_refresh_seconds * 1000 }})
|
||||
<script src="/static/records_review_page.js?v=4"></script>
|
||||
<script src="/static/options_expiry_countdown.js?v=1"></script>
|
||||
<script src="/static/instance_dashboard.js?v=5"></script>
|
||||
<script src="/static/instance_live.js?v=7"></script>
|
||||
<script src="/static/account_ledger.js?v=1"></script>
|
||||
<script>
|
||||
window.__INSTANCE_DISPLAY__ = {{ display | tojson }};
|
||||
|
||||
Reference in New Issue
Block a user