From 0a21b7d6870e9dd2f9ac155476ca1a1f0dc76a64 Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 10 Jun 2025 17:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/blueprints/message_push.py | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/admin/dashboard/blueprints/message_push.py b/admin/dashboard/blueprints/message_push.py index d9cffc0..9310447 100644 --- a/admin/dashboard/blueprints/message_push.py +++ b/admin/dashboard/blueprints/message_push.py @@ -152,7 +152,35 @@ def api_create_task(): # 确保 preview_recipients 是 JSON 字符串 if 'preview_recipients' in data and isinstance(data['preview_recipients'], list): data['preview_recipients'] = json.dumps(data['preview_recipients']) + + # 转换时间格式 + if 'created_at' in data: + try: + date = datetime.strptime(data['created_at'], '%a, %d %b %Y %H:%M:%S GMT') + data['created_at'] = date.strftime('%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + if 'updated_at' in data: + try: + date = datetime.strptime(data['updated_at'], '%a, %d %b %Y %H:%M:%S GMT') + data['updated_at'] = date.strftime('%Y-%m-%d %H:%M:%S') + except ValueError: + pass + if 'schedule_time' in data: + try: + date = datetime.strptime(data['schedule_time'], '%a, %d %b %Y %H:%M:%S GMT') + data['schedule_time'] = date.strftime('%Y-%m-%d %H:%M:%S') + except ValueError: + pass + + if 'recurring_end' in data and data['recurring_end']: + try: + date = datetime.strptime(data['recurring_end'], '%a, %d %b %Y %H:%M:%S GMT') + data['recurring_end'] = date.strftime('%Y-%m-%d %H:%M:%S') + except ValueError: + pass # 创建任务 db = current_app.dashboard_server.task_db task = db.create_task(data) @@ -166,7 +194,7 @@ def api_create_task(): } }) except Exception as e: - logger.error(f"创建任务失败: {e}") + logger.exception(f"创建任务失败: {e}") return jsonify({"success": False, "error": str(e)}), 500