fix: 懒加载单例以修复环境变量加载问题

This commit is contained in:
春河晴
2025-06-11 17:22:43 +09:00
parent 6d1f5be4e1
commit 6767bd6715
45 changed files with 243 additions and 155 deletions

View File

@@ -377,5 +377,11 @@ class ChatManager:
logger.error(f"从数据库加载所有聊天流失败 (Peewee): {e}", exc_info=True)
# 创建全局单例
chat_manager = ChatManager()
chat_manager = None
def get_chat_manager():
global chat_manager
if chat_manager is None:
chat_manager = ChatManager()
return chat_manager