修复插件定时任务星期与时间格式显示问题

变更项:1) async_job 触发文案把每周数字改为中文星期(周一到周日),消除星期显示歧义。2) async_job 时间序列化改为 yyyy-MM-dd HH:mm:ss,去掉 ISO 格式中的 T。3) 插件定时任务页面统一使用 formatDateTime 渲染下次执行、上次执行与日志触发时间,前端兜底去除 T。4) 补充中文注释说明显示层与调度层格式化意图。
This commit is contained in:
liuwei
2026-04-16 17:41:53 +08:00
parent 09eff21761
commit 879e64fb7c
2 changed files with 55 additions and 6 deletions

View File

@@ -48,7 +48,22 @@ class AsyncJob:
@staticmethod
def _safe_iso(dt: Optional[datetime]) -> Optional[str]:
return dt.isoformat(timespec="seconds") if dt else None
# 后台展示统一使用空格分隔时间,避免前端看到 ISO 格式中的 'T'。
return dt.strftime("%Y-%m-%d %H:%M:%S") if dt else None
@staticmethod
def _weekday_to_label(weekday: int) -> str:
"""把 0-6周一到周日转换为中文星期标签。"""
mapping = {
0: "周一",
1: "周二",
2: "周三",
3: "周四",
4: "周五",
5: "周六",
6: "周日",
}
return mapping.get(int(weekday), f"{weekday}")
@staticmethod
def _normalize_time_str(time_str: str) -> str:
@@ -94,9 +109,11 @@ class AsyncJob:
if trigger_type == "at_times":
return "每天 " + ", ".join(trigger_config.get("time_list", []))
if trigger_type == "every_weekday_time":
return f"每周{trigger_config['weekday']} {trigger_config['time_str']}"
# 触发文案显示中文星期避免出现“周5显示成4”的数字歧义。
return f"{self._weekday_to_label(trigger_config['weekday'])} {trigger_config['time_str']}"
if trigger_type == "every_week_time":
return f"每周{trigger_config['weekday']} {trigger_config['time_str']}"
# 与 every_weekday_time 保持一致,统一中文星期展示。
return f"{self._weekday_to_label(trigger_config['weekday'])} {trigger_config['time_str']}"
if trigger_type == "every_month_last_day_time":
return f"每月最后一天 {trigger_config['time_str']}"
return trigger_type