Force-refresh header balances after transfers and balance SSE events.

Invalidate balance caches on mutation, push SSE balance tick, and bypass 60s cache when refreshing funds.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-12 09:03:15 +08:00
parent bb53beb22d
commit 5eb9b9f5c5
10 changed files with 63 additions and 13 deletions
+11 -3
View File
@@ -9,6 +9,14 @@
return r.json();
}
function refreshFundsAfterMutation() {
if (typeof refreshAccountSnapshot !== "function") return;
refreshAccountSnapshot({ force: true });
setTimeout(function () {
refreshAccountSnapshot({ force: true, silent: true });
}, 1500);
}
function setMsg(id, text, isErr) {
const el = document.getElementById(id);
if (!el) return;
@@ -50,7 +58,7 @@
}),
});
setMsg("opt-set-swap-msg", d.ok ? "兑换单已提交" : (d.msg || "失败"), !d.ok);
if (d.ok && typeof refreshAccountSnapshot === "function") refreshAccountSnapshot();
if (d.ok && typeof refreshAccountSnapshot === "function") refreshFundsAfterMutation();
}
const swapBtn = document.getElementById("opt-set-swap-btn");
@@ -96,7 +104,7 @@
}),
});
setMsg("opt-set-int-msg", d.ok ? "划转成功" : (d.msg || "失败"), !d.ok);
if (d.ok && typeof refreshAccountSnapshot === "function") refreshAccountSnapshot();
if (d.ok && typeof refreshAccountSnapshot === "function") refreshFundsAfterMutation();
}
const intBtn = document.getElementById("opt-set-int-btn");
@@ -143,7 +151,7 @@
}),
});
setMsg("opt-set-cross-msg", d.ok ? "划转成功" : (d.msg || "失败"), !d.ok);
if (d.ok && typeof refreshAccountSnapshot === "function") refreshAccountSnapshot();
if (d.ok && typeof refreshAccountSnapshot === "function") refreshFundsAfterMutation();
}
const crossBtn = document.getElementById("opt-set-cross-btn");