# -*- coding: utf-8 -*- r'''版本号 1.8.0 -> 1.8.1。 这次是 bug 修复版:局域网劫持 + 长轮询 60 秒。 (用户规矩:每次上传都要升版号。) ''' from __future__ import annotations import sys from pathlib import Path ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote") OLD, NEW = "1.8.0", "1.8.1" BOM = b"\xef\xbb\xbf" TARGETS = [ "android/AndroidManifest.xml", "android/build_apk.ps1", "installer/ykxmz.iss", "relay/relay.py", "windows/lanremote/__init__.py", "_tests/test_apk_contents.py", "_tests/test_package_remote.py", "_build/package_remote.py", "_build/test_installer_cycle.py", ] NEEDS_BOM = {".ps1"} def main() -> int: print(" %s -> %s" % (OLD, NEW)) total = 0 for rel in TARGETS: path = ROOT / rel if not path.is_file(): print(" [跳过] %s 不存在" % rel) continue raw = path.read_bytes() had_bom = raw.startswith(BOM) text = raw.decode("utf-8-sig") if OLD not in text: print(" [跳过] %-40s 里面没有 %s" % (rel, OLD)) continue count = text.count(OLD) text = text.replace(OLD, NEW) want_bom = path.suffix in NEEDS_BOM or had_bom data = text.encode("utf-8") if want_bom: data = BOM + data path.write_bytes(data) print(" %-40s 改了 %d 处" % (rel, count)) total += count print() print(" 共改 %d 处" % total) return 0 if __name__ == "__main__": sys.exit(main())