From b6cc7651c425ec09e3efff3d809a57ae13d245ae Mon Sep 17 00:00:00 2001 From: Tordor <3262978839@qq.com> Date: Thu, 15 Jan 2026 17:45:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=90=86=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 1 + service/__init__.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 8f795f8..dfb5e06 100644 --- a/config.py +++ b/config.py @@ -4,6 +4,7 @@ from pydantic_settings import BaseSettings,SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env" , env_prefix="WNZS_") PGSQL: str = "" + WECOM_PROXY: str = "" WECOM_CORPID: str = "" WECOM_CORPSECRET: str = "" WECOM_APP_TOKEN: str = "" diff --git a/service/__init__.py b/service/__init__.py index 23270a6..2499f88 100644 --- a/service/__init__.py +++ b/service/__init__.py @@ -3,7 +3,13 @@ from config import Settings from utils.sing import SingletonProvider # 获取单例函数 +def get_wecom_single() -> Wecom: + wecom = Wecom( + Settings().WECOM_CORPID,Settings().WECOM_CORPSECRET + ) + WECOM_PROXY = Settings().WECOM_PROXY + if WECOM_PROXY and WECOM_PROXY != "": + wecom.BASE_URL = WECOM_PROXY + return wecom -get_wecom = SingletonProvider(lambda: Wecom( - Settings().WECOM_CORPID,Settings().WECOM_CORPSECRET -)) \ No newline at end of file +get_wecom = SingletonProvider(get_wecom_single) \ No newline at end of file