全面更换orjson

This commit is contained in:
雅诺狐
2025-08-26 14:20:26 +08:00
parent bfabf896b5
commit 4a44ba9866
45 changed files with 991 additions and 1279 deletions

View File

@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
from typing import Dict, List, Any, Union
import os
import toml
import json
import orjson
import shutil
import datetime
@@ -144,14 +144,14 @@ class PluginBase(ABC):
try:
with open(manifest_path, "r", encoding="utf-8") as f:
self.manifest_data = json.load(f)
self.manifest_data = orjson.loads(f.read())
logger.debug(f"{self.log_prefix} 成功加载manifest文件: {manifest_path}")
# 验证manifest格式
self._validate_manifest()
except json.JSONDecodeError as e:
except orjson.JSONDecodeError as e:
error_msg = f"{self.log_prefix} manifest文件格式错误: {e}"
logger.error(error_msg)
raise ValueError(error_msg) # noqa

View File

@@ -453,7 +453,7 @@ class ManifestValidator:
# try:
# manifest_path = os.path.join(plugin_dir, "_manifest.json")
# with open(manifest_path, "w", encoding="utf-8") as f:
# json.dump(manifest_data, f, ensure_ascii=False, indent=2)
# orjson.dumps(manifest_data, f, ensure_ascii=False, indent=2)
# logger.info(f"Manifest文件已保存: {manifest_path}")
# return True
# except Exception as e:
@@ -478,7 +478,7 @@ class ManifestValidator:
# try:
# with open(manifest_path, "r", encoding="utf-8") as f:
# manifest_data = json.load(f)
# manifest_data = orjson.loads(f.read())
# validator = ManifestValidator()
# is_valid = validator.validate_manifest(manifest_data)