Files
ykxmz/_build/polish_ui_and_tests.py
xmz7891 b62ac865ea ykxmz 1.5.0:修复手表端 TLS 证书校验 + MTU 修复网络稳定性
被控端
- 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%)
- 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败)
- 每分钟回头找局域网,自动切回快 400 倍的路径
- 画面心跳帧:静止时省流量,客户端仍知道流是活的
- 锁屏时给出可操作的提示

手表端
- 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException
- 连接错误翻译成人话(证书/时间/解析/超时分别提示)
- 经中转连上后用服务器报的地址刷新已配对记录
- 新增局域网连接页面、服务器延迟检测

服务器端
- 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502)
- 网络调优脚本 net-tune.sh(开机自动应用)
- 管理页:批量删除、网络体检、下载区
- 隧道改 HTTP/2 + 双连接

文档
- 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
2026-10-06 19:01:05 +08:00

127 lines
5.1 KiB
Python
Raw Permalink 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 -*-
"""1. 修一下说明文字的换行宽度
2. 给首次设置窗口的测试加"卡片必须真的显示出来"的断言
第 2 点很关键:
我之前写的 _card() 返回了内层 frame,而内层挂在从未被 pack 的
外层里 —— 卡片完全不显示(窗口只有 199px 高)。
但控件都"存在",walk 能列出来,原来的测试全过。
只有断言"窗口够高" + "子控件是 mapped 的"才能抓到。
"""
from __future__ import annotations
import ast
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
UI = ROOT / "windows" / "lanremote" / "ui.py"
TEST = ROOT / "_tests" / "test_first_run_setup.py"
# ---------------- 1. 换行宽度 ----------------
WRAP_OLD = ''' tk.Label(opt_inner,
text="没放行成功的话,配对码不会提交给服务器,"
"会告诉你怎么处理。",
bg=CARD, fg=MUTED, font=FONT_SMALL, justify="left",
wraplength=340).pack(anchor="w", pady=(6, 0))'''
WRAP_NEW = ''' tk.Label(opt_inner,
text="没放行成功的话,配对码不会提交给服务器,"
"会告诉你怎么处理。",
bg=CARD, fg=MUTED, font=FONT_SMALL, justify="left",
wraplength=396).pack(anchor="w", pady=(6, 0))'''
# ---------------- 2. 测试断言 ----------------
TEST_ANCHOR = ''' check("设置窗口有输入框", found.get("entries", 0) >= 1, str(found))'''
TEST_NEW = ''' # ---- 界面必须真的显示出来 ----
# 踩过的坑:_card() 返回了内层 frame,内层挂在从未 pack 的外层里,
# 于是两张卡片完全不显示,窗口只有 199px 高 —— 但控件都在,
# 光数控件个数查不出来。所以这里断言"够高 + 子控件是 mapped 的"。
metrics = found.get("metrics", {})
print(f" 窗口 {metrics.get('width')}x{metrics.get('height')},"
f"mapped 子控件 {metrics.get('mapped')}/{metrics.get('children')}")
check("设置窗口够高(卡片真的画出来了)",
(metrics.get("height") or 0) >= 400,
f"高度只有 {metrics.get('height')}(<400 说明卡片没显示)")
check("有多个子控件被真正映射(mapped)",
(metrics.get("mapped") or 0) >= 2, metrics)
check("配对码输入框是可见的",
metrics.get("entry_mapped") is True, metrics)
check("设置窗口有输入框", found.get("entries", 0) >= 1, str(found))'''
# 在 ready() 里收集 metrics
READY_OLD = ''' def ready(win):
parts = inspect(win)
found["entries"] = len(parts["entries"])
found["checks"] = len(parts["checks"])
found["buttons"] = len(parts["buttons"])
found["labels"] = parts["labels"]
found["confirmed"] = fill_and_confirm(win, "789113")'''
READY_NEW = ''' def ready(win):
root = win.root
# 多刷几轮,等布局稳定(刚建好时 winfo_width 还可能是初始值)
for _ in range(6):
root.update_idletasks()
root.update()
time.sleep(0.2)
parts = inspect(win)
found["entries"] = len(parts["entries"])
found["checks"] = len(parts["checks"])
found["buttons"] = len(parts["buttons"])
found["labels"] = parts["labels"]
children = root.winfo_children()
found["metrics"] = {
"width": root.winfo_width(),
"height": root.winfo_height(),
"children": len(children),
"mapped": sum(1 for c in children if c.winfo_ismapped()),
"reqheight": root.winfo_reqheight(),
"entry_mapped": any(e.winfo_ismapped() for e in parts["entries"]),
}
found["confirmed"] = fill_and_confirm(win, "789113")'''
def main() -> int:
ok = True
text = UI.read_text(encoding="utf-8")
if WRAP_OLD in text:
text = text.replace(WRAP_OLD, WRAP_NEW, 1)
UI.write_text(text, encoding="utf-8", newline="\n")
print(" ui.py:说明文字换行宽度 340 -> 396")
else:
print(" ui.py:换行宽度锚点没找到(可能已改)")
text = TEST.read_text(encoding="utf-8")
changed = 0
for old, new in ((READY_OLD, READY_NEW), (TEST_ANCHOR, TEST_NEW)):
if old in text:
text = text.replace(old, new, 1)
changed += 1
else:
print(f" [失败] 测试锚点没找到 -> {old.strip()[:60]}")
ok = False
if changed:
TEST.write_text(text, encoding="utf-8", newline="\n")
print(f" 测试:加了 {changed} 处界面可见性断言")
# 确认测试里有 time 导入
if "import time" not in text:
text = text.replace("import tempfile", "import tempfile\nimport time", 1)
TEST.write_text(text, encoding="utf-8", newline="\n")
print(" 测试:补了 import time")
ast.parse(UI.read_text(encoding="utf-8"))
ast.parse(TEST.read_text(encoding="utf-8"))
print(" 语法都 OK")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())