From 7c1a6caf470345a9169b55e5101660bcc2be0feb Mon Sep 17 00:00:00 2001 From: yml2213 Date: Wed, 7 Oct 2026 16:19:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20=E8=A1=A5=E5=85=85=20peace=5Fena?= =?UTF-8?q?bled=20=E5=AD=97=E6=AE=B5=E5=A3=B0=E6=98=8E=E5=B9=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AE=89=E5=85=A8=E5=B1=9E=E6=80=A7=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 DouyuConfigOut 与 DouyuConfigUpdate 中加入 peace_enabled 声明与序列化 - 在 update_config 中使用 getattr(req, field, None) 做安全兜底,避免 500 --- web/backend/routers/douyu.py | 2 +- web/backend/schemas.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/backend/routers/douyu.py b/web/backend/routers/douyu.py index 0dad9dc..9e2bc11 100644 --- a/web/backend/routers/douyu.py +++ b/web/backend/routers/douyu.py @@ -624,7 +624,7 @@ def update_config( config = ensure_douyu_config(db) changed_fields = [] for field in DOUYU_CONFIG_FIELDS: - value = getattr(req, field) + value = getattr(req, field, None) if value is None: continue setattr(config, field, value.strip() if isinstance(value, str) else value) diff --git a/web/backend/schemas.py b/web/backend/schemas.py index 9ecd0b3..062a1bb 100644 --- a/web/backend/schemas.py +++ b/web/backend/schemas.py @@ -769,6 +769,7 @@ class DouyuConfigOut(BaseModel): esports_chicken_skin_id: str = "0" esports_firework_gift_id: str = "24767" esports_firework_skin_id: str = "3850" + peace_enabled: bool = False xpd_act_alias: str = "20260623KDQFH" xpd_act_id: str = "46195" xpd_rid: str = "9263298" @@ -797,6 +798,7 @@ class DouyuConfigOut(BaseModel): "esports_chicken_skin_id": self.esports_chicken_skin_id, "esports_firework_gift_id": self.esports_firework_gift_id, "esports_firework_skin_id": self.esports_firework_skin_id, + "peace_enabled": self.peace_enabled, "xpd_act_alias": self.xpd_act_alias, "xpd_act_id": self.xpd_act_id, "xpd_rid": self.xpd_rid, @@ -825,6 +827,7 @@ class DouyuConfigUpdate(BaseModel): esports_chicken_skin_id: str | None = None esports_firework_gift_id: str | None = None esports_firework_skin_id: str | None = None + peace_enabled: bool | None = None xpd_act_alias: str | None = None xpd_act_id: str | None = None xpd_rid: str | None = None