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
+5
View File
@@ -100,6 +100,11 @@ class InstanceLivePush:
instance_live_push = InstanceLivePush()
def notify_instance_balance_changed() -> int:
"""划转/兑换后通知 embed 壳拉最新资金快照."""
return instance_live_push.tick("balance")
def register_instance_live_routes(app: Flask, login_required: Callable) -> None:
instance_live_push.start()
@@ -1166,11 +1166,11 @@ function applyAccountSnapshot(data){
}
if(data.options_funding_usdc != null || data.options_funding_usdt != null){
const optFunding = formatOptionsFundingLabel(data.options_funding_usdc, data.options_funding_usdt);
if(optFunding !== "—") setFundsFieldText("options-funding-usdc", optFunding);
setFundsFieldText("options-funding-usdc", optFunding);
}
if(data.options_trading_usdc != null || data.options_trading_usdt != null){
const optTrading = formatOptionsFundingLabel(data.options_trading_usdc, data.options_trading_usdt);
if(optTrading !== "—") setFundsFieldText("options-trading-usdc", optTrading);
setFundsFieldText("options-trading-usdc", optTrading);
}
if(typeof data.unrealized_pnl !== "undefined"){
updateRealtimePnl(data.unrealized_pnl);
+1 -1
View File
@@ -106,7 +106,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=12"></script>
<script src="/static/instance_live.js?v=4"></script>
<script src="/static/instance_live.js?v=5"></script>
<script src="/static/instance_embed.js?v=23"></script>
</body>
</html>
+2 -2
View File
@@ -1811,11 +1811,11 @@ function applyAccountSnapshot(data){
}
if(data.options_funding_usdc != null || data.options_funding_usdt != null){
const optFunding = formatOptionsFundingLabel(data.options_funding_usdc, data.options_funding_usdt);
if(optFunding !== "—") setFundsFieldText("options-funding-usdc", optFunding);
setFundsFieldText("options-funding-usdc", optFunding);
}
if(data.options_trading_usdc != null || data.options_trading_usdt != null){
const optTrading = formatOptionsFundingLabel(data.options_trading_usdc, data.options_trading_usdt);
if(optTrading !== "—") setFundsFieldText("options-trading-usdc", optTrading);
setFundsFieldText("options-trading-usdc", optTrading);
}
if(typeof data.unrealized_pnl !== "undefined"){
updateRealtimePnl(data.unrealized_pnl);