fix: CTP登录冷却持久化到数据库,取消页面自动连并刷新JS缓存

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 17:01:36 +08:00
parent 9c8b92d2bd
commit 259d9e812d
4 changed files with 80 additions and 17 deletions
+12 -3
View File
@@ -205,7 +205,9 @@ def require_nav(key: str):
@app.context_processor
def inject_globals():
return {"nav_items": get_nav_items(get_setting)}
trade_js = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static", "js", "trade.js")
asset_v = str(int(os.path.getmtime(trade_js))) if os.path.isfile(trade_js) else "0"
return {"nav_items": get_nav_items(get_setting), "asset_v": asset_v}
def _trading_mode() -> str:
@@ -1714,9 +1716,16 @@ def settings():
save_ctp_settings_from_form(request.form, set_setting)
try:
from vnpy_bridge import get_bridge
from vnpy_bridge import get_bridge, _persist_last_error
get_bridge().mark_disconnected()
b = get_bridge()
b.mark_disconnected()
if (request.form.get("simnow_password") or "").strip() or (
request.form.get("ctp_live_password") or ""
).strip():
b._clear_login_cooldown()
b._last_error = ""
_persist_last_error("")
except Exception:
pass
flash("CTP 配置已保存,请在持仓监控页重连 CTP")