1.6.0:重写 README,面向老师 / 电教 / 开发者 / 普通用户

README
- 原来的 README 是开发者视角(在解释我为什么没做某功能),
  而且通篇 AI 腔。这次按用户视角重写,讲怎么用。
- 开头就分流:老师 / 电教 / 开发者 / 普通用户,各看各的
- 定位改成教室电脑手表遥控,主场景是老师上课管教室那台电脑
- 加了电教专用一节:机房同传部署、脚本批量推、网络规划、权限收口
- 加了开发者一节:三端怎么编译、怎么跑测试、怎么打包
- 加了通信协议一节
- 常见问题、排错顺序、错误对照表都补全

版本号
- 1.5.0 -> 1.6.0(versionCode 107)
- 顺手写了通用的版本升级脚本 _build/bump_version_generic.py,
  以后升版本一条命令就行,不用手改十几个文件
This commit is contained in:
xmz7891
2026-10-06 23:08:07 +08:00
parent 60d1bdfe58
commit 07e96a9595
15 changed files with 730 additions and 675 deletions
+148
View File
@@ -0,0 +1,148 @@
# -*- coding: utf-8 -*-
r"""通用版本号升级(1.5.0 -> 1.6.0)。
只改**用户能看到版本号的地方**,不动那些当数据用的 "1.4.0/1.5.0":
* HTTP User-Agent "LanRemote/1.4.0" —— 协议标识,不是产品版本,
而且 20 多个测试在断言它,动它要同步改一大片
* _tests 里当测试数据用的版本串
* _build 下的一次性脚本(历史记录)
改这些:
android/AndroidManifest.xml versionCode / versionName
android/build_apk.ps1 APK 文件名 + manifest 参数
_build/package_remote.py 三个产物名
windows/version_info.txt EXE 的文件版本
windows/lanremote/__init__.py __version__
docs/*.txt 三份文档
relay/relay.py VERSION
_tests/test_package_remote.py 断言成品名
_tests/test_apk_contents.py 断言 APK 名
"""
from __future__ import annotations
import re
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
OLD = sys.argv[1] if len(sys.argv) > 1 else "1.5.0"
NEW = sys.argv[2] if len(sys.argv) > 2 else "1.6.0"
OLD_CODE = str(int(OLD.split(".")[0]) * 100 + int(OLD.split(".")[1]) + 1)
NEW_CODE = str(int(NEW.split(".")[0]) * 100 + int(NEW.split(".")[1]) + 1)
def swap(path: Path, pairs, note: str) -> bool:
if not path.is_file():
print(f" [跳过] {path.name} 不存在")
return False
raw = path.read_bytes()
had_bom = raw.startswith(b"\xef\xbb\xbf")
text = raw.decode("utf-8-sig")
original = text
for old, new in pairs:
text = text.replace(old, new)
if text == original:
print(f" [跳过] {path.name}: 没有 {OLD}")
return False
path.write_bytes((b"\xef\xbb\xbf" if had_bom else b"")
+ text.replace("\r\n", "\n").encode("utf-8"))
print(f" {path.name}: {note}")
return True
def main() -> int:
print(f" 版本号 {OLD} -> {NEW}(versionCode {OLD_CODE} -> {NEW_CODE})")
print()
changed = 0
# ---- Android manifest ----
manifest = ROOT / "android" / "AndroidManifest.xml"
if swap(manifest,
[(f'android:versionCode="{OLD_CODE}"',
f'android:versionCode="{NEW_CODE}"'),
(f'android:versionName="{OLD}"',
f'android:versionName="{NEW}"')],
f"versionCode={NEW_CODE} versionName={NEW}"):
changed += 1
# ---- APK 构建脚本 ----
apk_ps1 = ROOT / "android" / "build_apk.ps1"
if swap(apk_ps1,
[(f"ykxmz-watch-{OLD}.apk", f"ykxmz-watch-{NEW}.apk"),
(f"--version-code {OLD_CODE}", f"--version-code {NEW_CODE}"),
(f'--version-name "{OLD}"', f'--version-name "{NEW}"')],
"APK 名 + 版本"):
changed += 1
# ---- 打包脚本 ----
if swap(ROOT / "_build" / "package_remote.py",
[(f'VERSION = "{OLD}"', f'VERSION = "{NEW}"')],
f"VERSION={NEW}"):
changed += 1
# ---- Windows EXE 版本信息 ----
if swap(ROOT / "windows" / "version_info.txt",
[(f'"{OLD}.0"', f'"{NEW}.0"')],
f"EXE 文件版本 {NEW}.0"):
changed += 1
# ---- __init__ ----
if swap(ROOT / "windows" / "lanremote" / "__init__.py",
[(f'"{OLD}"', f'"{NEW}"')],
f"__version__={NEW}"):
changed += 1
# ---- 中转 VERSION ----
if swap(ROOT / "relay" / "relay.py",
[(f'VERSION = "{OLD}"', f'VERSION = "{NEW}"')],
f"VERSION={NEW}"):
changed += 1
# ---- 三份文档 ----
for path in sorted((ROOT / "docs").glob("*.txt")):
raw = path.read_bytes()
had_bom = raw.startswith(b"\xef\xbb\xbf")
text = raw.decode("utf-8-sig")
new_text = text.replace(OLD, NEW)
if new_text != text:
path.write_bytes((b"\xef\xbb\xbf" if had_bom else b"")
+ new_text.replace("\r\n", "\n").encode("utf-8"))
print(f" docs/{path.name}")
changed += 1
# ---- 会断言成品名的测试 ----
for name in ("test_package_remote.py", "test_apk_contents.py"):
path = ROOT / "_tests" / name
if not path.is_file():
continue
text = path.read_text(encoding="utf-8")
new_text = (text.replace(f"ykxmz-agent-{OLD}", f"ykxmz-agent-{NEW}")
.replace(f"ykxmz-server-{OLD}", f"ykxmz-server-{NEW}")
.replace(f"ykxmz-watch-{OLD}", f"ykxmz-watch-{NEW}"))
if new_text != text:
path.write_text(new_text, encoding="utf-8", newline="\n")
print(f" _tests/{name}")
changed += 1
print()
print(f" 共改了 {changed} 处")
print(f" 注意:HTTP UA 仍然是 LanRemote/1.4.0(协议标识,不是产品版本)")
# 复核
print()
print(" 复核:")
checks = [
(manifest, f'versionName="{NEW}"'),
(apk_ps1, f"ykxmz-watch-{NEW}.apk"),
(ROOT / "_build" / "package_remote.py", f'VERSION = "{NEW}"'),
]
for path, needle in checks:
ok = needle in path.read_text(encoding="utf-8-sig")
print(f" {path.name}: {'✓' if ok else '✗'} {needle}")
return 0
if __name__ == "__main__":
sys.exit(main())
+1 -1
View File
@@ -17,7 +17,7 @@ import zipfile
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
VERSION = "1.5.0"
VERSION = "1.6.0"
NAME = f"ykxmz-{VERSION}"
AGENT_SRC = ROOT / "dist_exe" / "ykxmz"
+54
View File
@@ -0,0 +1,54 @@
# 提交并推送 1.6.0
$ErrorActionPreference = "Continue"
$git = "C:\Program Files\Git\bin\git.exe"
$root = "C:\Users\shu\Desktop\deepseekagent\LanRemote"
Set-Location $root
Write-Host "===== 1. 暂存 =====" -ForegroundColor Cyan
& $git add -A 2>&1 | Out-Null
$files = @(& $git -c core.quotepath=false diff --cached --name-only |
Where-Object { $_ -and $_.Trim() -ne "" })
Write-Host " 改动: $($files.Count) 个"
$files | Select-Object -First 20 | ForEach-Object { Write-Host " $_" }
Write-Host ""
Write-Host "===== 2. 确认没有大文件 =====" -ForegroundColor Cyan
$big = foreach ($f in $files) {
$p = Join-Path $root ($f -replace '/','\')
if (Test-Path -LiteralPath $p -PathType Leaf) {
$len = (Get-Item -LiteralPath $p).Length
if ($len -gt 500KB) { [pscustomobject]@{ N = $f; MB = [math]::Round($len/1MB,2) } }
}
}
if ($big) { $big | ForEach-Object { Write-Host " ⚠ $($_.MB) MB $($_.N)" -ForegroundColor Yellow } }
else { Write-Host " ✓ 没有超过 500KB 的" -ForegroundColor Green }
Write-Host ""
Write-Host "===== 3. 提交 =====" -ForegroundColor Cyan
$msg = @"
1.6.0:重写 README,面向老师 / 电教 / 开发者 / 普通用户
README
- 原来的 README 是开发者视角(在解释"我为什么没做某功能"),
而且通篇 AI 腔。这次按用户视角重写,讲怎么用。
- 开头就分流:老师 / 电教 / 开发者 / 普通用户,各看各的
- 定位改成"教室电脑手表遥控",主场景是老师上课管教室那台电脑
- 加了电教专用一节:机房同传部署、脚本批量推、网络规划、权限收口
- 加了开发者一节:三端怎么编译、怎么跑测试、怎么打包
- 加了通信协议一节
- 常见问题、排错顺序、错误对照表都补全
版本号
- 1.5.0 -> 1.6.0(versionCode 107)
- 顺手写了通用的版本升级脚本 _build/bump_version_generic.py,
以后升版本一条命令就行,不用手改十几个文件
"@
& $git commit -q -m $msg 2>&1 | Out-Null
Write-Host " exit=$LASTEXITCODE"
& $git log --oneline 2>&1 | Select-Object -First 2 | ForEach-Object { Write-Host " $_" }
Write-Host ""
Write-Host "===== 4. 推送 =====" -ForegroundColor Cyan
$env:GIT_SSH_COMMAND = "`"C:\Program Files\Git\usr\bin\ssh.exe`""
& $git push origin main 2>&1 | Select-Object -Last 5 | ForEach-Object { Write-Host " $_" }
Write-Host " exit=$LASTEXITCODE"
+53
View File
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
r"""上传 1.6.0 到中转站下载区,并清掉旧版本。"""
from __future__ import annotations
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
VER = "1.6.0"
REMOTE_DIR = "/root/lanremote-relay/downloads"
UPLOADS = [
(f"dist/ykxmz-agent-{VER}.zip",
f"{REMOTE_DIR}/ykxmz-agent-{VER}.zip"),
(f"dist/ykxmz-server-{VER}.zip",
f"{REMOTE_DIR}/ykxmz-server-{VER}.zip"),
(f"dist/ykxmz-watch-{VER}.apk",
f"{REMOTE_DIR}/ykxmz-watch-{VER}.apk"),
]
def main() -> int:
# 旧版本清掉,页面上只留最新的一份
print(" 清掉旧版本:")
_c, out, _e = run(f"ls {REMOTE_DIR}/ 2>/dev/null", timeout=30)
for line in (out or "").splitlines():
name = line.strip()
if name and VER not in name:
run(f"rm -f '{REMOTE_DIR}/{name}'", timeout=30)
print(f" 删除 {name}")
print()
print(" 上传 1.6.0:")
for local, remote in UPLOADS:
src = ROOT / local
if not src.is_file():
print(f" [失败] {local} 不存在")
return 1
upload(str(src), remote, 0o644)
print(f" ✓ {src.name} ({src.stat().st_size / 1024 / 1024:.2f} MB)")
print()
_c, out, _e = run(f"ls -la {REMOTE_DIR}/ | tail -6", timeout=30)
print(out)
return 0
if __name__ == "__main__":
sys.exit(main())