fix(okx): cache options balances and stop SSE from hammering exchange API

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 11:15:06 +08:00
parent 799a4d6b8b
commit 2ad9e049f3
6 changed files with 82 additions and 37 deletions
+8 -5
View File
@@ -206,11 +206,14 @@
function preloadAllTabs() {
const tabs = Object.keys(TAB_PATH);
const current = getTab();
const heavyLast = new Set(["options", "records", "stats"]);
const ordered = tabs.filter((t) => t !== current && !heavyLast.has(t))
.concat(tabs.filter((t) => heavyLast.has(t) && t !== current));
let idx = 0;
function step() {
if (idx >= tabs.length) return;
const tab = tabs[idx++];
if (tab === current || tabPanes.has(tab)) {
if (idx >= ordered.length) return;
const tab = ordered[idx++];
if (tabPanes.has(tab)) {
step();
return;
}
@@ -220,11 +223,11 @@
})
.catch(() => {})
.finally(() => {
setTimeout(step, 120);
setTimeout(step, heavyLast.has(tab) ? 400 : 180);
});
}
const ric = global.requestIdleCallback || function (fn) {
setTimeout(fn, 1200);
setTimeout(fn, 2000);
};
ric(step);
}