From ff75be02d665d98a035b71ba37aa81322eab9fe2 Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 10 Jun 2025 16:46:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=91=A8=E6=9C=9F=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E9=87=8C=E9=9D=A2=E7=9A=84=E6=AF=8F=E4=B8=AA=E5=91=A8?= =?UTF-8?q?=E6=9C=9F=E7=9A=84=E5=85=B7=E4=BD=93=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/blueprints/message_push.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/admin/dashboard/blueprints/message_push.py b/admin/dashboard/blueprints/message_push.py index 21e861e..24498be 100644 --- a/admin/dashboard/blueprints/message_push.py +++ b/admin/dashboard/blueprints/message_push.py @@ -98,18 +98,21 @@ def api_tasks_list(): db = current_app.dashboard_server.task_db tasks, total = db.get_tasks_list(status, start_time, end_time, page, limit) - # 处理recurring_time序列化问题 + # 处理任务数据,确保所有字段都可以JSON序列化 + serialized_tasks = [] for task in tasks: - if hasattr(task, 'recurring_time') and task.recurring_time: - # 将timedelta转换为HH:mm格式的字符串 - hours = task.recurring_time.seconds // 3600 - minutes = (task.recurring_time.seconds % 3600) // 60 - task.recurring_time = f"{hours:02d}:{minutes:02d}" + task_dict = dict(task) + # 处理recurring_time + if task_dict.get('recurring_time'): + hours = task_dict['recurring_time'].seconds // 3600 + minutes = (task_dict['recurring_time'].seconds % 3600) // 60 + task_dict['recurring_time'] = f"{hours:02d}:{minutes:02d}" + serialized_tasks.append(task_dict) return jsonify({ "success": True, "data": { - "tasks": tasks, + "tasks": serialized_tasks, "total": total, "page": page, "limit": limit