Add global autofill guard for hub, env, and transfer inputs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-20 10:18:56 +08:00
parent 00d76ba20f
commit 4a3e6a2a1d
15 changed files with 221 additions and 38 deletions
+11
View File
@@ -777,6 +777,17 @@ _ACCOUNT_RISK_BADGE_CSS = _REPO_STATIC / "account_risk_badge.css"
_ACCOUNT_RISK_BADGE_JS = _REPO_STATIC / "account_risk_badge.js"
_OPTIONS_EXPIRY_COUNTDOWN_JS = _REPO_STATIC / "options_expiry_countdown.js"
_OPTIONS_POSITION_CARDS_JS = _REPO_STATIC / "options_position_cards.js"
_AUTOFILL_GUARD_JS = _REPO_STATIC / "autofill_guard.js"
@app.get("/assets/autofill_guard.js")
def hub_autofill_guard_js():
if not _AUTOFILL_GUARD_JS.is_file():
raise HTTPException(status_code=404, detail="autofill_guard.js not found")
return FileResponse(
str(_AUTOFILL_GUARD_JS),
media_type="application/javascript; charset=utf-8",
)
@app.get("/assets/account_risk_badge.css")
+4 -4
View File
@@ -5009,12 +5009,12 @@
<div class="settings-card-head">
<label class="chk-label"><input type="checkbox" class="ex-enabled" ${ex.enabled ? "checked" : ""} ${ex.env_disabled ? "disabled" : ""}/> 启用</label>
${envOff}
<input class="ex-name" value="${esc(ex.name || "")}" placeholder="显示名称" />
<input class="ex-name" value="${esc(ex.name || "")}" placeholder="显示名称" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</div>
<div class="settings-grid">
<div class="field"><label>Flask URL</label><input class="ex-flask" value="${esc(ex.flask_url || "")}" /></div>
<div class="field"><label>Agent URL</label><input class="ex-agent" value="${esc(ex.agent_url || "")}" /></div>
<div class="field field-wide"><label>复盘链接(可空)</label><input class="ex-review" value="${esc(ex.review_url || "")}" placeholder="留空则自动生成 /records" /></div>
<div class="field"><label>Flask URL</label><input class="ex-flask" value="${esc(ex.flask_url || "")}" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></div>
<div class="field"><label>Agent URL</label><input class="ex-agent" value="${esc(ex.agent_url || "")}" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></div>
<div class="field field-wide"><label>复盘链接(可空)</label><input class="ex-review" value="${esc(ex.review_url || "")}" placeholder="留空则自动生成 /records" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></div>
</div>
<div class="cap-chips">
<label><input type="checkbox" class="cap-key" ${caps.includes("key") ? "checked" : ""}/> 监控关键位</label>
+10 -9
View File
@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<script src="/assets/theme.js?v=20260604-hub-inst-theme"></script>
<script src="/assets/autofill_guard.js?v=1"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" />
<meta name="theme-color" content="#0b0e18" />
<meta name="apple-mobile-web-app-title" content="中控" />
@@ -113,15 +114,15 @@
</label>
<label class="plan-field">
<span>目标位</span>
<input id="plan-create-target" type="text" placeholder="如 68500" />
<input id="plan-create-target" type="text" placeholder="如 68500" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="plan-field">
<span>当前区间</span>
<input id="plan-create-range" type="text" placeholder="如 67000-68000" />
<input id="plan-create-range" type="text" placeholder="如 67000-68000" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
</label>
<label class="plan-field plan-field-full">
<span>备注</span>
<textarea id="plan-create-note" rows="2" placeholder="计划说明…"></textarea>
<textarea id="plan-create-note" rows="2" placeholder="计划说明…" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other"></textarea>
</label>
</div>
<button type="submit" class="primary plan-submit-btn">保存并进入进行中</button>
@@ -1077,10 +1078,10 @@
</div>
<p class="settings-display-hint">修改中控网页登录账号密码,写入 <code>manual_trading_hub/.env</code> 后需重启中控生效.当前用户:<code id="hub-pwd-current-user"></code></p>
<div class="settings-grid hub-password-grid">
<div class="field"><label>当前密码</label><input type="password" id="hub-pwd-old" autocomplete="current-password"></div>
<div class="field"><label>新用户名(可选)</label><input type="text" id="hub-pwd-new-username" autocomplete="username"></div>
<div class="field"><label>新密码</label><input type="password" id="hub-pwd-new" autocomplete="new-password"></div>
<div class="field"><label>确认新密码</label><input type="password" id="hub-pwd-confirm" autocomplete="new-password"></div>
<div class="field" data-password-settings="1"><label>当前密码</label><input type="password" id="hub-pwd-old" autocomplete="current-password"></div>
<div class="field" data-password-settings="1"><label>新用户名(可选)</label><input type="text" id="hub-pwd-new-username" autocomplete="username"></div>
<div class="field" data-password-settings="1"><label>新密码</label><input type="password" id="hub-pwd-new" autocomplete="new-password"></div>
<div class="field" data-password-settings="1"><label>确认新密码</label><input type="password" id="hub-pwd-confirm" autocomplete="new-password"></div>
</div>
<div class="hub-settings-tab-actions">
<button type="button" class="primary" id="hub-pwd-save-btn">保存密码</button>
@@ -1378,7 +1379,7 @@
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
<script src="/assets/chart_draw.js?v=20260609-market-day-split"></script>
<script src="/assets/chart.js?v=20260715-fs-landscape"></script>
<script src="/assets/plan.js?v=20260614-plan-refresh"></script>
<script src="/assets/plan.js?v=20260720-autofill"></script>
<script src="/assets/calculator.js?v=20260715-calc-tabs"></script>
<script src="/assets/trade_stats_calendar.js?v=3"></script>
<script src="/assets/archive.js?v=20260717-archive-cal-chart"></script>
@@ -1393,6 +1394,6 @@
<script src="/assets/options_expiry_countdown.js?v=1"></script>
<script src="/assets/options_position_cards.js?v=2"></script>
<script src="/assets/backup.js?v=1"></script>
<script src="/assets/app.js?v=20260717-quotes-feed"></script>
<script src="/assets/app.js?v=20260720-autofill"></script>
</body>
</html>
+3 -3
View File
@@ -481,7 +481,7 @@
"</select></label>" +
'<label class="plan-field"><span>币种</span><input name="symbol" type="text" value="' +
esc(p.symbol) +
'" required /></label>' +
'" required autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></label>' +
'<label class="plan-field"><span>类型</span><select name="plan_type" required>' +
opts(meta.plan_types, "plan_type", "value", "label") +
"</select></label>" +
@@ -496,10 +496,10 @@
"</span></label>" +
'<label class="plan-field"><span>目标位</span><input name="target_level" type="text" value="' +
esc(p.target_level || "") +
'" /></label>' +
'" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></label>' +
'<label class="plan-field"><span>当前区间</span><input name="current_range" type="text" value="' +
esc(p.current_range || "") +
'" /></label>' +
'" autocomplete="off" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></label>' +
'<label class="plan-field plan-field-full"><span>入场方案</span><select name="entry_scheme" required>' +
opts(meta.entry_schemes, "entry_scheme", "value", "label") +
"</select></label>" +