refactor(managers): 重构单例管理器实现并优化代码结构

feat(ws_pool): 新增 WebSocket 连接池实现

perf(json): 使用 orjson 替代标准 json 库提升性能

style: 清理未使用的导入和冗余代码

docs: 更新架构文档和开发规范

test: 添加 WebSocket 连接池测试用例

fix(plugins): 修复自动审批插件 API 调用参数格式
This commit is contained in:
2026-01-22 16:23:03 +08:00
parent d7d732ff4d
commit caf5b06097
42 changed files with 1285 additions and 261 deletions

View File

@@ -1,7 +1,7 @@
"""
通用单例模式基类
"""
from typing import Any, Dict, Optional, Type, TypeVar
from typing import Any, Dict, Optional, Type, TypeVar, cast
T = TypeVar('T')
@@ -29,9 +29,9 @@ class Singleton:
Returns:
T: 单例实例
"""
# 使用全局字典存储实例,避免类型检查问题
# 使用全局字典存储实例,修复类型检查问题
if cls not in _instance_store:
_instance_store[cls] = super().__new__(cls)
_instance_store[cls] = super(Singleton, cls).__new__(cls)
return _instance_store[cls]
def __init__(self) -> None:
@@ -67,7 +67,7 @@ def singleton(cls: Type[T]) -> Type[T]:
nonlocal class_instance
if class_instance is None:
# 使用super()调用原始类的__new__方法
class_instance = cls(*args, **kwargs)
class_instance = super(SingletonClass, cls).__new__(cls)
return class_instance
# 复制类的元数据