Files
ykxmz/_build/fix_admin_button.py
T
xmz7891 b705216e4a ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞
- 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀?
鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException
- 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴?
鏈嶅姟鍣ㄧ
- 鏀寔 chunked 璇锋眰浣擄紙淇瘡 16 绉掍竴娆$殑杩炴帴閿欎贡涓庡ぇ闈㈢Н 502锛?- 缃戠粶璋冧紭鑴氭湰 net-tune.sh锛堝紑鏈鸿嚜鍔ㄥ簲鐢級
- 绠$悊椤碉細鎵归噺鍒犻櫎銆佺綉缁滀綋妫€銆佷笅杞藉尯
- 闅ч亾鏀?HTTP/2 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
2026-10-06 19:01:05 +08:00

119 lines
4.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""修管理页删除按钮的幽灵按键。
根因:
生成的 JS 里,字符串字面量中间出现了**真实换行**:
if (!confirm('删除设备「' + name + '」(配对码 ' + code + ')?
'
原因是 Python 源码里写的是普通(非 raw)字符串里的 \\n,
于是变成了真的换行符。对 HTML 来说没问题,
但 JS 里字符串不能跨行 -> SyntaxError -> 整段 script 不执行
-> 所有 onclick 都没绑上 -> 按钮点了没反应("幽灵按键")。
修法:
把 JS 字符串里的换行写成 \\\\n(两个字符:反斜杠 + n),
这样生成的 JS 才是合法的 '...\\n...'。
"""
from __future__ import annotations
import sys
from pathlib import Path
RELAY = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\relay"
r"\relay.py")
# 这几行里的 \n 都在 JS 字符串字面量内部,必须变成 \\n(字面量)
FIXES = [
# 删除确认框
(""" if (!confirm('删除设备「' + name + '」(配对码 ' + code + ')?\\n\\n'""",
""" if (!confirm('删除设备「' + name + '」(配对码 ' + code + ')?\\\\n\\\\n'"""),
(""" + '这会:\\n 1. 断开它现在的手表连接\\n'""",
""" + '这会:\\\\n 1. 断开它现在的手表连接\\\\n'"""),
(""" + ' 2. 从服务器删掉这台设备\\n'""",
""" + ' 2. 从服务器删掉这台设备\\\\n'"""),
(""" + ' 3. 清掉它的配对码绑定')) return;""",
""" + ' 3. 清掉它的配对码绑定')) return;"""),
# 删除成功提示
(""" alert('已删除「' + (j.name || name) + '」\\n'""",
""" alert('已删除「' + (j.name || name) + '」\\\\n'"""),
# 清场确认框
(""" if (!confirm('删除**全部**设备(连同所有配对码)?\\n\\n清场用,删完所有电脑都要重新设码。'))""",
""" if (!confirm('删除**全部**设备(连同所有配对码)?\\\\n\\\\n清场用,删完所有电脑都要重新设码。'))"""),
]
def main() -> int:
text = RELAY.read_text(encoding="utf-8")
ok = True
changed = 0
for old, new in FIXES:
if old == new:
continue
if old in text:
text = text.replace(old, new, 1)
changed += 1
else:
# 可能已经修过(\\n 已经是两个反斜杠)
print(f" [跳过] 锚点没找到(可能已修): {old.strip()[:56]}")
if changed:
RELAY.write_text(text, encoding="utf-8", newline="\n")
print(f" 改了 {changed} 处")
else:
print(" 没有需要改的(可能已修)")
import ast
try:
ast.parse(text)
print(" relay.py 语法 OK")
except SyntaxError as exc:
print(f" relay.py 语法错误: {exc}")
ok = False
# ---------------- 复核:生成的 JS 里不该有跨行字符串 ----------------
print()
print(" 复核:模拟生成 JS,检查有没有字符串跨行")
# 把 f-string 里的 {{ }} 还原成 { },再看每行
import re
start = text.find("<script>")
end = text.find("</script>", start)
if start < 0:
print(" [失败] 找不到 script 段")
return 1
block = text[start:end]
# 粗还原:{{ -> {, }} -> }
rendered = block.replace("{{", "{").replace("}}", "}")
# 把 \\n 变成真正的换行(模拟 Python 的转义)
rendered = rendered.replace("\\\\n", "\n")
bad = []
inside = False
quote = ""
for lineno, line in enumerate(rendered.splitlines(), 1):
stripped = line.strip()
if inside:
# 上一行开了字符串但没闭合
if quote in stripped:
inside = False
else:
bad.append(lineno)
continue
# 统计这一行的单引号(简单判断,忽略转义的)
count = len(re.findall(r"(?<!\\)'", line))
if count % 2 == 1 and "//" not in stripped:
inside = True
quote = "'"
if bad:
print(f" [失败] 这些行是跨行字符串的续行:{bad}")
ok = False
else:
print(" ✓ JS 里没有跨行字符串了")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())