fix: 统一所有 JSON 文件读写为 UTF-8 编码
Windows 中文环境默认编码为 GBK,未指定 encoding 会导致 config.json/all_keys.json 解析失败。修复 9 个文件共 17 处。 Closes #32 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
4
main.py
4
main.py
@@ -28,7 +28,7 @@ def ensure_keys(keys_file, db_dir):
|
||||
"""确保密钥文件存在且匹配当前 db_dir,否则重新提取"""
|
||||
if os.path.exists(keys_file):
|
||||
try:
|
||||
with open(keys_file) as f:
|
||||
with open(keys_file, encoding="utf-8") as f:
|
||||
keys = json.load(f)
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
keys = {}
|
||||
@@ -59,7 +59,7 @@ def ensure_keys(keys_file, db_dir):
|
||||
print("[!] 密钥提取失败")
|
||||
sys.exit(1)
|
||||
try:
|
||||
with open(keys_file) as f:
|
||||
with open(keys_file, encoding="utf-8") as f:
|
||||
keys = json.load(f)
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
keys = {}
|
||||
|
||||
Reference in New Issue
Block a user