1.7.1:修白屏 + 配对 + 官网管理页分家

手表端
- 修「连上后一片白屏」:initTabs() 从来没被调用过,
  导致 tabDefs 为 null、selectTab 直接 return,
  标签栏里只剩一个孤立的滑动指示器
- 应用名改成 ykxmz

被控端
- 修「设备已关闭新设备配对」:配对码本身就是密钥,
  拿着正确的码就该放行。老逻辑"首台配对后自动关窗"会把
  手表重装的人永久挡在外面
- 应用名改成 ykxmz

服务器端
- / 改成官网(公开,简洁介绍 + 下载)
- /zhingzhuanzhan 中转站管理(要登录),/admin 自动跳转
- 管理账号 xmz7891,可改
- 官网 / 登录页 / 管理页都加上 favicon
This commit is contained in:
xmz7891
2026-10-06 23:08:07 +08:00
parent bc7a022c6e
commit 81e923a0aa
24 changed files with 1829 additions and 23 deletions
+62
View File
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
r'''给管理页补 favicon(第二版 —— 这次锚点找对了)。
管理页的 HTML 不在 _admin_page 开头,而是在它内部,
标题那行是 <title>ykxmz 中转服务器</title>,
所以插在它的 viewport 那行之后。
(上一版脚本的文档字符串里写了一个三引号,把自己的 docstring 提前闭合了,
这里改用单引号三连,避免同样的问题。)
'''
from __future__ import annotations
import ast
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
sys.path.insert(0, str(ROOT / "_build"))
from devssh import run, upload # noqa: E402
RELAY = ROOT / "relay" / "relay.py"
ANCHOR = '<meta name=viewport content="width=device-width,initial-scale=1">\n<title>ykxmz 中转服务器</title>'
NEW = ('<meta name=viewport content="width=device-width,initial-scale=1">\n'
'<link rel="icon" href="/favicon.ico">\n'
'<title>ykxmz 中转服务器</title>')
def main() -> int:
text = RELAY.read_text(encoding="utf-8")
if '<link rel="icon" href="/favicon.ico">\n<title>ykxmz 中转服务器' in text:
print(" 管理页已经有 favicon")
elif ANCHOR in text:
text = text.replace(ANCHOR, NEW, 1)
RELAY.write_text(text, encoding="utf-8", newline="\n")
print(" 管理页补上 favicon link")
ast.parse(text)
print(" 语法 OK")
else:
print(" [失败] 锚点还是没找到,实际内容:")
idx = text.find("<title>ykxmz 中转服务器</title>")
if idx > 0:
print(text[max(0, idx - 200):idx + 40])
return 1
print()
print(" 部署…")
upload(str(RELAY), "/root/lanremote-relay/relay.py", 0o755)
upload(str(ROOT / "relay" / "favicon.ico"),
"/root/lanremote-relay/favicon.ico", 0o644)
run("systemctl restart lanremote-relay", timeout=90)
print(" 已重启")
print()
_c, out, _e = run("bash /root/check_web.sh 2>&1", timeout=180)
print(out)
return 0
if __name__ == "__main__":
sys.exit(main())