Normalize fullwidth punctuation to ASCII across codebase.
Add scripts/normalize_ambiguous_unicode.py; fix corrupted patch_instance_theme_templates.py. Preserves curly quotes in string literals; removes Git homoglyph warnings on .env.example. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""从 binance index.html 生成三所共用的 lib/instance/templates/index.html。"""
|
||||
"""从 binance index.html 生成三所共用的 lib/instance/templates/index.html."""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
@@ -12,7 +12,7 @@ OUT = ROOT / "lib" / "instance" / "templates" / "index.html"
|
||||
TRANSFER_BLOCK = """ <details class="tip-collapse transfer-rule-collapse">
|
||||
<summary class="tip-collapse-summary">划转规则说明</summary>
|
||||
<div class="tip-collapse-body rule-tip">
|
||||
划转:自动划转 {{ '开启' if auto_transfer_enabled else '关闭' }}(每天<strong>北京时间 {{ auto_transfer_bj_hour }}:00</strong>起该整点小时内尝试;账簿按 <strong>UTC 自然日</strong>去重;将 {{ auto_transfer_to }} 调整至 {{ auto_transfer_amount }}U:不足从 {{ auto_transfer_from }} 划入、超出划回 {{ auto_transfer_from }};<strong>持仓中不划转</strong>并微信通知)
|
||||
划转:自动划转 {{ '开启' if auto_transfer_enabled else '关闭' }}(每天<strong>北京时间 {{ auto_transfer_bj_hour }}:00</strong>起该整点小时内尝试;账簿按 <strong>UTC 自然日</strong>去重;将 {{ auto_transfer_to }} 调整至 {{ auto_transfer_amount }}U:不足从 {{ auto_transfer_from }} 划入,超出划回 {{ auto_transfer_from }};<strong>持仓中不划转</strong>并微信通知)
|
||||
</div>
|
||||
</details>
|
||||
<form action="/manual_transfer" method="post" class="form-row">
|
||||
@@ -44,9 +44,9 @@ def main() -> None:
|
||||
flags=re.DOTALL,
|
||||
)
|
||||
|
||||
# 顶栏:划转 + 可选 open guard
|
||||
# 顶栏:划转 + 可选 open guard
|
||||
text = text.replace(
|
||||
' <div class="rule-tip">实时价格更新:<span id="price-last-updated">--</span>(北京时间 UTC+8)</div>\n',
|
||||
' <div class="rule-tip">实时价格更新:<span id="price-last-updated">--</span>(北京时间 UTC+8)</div>\n',
|
||||
" {% include 'instance_top_bar.html' %}\n",
|
||||
)
|
||||
|
||||
@@ -56,7 +56,7 @@ def main() -> None:
|
||||
"{% include order_rule_tips_tpl %}",
|
||||
)
|
||||
|
||||
# 下单面板内划转块移除(已上移到顶栏)
|
||||
# 下单面板内划转块移除(已上移到顶栏)
|
||||
if TRANSFER_BLOCK in text:
|
||||
text = text.replace(TRANSFER_BLOCK, "", 1)
|
||||
|
||||
@@ -64,7 +64,7 @@ def main() -> None:
|
||||
orphan_block = """ {% if not order and orphan_live_positions %}
|
||||
{% set o = orphan_live_positions[0] %}
|
||||
<div id="orphan-position-recover" class="orphan-recover-banner" style="display:block;margin-bottom:10px;padding:10px 12px;background:#2a2210;border:1px solid #6b5420;border-radius:6px;font-size:.9rem;color:#e8d5a8">
|
||||
<strong>检测到交易所仍有持仓,本地无对应监控单</strong>
|
||||
<strong>检测到交易所仍有持仓,本地无对应监控单</strong>
|
||||
<span style="margin-left:8px">{{ o.exchange_symbol or o.symbol }} · {{ '多' if o.direction == 'long' else '空' }}</span>
|
||||
<form action="/recover_orphan_order" method="post" style="display:inline;margin-left:12px">
|
||||
<input type="hidden" name="symbol" value="{{ o.symbol }}">
|
||||
@@ -78,7 +78,7 @@ def main() -> None:
|
||||
wrapped = "{% if ui_orphan_recovery_enabled %}\n" + orphan_block + "\n {% endif %}"
|
||||
text = text.replace(orphan_block, wrapped, 1)
|
||||
|
||||
# refreshAccountSnapshot:采用 OKX 版 open_guard 逻辑
|
||||
# refreshAccountSnapshot:采用 OKX 版 open_guard 逻辑
|
||||
old_can_trade = """ let canTradeText = "可开仓";
|
||||
if (!data.can_trade) {
|
||||
const parts = [];
|
||||
@@ -93,7 +93,7 @@ def main() -> None:
|
||||
if (hard > 0 && !Number.isNaN(opens) && opens >= hard) parts.push(`本交易日开仓 ${opens}/${hard} 已达上限`);
|
||||
if (!parts.length) parts.push(`未到北京时间 {{ reset_hour }}:00`);
|
||||
else parts.push(`或未到北京时间 {{ reset_hour }}:00`);
|
||||
canTradeText = `不可开仓(${parts.join(";")})`;
|
||||
canTradeText = `不可开仓(${parts.join(";")})`;
|
||||
}"""
|
||||
new_can_trade = """ let canTradeText = "可开仓";
|
||||
if(!data.can_trade){
|
||||
@@ -106,7 +106,7 @@ def main() -> None:
|
||||
const opens = Number(data.opens_today);
|
||||
if (hard > 0 && !Number.isNaN(opens) && opens >= hard) parts.push(`本交易日开仓 ${opens}/${hard} 已达上限`);
|
||||
if(data.open_guard_blocks_now) parts.push(`未到北京时间 ${data.reset_hour||{{ reset_hour }}}:00`);
|
||||
canTradeText = parts.length ? `不可开仓(${parts.join(";")})` : "不可开仓";
|
||||
canTradeText = parts.length ? `不可开仓(${parts.join(";")})` : "不可开仓";
|
||||
}"""
|
||||
text = text.replace(old_can_trade, new_can_trade, 1)
|
||||
|
||||
@@ -118,11 +118,11 @@ def main() -> None:
|
||||
}
|
||||
if(guardStatus && typeof data.open_guard_enabled !== "undefined"){
|
||||
guardStatus.innerText = data.open_guard_enabled
|
||||
? `已限制:${resetH}:00 前不可开仓`
|
||||
: `已放开:${resetH}:00 前允许开仓`;
|
||||
? `已限制:${resetH}:00 前不可开仓`
|
||||
: `已放开:${resetH}:00 前允许开仓`;
|
||||
}"""
|
||||
insert_after = """ if(tip){
|
||||
tip.innerText = `规则:最多 ${data.max_active_positions || {{ max_active_positions }}} 仓;BTC {{ btc_leverage }}x / 山寨 {{ alt_leverage }}x;${openCntTxt ? openCntTxt + ";" : ""}${canTradeText}${avail};人工开仓盈亏比不得低于 {{ manual_min_planned_rr }}:1`;
|
||||
tip.innerText = `规则:最多 ${data.max_active_positions || {{ max_active_positions }}} 仓;BTC {{ btc_leverage }}x / 山寨 {{ alt_leverage }}x;${openCntTxt ? openCntTxt + ";" : ""}${canTradeText}${avail};人工开仓盈亏比不得低于 {{ manual_min_planned_rr }}:1`;
|
||||
}
|
||||
}).catch(()=>{});"""
|
||||
if guard_sync not in text:
|
||||
@@ -158,7 +158,7 @@ if(allowOpenBeforeResetEl){
|
||||
orphan_fn_guard,
|
||||
)
|
||||
|
||||
header = "{# 三所共用 standalone 主页 — 由 scripts/build_unified_index.py 生成,勿手改三所副本 #}\n"
|
||||
header = "{# 三所共用 standalone 主页 — 由 scripts/build_unified_index.py 生成,勿手改三所副本 #}\n"
|
||||
if not text.startswith("{# 三所共用"):
|
||||
text = header + text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user