From 44b6c70a4b6118fd2f16906cd33ea5959ee55056 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Thu, 22 Jan 2026 18:02:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(roi):=E4=BF=AE=E5=A4=8D=20working=5Fhours?= =?UTF-8?q?=20=E4=B8=BA=E7=A9=BA=E6=95=B0=E7=BB=84=20`[]`=20=E6=97=B6?= =?UTF-8?q?=E8=A2=AB=E9=94=99=E8=AF=AF=E8=AF=86=E5=88=AB=E4=B8=BA=20`None`?= =?UTF-8?q?=20=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=85=A8=E5=A4=A9=E6=A8=A1=E5=BC=8F=E5=A4=B1=E6=95=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 `api/roi.py` 中的判断逻辑:使用 `is not None` 替代 truthy 检查,确保 `[]` 能正确序列化并存入数据库 - 更新 `config.yaml` 全局默认值为 `working_hours: []`,表示“全天开启” --- api/roi.py | 4 ++-- config.yaml | 8 ++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/api/roi.py b/api/roi.py index f5eff0d..9833314 100644 --- a/api/roi.py +++ b/api/roi.py @@ -108,7 +108,7 @@ def add_roi( ): import json - working_hours_json = json.dumps(request.working_hours) if request.working_hours else None + working_hours_json = json.dumps(request.working_hours) if request.working_hours is not None else None roi = create_roi( db, @@ -153,7 +153,7 @@ def modify_roi( db: Session = Depends(get_db), ): import json - working_hours_json = json.dumps(request.working_hours) if request.working_hours else None + working_hours_json = json.dumps(request.working_hours) if request.working_hours is not None else None roi = update_roi( db, diff --git a/config.yaml b/config.yaml index 74586ea..1c40cfc 100644 --- a/config.yaml +++ b/config.yaml @@ -60,12 +60,8 @@ roi: - "line" max_points: 50 # 多边形最大顶点数 -# 工作时间配置(全局默认) -working_hours: - - start: [8, 30] # 8:30 - end: [11, 0] # 11:00 - - start: [12, 0] # 12:00 - end: [17, 30] # 17:30 +# 工作时间配置(全局默认,空数组表示全天开启) +working_hours: [] # 算法默认参数 algorithms: