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
+72
View File
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
r"""给管理页 head 补 favicon link,然后部署验证。
前面几次栽在"Python 三层引号套 PowerShell 引号"上,
这次全部走文件:Python 脚本 + shell 脚本,不再用 -c 内联。
"""
from __future__ import annotations
import ast
import re
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"
LINK = '\n<link rel="icon" href="/favicon.ico">'
def patch_admin_head() -> bool:
text = RELAY.read_text(encoding="utf-8")
start = text.find("def _admin_page")
if start < 0:
print(" [失败] 找不到 _admin_page")
return False
head_open = text.find("<head>", start)
head_close = text.find("</head>", head_open)
if head_open < 0 or head_close < 0:
print(" [失败] _admin_page 里找不到 <head>")
return False
segment = text[head_open:head_close]
if "favicon" in segment:
print(" 管理页已经有 favicon")
return True
# 插在 <head> 之后就行,不用找 charset
insert_at = head_open + len("<head>")
text = text[:insert_at] + LINK + text[insert_at:]
RELAY.write_text(text, encoding="utf-8", newline="\n")
print(" 管理页 head 补上 favicon link")
ast.parse(text)
print(" relay.py 语法 OK")
return True
def main() -> int:
if not patch_admin_head():
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()
print(" 验证:")
_c, out, _e = run("bash /root/check_web.sh 2>&1", timeout=180)
print(out)
return 0
if __name__ == "__main__":
sys.exit(main())