From fe068709ac98562179dfaf182b8422831b6782a0 Mon Sep 17 00:00:00 2001 From: dekun Date: Wed, 27 May 2026 22:35:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crypto_monitor_binance/app.py | 23 ++++++- crypto_monitor_binance/templates/index.html | 42 ++++++++++--- crypto_monitor_gate/app.py | 24 +++++++- crypto_monitor_gate/templates/index.html | 42 ++++++++++--- crypto_monitor_gate_bot/app.py | 25 +++++++- crypto_monitor_gate_bot/templates/index.html | 31 +++++++++- crypto_monitor_okx/app.py | 23 ++++++- crypto_monitor_okx/templates/index.html | 38 ++++++++++-- form_submit_lib.py | 51 +++++++++++++++ static/form_submit_guard.js | 65 ++++++++++++++++++++ 10 files changed, 337 insertions(+), 27 deletions(-) create mode 100644 form_submit_lib.py create mode 100644 static/form_submit_guard.js diff --git a/crypto_monitor_binance/app.py b/crypto_monitor_binance/app.py index c8a5b4c..4568f3d 100644 --- a/crypto_monitor_binance/app.py +++ b/crypto_monitor_binance/app.py @@ -36,6 +36,7 @@ if _REPO_ROOT not in sys.path: sys.path.insert(0, _REPO_ROOT) from ai_client import ai_generate, ai_review, ai_short_advice from ai_review_lib import build_journal_ai_chart_path, collect_images_for_ai_review +from form_submit_lib import check_duplicate_submit, submit_scope_add_key, submit_scope_add_order from fib_key_monitor_lib import ( FIB_KEY_MONITOR_TYPES, calc_fib_plan, @@ -6476,6 +6477,12 @@ def add_key(): return redirect("/key_monitor") mt = (d.get("type") or "").strip() direction_sel = (d.get("direction") or "").strip().lower() + dup_msg = check_duplicate_submit( + session, submit_scope_add_key(symbol, mt, direction_sel or "watch") + ) + if dup_msg: + flash(dup_msg) + return redirect("/key_monitor") if mt in KEY_MONITOR_RS_TYPES: direction_sel = KEY_DIRECTION_WATCH elif direction_sel not in ("long", "short"): @@ -6622,6 +6629,11 @@ def add_order(): conn.close() flash("symbol 不能为空") return redirect("/") + dup_msg = check_duplicate_submit(session, submit_scope_add_order(symbol, direction)) + if dup_msg: + conn.close() + flash(dup_msg) + return redirect("/trade") ok, reason = precheck_risk(conn, symbol, direction) if not ok: if "已达最大持仓数" in reason: @@ -7517,7 +7529,9 @@ def api_reviews(): return jsonify([row_to_dict(r) for r in rows]) -_AI_REVIEW_RENDER_JS = os.path.join(os.path.dirname(BASE_DIR), "static", "ai_review_render.js") +_REPO_STATIC_DIR = os.path.join(os.path.dirname(BASE_DIR), "static") +_AI_REVIEW_RENDER_JS = os.path.join(_REPO_STATIC_DIR, "ai_review_render.js") +_FORM_SUBMIT_GUARD_JS = os.path.join(_REPO_STATIC_DIR, "form_submit_guard.js") @app.route("/static/ai_review_render.js") @@ -7527,6 +7541,13 @@ def static_ai_review_render_js(): return send_file(_AI_REVIEW_RENDER_JS, mimetype="application/javascript; charset=utf-8") +@app.route("/static/form_submit_guard.js") +def static_form_submit_guard_js(): + if not os.path.isfile(_FORM_SUBMIT_GUARD_JS): + return Response("not found", status=404, mimetype="text/plain; charset=utf-8") + return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8") + + @app.route("/export/review_md/") @login_required def export_review_md(rid): diff --git a/crypto_monitor_binance/templates/index.html b/crypto_monitor_binance/templates/index.html index 3396047..e6df2eb 100644 --- a/crypto_monitor_binance/templates/index.html +++ b/crypto_monitor_binance/templates/index.html @@ -61,6 +61,8 @@ .pnl-profit{color:#4cd97f;font-weight:600} .pnl-loss{color:#ff6666;font-weight:600} .flash{padding:10px;background:#1e2533;color:#4cc2ff;border-radius:10px;margin-bottom:12px;text-align:center;border:1px solid #304164} + form.is-form-submitting{opacity:.88;pointer-events:none} + form.is-form-submitting button[type=submit],form.is-form-submitting input[type=submit]{cursor:wait} .ai-result{background:#1a1a29;border:1px solid #2e2e45;border-radius:8px;padding:10px;white-space:pre-wrap;max-height:220px;overflow:auto;font-size:.84rem;line-height:1.45;margin-top:8px} .ai-result.ai-result-md,.detail-modal .panel-body.md-review{white-space:normal} .ai-result-md p,.detail-modal .panel-body.md-review p{margin:6px 0;color:#dde2ff} @@ -862,6 +864,7 @@ + + + +