diff --git a/app/core/config.py b/app/core/config.py index 24bd82b..8fb5b46 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -30,13 +30,11 @@ def __mkdir(self) -> None: """ 创建目录 """ - with self.CONFIG_DIR as dir_path: - if not dir_path.exists(): - dir_path.mkdir(parents=True, exist_ok=True) + if not self.CONFIG_DIR.exists(): + self.CONFIG_DIR.mkdir(parents=True, exist_ok=True) - with self.LOG_DIR as dir_path: - if not dir_path.exists(): - dir_path.mkdir(parents=True, exist_ok=True) + if not self.LOG_DIR.exists(): + self.LOG_DIR.mkdir(parents=True, exist_ok=True) def __load_mode(self) -> None: """ diff --git a/app/utils/http.py b/app/utils/http.py index 1040017..273545f 100644 --- a/app/utils/http.py +++ b/app/utils/http.py @@ -338,7 +338,7 @@ class RequestUtils: 支持同步和异步请求 """ - __client = HTTPClient + __client: HTTPClient | None = None @classmethod def get_client(cls, *_, **__) -> HTTPClient: @@ -348,7 +348,9 @@ def get_client(cls, *_, **__) -> HTTPClient: :param url: 请求的 URL :return: HTTP 客户端 """ - return cls.client + if cls.__client is None: + cls.__client = HTTPClient() + return cls.__client @overload @classmethod