From 6b68de7f4ed3f0a56f78caa66b4ea95b42b5a5d7 Mon Sep 17 00:00:00 2001 From: liuwei Date: Fri, 17 Apr 2026 09:09:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 变更项:1) 在 system_jobs 蓝图新增时间归一化方法,统一输出为 yyyy-MM-dd HH:mm:ss。2) 系统任务列表接口对 next_run_at 与 last_run_at 做后端格式化。3) 系统任务日志接口对 triggered_at 做后端格式化,避免出现 Fri, 17 Apr ... 的 RFC 时间串。4) 补充中文注释说明格式化策略。 --- admin/dashboard/blueprints/system_jobs.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/admin/dashboard/blueprints/system_jobs.py b/admin/dashboard/blueprints/system_jobs.py index d0dc029..d994e2f 100644 --- a/admin/dashboard/blueprints/system_jobs.py +++ b/admin/dashboard/blueprints/system_jobs.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from datetime import datetime from flask import Blueprint, current_app, jsonify, render_template, request from utils.decorator.async_job import async_job @@ -8,6 +9,18 @@ from .auth import login_required system_jobs_bp = Blueprint("system_jobs", __name__, url_prefix="/system_jobs") +def _normalize_datetime_text(value): + """统一时间文本格式为 `YYYY-MM-DD HH:MM:SS`。""" + if value is None: + return value + if isinstance(value, datetime): + return value.strftime("%Y-%m-%d %H:%M:%S") + text = str(value) + if "T" in text: + return text.replace("T", " ")[:19] + return text + + @system_jobs_bp.route("/") @login_required def page_system_jobs(): @@ -38,11 +51,11 @@ def api_list_jobs(): "runtime_enabled": runtime.get("enabled"), "running": runtime.get("running", False), "trigger_text": runtime.get("trigger_text", ""), - "last_run_at": runtime.get("last_run_at"), + "last_run_at": _normalize_datetime_text(runtime.get("last_run_at")), "last_status": runtime.get("last_status"), "last_error": runtime.get("last_error"), "last_duration_ms": runtime.get("last_duration_ms"), - "next_run_at": runtime.get("next_run_at"), + "next_run_at": _normalize_datetime_text(runtime.get("next_run_at")), "run_count": runtime.get("run_count", 0), "success_count": runtime.get("success_count", 0), "fail_count": runtime.get("fail_count", 0), @@ -104,7 +117,7 @@ def api_job_logs(job_key: str): level = "error" if status == "failed" else ("success" if status == "success" else "info") logs.append( { - "time": row.get("triggered_at"), + "time": _normalize_datetime_text(row.get("triggered_at")), "level": level, "message": row.get("summary") or "", "status": status,