🔧 优化 JSON 写入格式

- 调整 JSON 写入时的缩进为 2 个空格,以保持一致性
- 添加 `sort_keys=False` 参数以避免键排序,保持原有顺序
This commit is contained in:
Cp0204 2024-12-04 15:12:17 +08:00
parent 09109fe9bf
commit b3e0eead61
2 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ def read_json():
# 将数据写入 JSON 文件
def write_json(data):
with open(CONFIG_PATH, "w", encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False, sort_keys=False)
json.dump(data, f, ensure_ascii=False, sort_keys=False, indent=2)
def is_login():

View File

@ -964,7 +964,7 @@ def main():
if cookie_form_file:
# 更新配置
with open(config_path, "w", encoding="utf-8") as file:
json.dump(CONFIG_DATA, file, ensure_ascii=False, indent=2)
json.dump(CONFIG_DATA, file, ensure_ascii=False, sort_keys=False, indent=2)
print(f"===============程序结束===============")
duration = datetime.now() - start_time