diff --git a/utils/login_qrcode.py b/utils/login_qrcode.py index dda3ed3..13c1cec 100644 --- a/utils/login_qrcode.py +++ b/utils/login_qrcode.py @@ -35,7 +35,13 @@ def remove_qrcode_file(qrcode_path: Path | None) -> bool: def decode_qrcode_from_path(qrcode_path: Path) -> str | None: - image = cv2.imread(str(qrcode_path)) + # Windows 下 cv2.imread 不支持中文路径, 改用 np.fromfile + imdecode + import numpy as np + + try: + image = cv2.imdecode(np.fromfile(str(qrcode_path), dtype=np.uint8), cv2.IMREAD_COLOR) + except Exception: + return None if image is None: return None