Files
ykxmz/_build/fix_commit_msg.py
T
xmz7891 81e923a0aa 1.7.1:修白屏 + 配对 + 官网管理页分家
手表端
- 修「连上后一片白屏」:initTabs() 从来没被调用过,
  导致 tabDefs 为 null、selectTab 直接 return,
  标签栏里只剩一个孤立的滑动指示器
- 应用名改成 ykxmz

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

服务器端
- / 改成官网(公开,简洁介绍 + 下载)
- /zhingzhuanzhan 中转站管理(要登录),/admin 自动跳转
- 管理账号 xmz7891,可改
- 官网 / 登录页 / 管理页都加上 favicon
2026-10-06 23:08:07 +08:00

46 lines
1.4 KiB
Python
Raw 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 -*-
r'''修复被 GBK 二次编码搞乱的提交信息。
成因:
PowerShell 的 git commit -m $msg 把 UTF-8 的中文按 GBK 传给 git,
git 又把那串字节当 UTF-8 存了 —— 等于"多错一层"。
结果:ykxmz 1.5.0锛氭墜琛ㄧ TLS ...
恢复:
当前字符串 -> encode('gbk') 拿回原始 UTF-8 字节 -> decode('utf-8')
这个脚本给 git filter-branch --msg-filter 用:
消息从 stdin 进来,改完写到 stdout。
'''
from __future__ import annotations
import sys
# 明显的乱码特征字(GBK 误读 UTF-8 会产生这些生僻字)
MARKERS = "锛氬焷姘噰鏃粈缂撳啿鏈嬭繛璇佷功鍏煎寘涓嬭浇鍖哄尯鐗堟湰"
def fix(text: str) -> str:
"""试着把乱码还原;还原不了就原样返回。"""
if not any(ch in text for ch in MARKERS):
return text
try:
recovered = text.encode("gbk").decode("utf-8")
except (UnicodeEncodeError, UnicodeDecodeError):
return text
# 还原后如果还有一堆乱码特征,说明不是这个问题,别乱改
if any(ch in recovered for ch in MARKERS):
return text
return recovered
def main() -> int:
raw = sys.stdin.buffer.read()
text = raw.decode("utf-8", "replace")
sys.stdout.buffer.write(fix(text).encode("utf-8"))
return 0
if __name__ == "__main__":
sys.exit(main())