fix(order): hide RR preview in fixed-RR mode and serve shared JS

manual_order_rr_preview.js was not routed from repo static/, so hide logic never ran. Add Flask routes on four exchanges, default hidden in HTML, and toggleSltpMode visibility.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-17 10:59:45 +08:00
parent ca1e25888d
commit b77741ee21
8 changed files with 48 additions and 8 deletions
+8
View File
@@ -8896,6 +8896,7 @@ def api_reviews():
_REPO_STATIC_DIR = os.path.join(os.path.dirname(BASE_DIR), "static") _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") _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") _FORM_SUBMIT_GUARD_JS = os.path.join(_REPO_STATIC_DIR, "form_submit_guard.js")
_MANUAL_ORDER_RR_PREVIEW_JS = os.path.join(_REPO_STATIC_DIR, "manual_order_rr_preview.js")
@app.route("/static/ai_review_render.js") @app.route("/static/ai_review_render.js")
@@ -8912,6 +8913,13 @@ def static_form_submit_guard_js():
return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8") return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/static/manual_order_rr_preview.js")
def static_manual_order_rr_preview_js():
if not os.path.isfile(_MANUAL_ORDER_RR_PREVIEW_JS):
return Response("not found", status=404, mimetype="text/plain; charset=utf-8")
return send_file(_MANUAL_ORDER_RR_PREVIEW_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/export/review_md/<rid>") @app.route("/export/review_md/<rid>")
@login_required @login_required
def export_review_md(rid): def export_review_md(rid):
+4 -2
View File
@@ -396,7 +396,7 @@
<input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none"> <input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none">
<input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none"> <input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none">
<input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none"> <input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none">
<span id="order-rr-preview" class="order-rr-preview" style="font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span> <span id="order-rr-preview" class="order-rr-preview" style="display:none;font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span>
<button type="submit">{{ open_position_button_label }}</button> <button type="submit">{{ open_position_button_label }}</button>
</form> </form>
</div> </div>
@@ -823,7 +823,7 @@
<script src="/static/time_close_ui.js?v=2"></script> <script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script> <script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script> <script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script> <script src="/static/manual_order_rr_preview.js?v=3"></script>
<script> <script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }}; const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }}; const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
@@ -2088,11 +2088,13 @@ function toggleSltpMode(){
const slEl = document.getElementById("order-sl"); const slEl = document.getElementById("order-sl");
const tpEl = document.getElementById("order-tp"); const tpEl = document.getElementById("order-tp");
const fixedRrEl = document.getElementById("order-fixed-rr"); const fixedRrEl = document.getElementById("order-fixed-rr");
const rrPreviewEl = document.getElementById("order-rr-preview");
const slPctEl = document.getElementById("order-sl-pct"); const slPctEl = document.getElementById("order-sl-pct");
const tpPctEl = document.getElementById("order-tp-pct"); const tpPctEl = document.getElementById("order-tp-pct");
if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; } if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; }
const pct = mode === "pct"; const pct = mode === "pct";
const fixed = mode === "fixed_rr"; const fixed = mode === "fixed_rr";
if(rrPreviewEl) rrPreviewEl.style.display = fixed ? "none" : "";
slEl.style.display = pct ? "none" : ""; slEl.style.display = pct ? "none" : "";
tpEl.style.display = (pct || fixed) ? "none" : ""; tpEl.style.display = (pct || fixed) ? "none" : "";
if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none"; if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none";
+8
View File
@@ -8831,6 +8831,7 @@ def api_reviews():
_REPO_STATIC_DIR = os.path.join(os.path.dirname(BASE_DIR), "static") _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") _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") _FORM_SUBMIT_GUARD_JS = os.path.join(_REPO_STATIC_DIR, "form_submit_guard.js")
_MANUAL_ORDER_RR_PREVIEW_JS = os.path.join(_REPO_STATIC_DIR, "manual_order_rr_preview.js")
@app.route("/static/ai_review_render.js") @app.route("/static/ai_review_render.js")
@@ -8847,6 +8848,13 @@ def static_form_submit_guard_js():
return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8") return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/static/manual_order_rr_preview.js")
def static_manual_order_rr_preview_js():
if not os.path.isfile(_MANUAL_ORDER_RR_PREVIEW_JS):
return Response("not found", status=404, mimetype="text/plain; charset=utf-8")
return send_file(_MANUAL_ORDER_RR_PREVIEW_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/export/review_md/<rid>") @app.route("/export/review_md/<rid>")
@login_required @login_required
def export_review_md(rid): def export_review_md(rid):
+4 -2
View File
@@ -376,7 +376,7 @@
<input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none"> <input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none">
<input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none"> <input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none">
<input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none"> <input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none">
<span id="order-rr-preview" class="order-rr-preview" style="font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span> <span id="order-rr-preview" class="order-rr-preview" style="display:none;font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span>
<button type="submit">{{ open_position_button_label }}</button> <button type="submit">{{ open_position_button_label }}</button>
</form> </form>
</div> </div>
@@ -790,7 +790,7 @@
<script src="/static/time_close_ui.js?v=2"></script> <script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script> <script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script> <script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script> <script src="/static/manual_order_rr_preview.js?v=3"></script>
<script> <script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }}; const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }}; const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
@@ -2014,11 +2014,13 @@ function toggleSltpMode(){
const slEl = document.getElementById("order-sl"); const slEl = document.getElementById("order-sl");
const tpEl = document.getElementById("order-tp"); const tpEl = document.getElementById("order-tp");
const fixedRrEl = document.getElementById("order-fixed-rr"); const fixedRrEl = document.getElementById("order-fixed-rr");
const rrPreviewEl = document.getElementById("order-rr-preview");
const slPctEl = document.getElementById("order-sl-pct"); const slPctEl = document.getElementById("order-sl-pct");
const tpPctEl = document.getElementById("order-tp-pct"); const tpPctEl = document.getElementById("order-tp-pct");
if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; } if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; }
const pct = mode === "pct"; const pct = mode === "pct";
const fixed = mode === "fixed_rr"; const fixed = mode === "fixed_rr";
if(rrPreviewEl) rrPreviewEl.style.display = fixed ? "none" : "";
slEl.style.display = pct ? "none" : ""; slEl.style.display = pct ? "none" : "";
tpEl.style.display = (pct || fixed) ? "none" : ""; tpEl.style.display = (pct || fixed) ? "none" : "";
if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none"; if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none";
+8
View File
@@ -8831,6 +8831,7 @@ def api_reviews():
_REPO_STATIC_DIR = os.path.join(os.path.dirname(BASE_DIR), "static") _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") _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") _FORM_SUBMIT_GUARD_JS = os.path.join(_REPO_STATIC_DIR, "form_submit_guard.js")
_MANUAL_ORDER_RR_PREVIEW_JS = os.path.join(_REPO_STATIC_DIR, "manual_order_rr_preview.js")
@app.route("/static/ai_review_render.js") @app.route("/static/ai_review_render.js")
@@ -8847,6 +8848,13 @@ def static_form_submit_guard_js():
return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8") return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/static/manual_order_rr_preview.js")
def static_manual_order_rr_preview_js():
if not os.path.isfile(_MANUAL_ORDER_RR_PREVIEW_JS):
return Response("not found", status=404, mimetype="text/plain; charset=utf-8")
return send_file(_MANUAL_ORDER_RR_PREVIEW_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/export/review_md/<rid>") @app.route("/export/review_md/<rid>")
@login_required @login_required
def export_review_md(rid): def export_review_md(rid):
+4 -2
View File
@@ -376,7 +376,7 @@
<input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none"> <input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none">
<input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none"> <input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none">
<input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none"> <input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none">
<span id="order-rr-preview" class="order-rr-preview" style="font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span> <span id="order-rr-preview" class="order-rr-preview" style="display:none;font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span>
<button type="submit">{{ open_position_button_label }}</button> <button type="submit">{{ open_position_button_label }}</button>
</form> </form>
</div> </div>
@@ -790,7 +790,7 @@
<script src="/static/time_close_ui.js?v=2"></script> <script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script> <script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script> <script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script> <script src="/static/manual_order_rr_preview.js?v=3"></script>
<script> <script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }}; const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }}; const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
@@ -2014,11 +2014,13 @@ function toggleSltpMode(){
const slEl = document.getElementById("order-sl"); const slEl = document.getElementById("order-sl");
const tpEl = document.getElementById("order-tp"); const tpEl = document.getElementById("order-tp");
const fixedRrEl = document.getElementById("order-fixed-rr"); const fixedRrEl = document.getElementById("order-fixed-rr");
const rrPreviewEl = document.getElementById("order-rr-preview");
const slPctEl = document.getElementById("order-sl-pct"); const slPctEl = document.getElementById("order-sl-pct");
const tpPctEl = document.getElementById("order-tp-pct"); const tpPctEl = document.getElementById("order-tp-pct");
if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; } if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; }
const pct = mode === "pct"; const pct = mode === "pct";
const fixed = mode === "fixed_rr"; const fixed = mode === "fixed_rr";
if(rrPreviewEl) rrPreviewEl.style.display = fixed ? "none" : "";
slEl.style.display = pct ? "none" : ""; slEl.style.display = pct ? "none" : "";
tpEl.style.display = (pct || fixed) ? "none" : ""; tpEl.style.display = (pct || fixed) ? "none" : "";
if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none"; if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none";
+8
View File
@@ -8378,6 +8378,7 @@ def api_reviews():
_REPO_STATIC_DIR = os.path.join(os.path.dirname(BASE_DIR), "static") _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") _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") _FORM_SUBMIT_GUARD_JS = os.path.join(_REPO_STATIC_DIR, "form_submit_guard.js")
_MANUAL_ORDER_RR_PREVIEW_JS = os.path.join(_REPO_STATIC_DIR, "manual_order_rr_preview.js")
@app.route("/static/ai_review_render.js") @app.route("/static/ai_review_render.js")
@@ -8394,6 +8395,13 @@ def static_form_submit_guard_js():
return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8") return send_file(_FORM_SUBMIT_GUARD_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/static/manual_order_rr_preview.js")
def static_manual_order_rr_preview_js():
if not os.path.isfile(_MANUAL_ORDER_RR_PREVIEW_JS):
return Response("not found", status=404, mimetype="text/plain; charset=utf-8")
return send_file(_MANUAL_ORDER_RR_PREVIEW_JS, mimetype="application/javascript; charset=utf-8")
@app.route("/export/review_md/<rid>") @app.route("/export/review_md/<rid>")
@login_required @login_required
def export_review_md(rid): def export_review_md(rid):
+4 -2
View File
@@ -405,7 +405,7 @@
<input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none"> <input id="order-tp" name="tgt" step="any" placeholder="止盈价格" style="display:none">
<input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none"> <input id="order-sl-pct" name="sl_pct" type="number" min="0.01" step="0.01" placeholder="止损%" style="display:none">
<input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none"> <input id="order-tp-pct" name="tp_pct" type="number" min="0.01" step="0.01" placeholder="止盈%" style="display:none">
<span id="order-rr-preview" class="order-rr-preview" style="font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span> <span id="order-rr-preview" class="order-rr-preview" style="display:none;font-size:.82rem;color:#8fc8ff;align-self:center">预估盈亏比:—</span>
<button type="submit">{{ open_position_button_label }}</button> <button type="submit">{{ open_position_button_label }}</button>
</form> </form>
</div> </div>
@@ -819,7 +819,7 @@
<script src="/static/time_close_ui.js?v=2"></script> <script src="/static/time_close_ui.js?v=2"></script>
<script src="/static/ai_review_render.js?v=2"></script> <script src="/static/ai_review_render.js?v=2"></script>
<script src="/static/form_submit_guard.js?v=2"></script> <script src="/static/form_submit_guard.js?v=2"></script>
<script src="/static/manual_order_rr_preview.js?v=2"></script> <script src="/static/manual_order_rr_preview.js?v=3"></script>
<script> <script>
const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }}; const JOURNAL_ENTRY_REASON_OPTIONS = {{ entry_reason_options | tojson }};
const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }}; const JOURNAL_ENTRY_REASON_OTHER = {{ entry_reason_other_value | tojson }};
@@ -2067,11 +2067,13 @@ function toggleSltpMode(){
const slEl = document.getElementById("order-sl"); const slEl = document.getElementById("order-sl");
const tpEl = document.getElementById("order-tp"); const tpEl = document.getElementById("order-tp");
const fixedRrEl = document.getElementById("order-fixed-rr"); const fixedRrEl = document.getElementById("order-fixed-rr");
const rrPreviewEl = document.getElementById("order-rr-preview");
const slPctEl = document.getElementById("order-sl-pct"); const slPctEl = document.getElementById("order-sl-pct");
const tpPctEl = document.getElementById("order-tp-pct"); const tpPctEl = document.getElementById("order-tp-pct");
if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; } if(!slEl || !tpEl || !slPctEl || !tpPctEl){ return; }
const pct = mode === "pct"; const pct = mode === "pct";
const fixed = mode === "fixed_rr"; const fixed = mode === "fixed_rr";
if(rrPreviewEl) rrPreviewEl.style.display = fixed ? "none" : "";
slEl.style.display = pct ? "none" : ""; slEl.style.display = pct ? "none" : "";
tpEl.style.display = (pct || fixed) ? "none" : ""; tpEl.style.display = (pct || fixed) ? "none" : "";
if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none"; if(fixedRrEl) fixedRrEl.style.display = fixed ? "" : "none";