fix: 添加 cron_expression_to_human 函数到 utils.py

This commit is contained in:
2026-06-01 12:31:38 +08:00
parent 69edd1c63e
commit 7904117b1d
11 changed files with 32 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -30314,3 +30314,6 @@ Press CTRL+C to quit
[2026-06-01 12:29:39] 访问地址: http://localhost:16022 [2026-06-01 12:29:39] 访问地址: http://localhost:16022
[2026-06-01 12:29:39] 进程PID: 784244 [2026-06-01 12:29:39] 进程PID: 784244
[2026-06-01 12:29:39] ================================================== [2026-06-01 12:29:39] ==================================================
[2026-06-01 12:30:38] ⚠️ 进程收到 SIGTERM 信号,即将退出!
[2026-06-01 12:31:16] 项目服务管理面板 v3.4.0 初始化完成
[2026-06-01 12:31:16] 启动 项目服务管理面板,端口: 16022

View File

@@ -195,6 +195,35 @@ def parse_cron_expression(expr):
return ' '.join(desc) if desc else expr return ' '.join(desc) if desc else expr
def cron_expression_to_human(expr):
"""更友好的人类可读格式"""
parts = expr.split()
if len(parts) != 5:
return expr
minute, hour, day, month, weekday = parts
# 特殊模式
patterns = [
('0 4 * * *', '每天凌晨4点'),
('0 0 * * *', '每天午夜0点'),
('*/5 * * * *', '每5分钟'),
('*/10 * * * *', '每10分钟'),
('*/20 * * * *', '每20分钟'),
('*/30 * * * *', '每30分钟'),
('0 */1 * * *', '每小时'),
('0 */2 * * *', '每2小时'),
('0 9 * * 1', '每周一9点'),
('0 9 * * 1-5', '每周一到五9点'),
]
for pattern, desc in patterns:
if expr == pattern:
return desc
# 通用解析
return parse_cron_expression(expr)
def guess_cron_name(command): def guess_cron_name(command):
"""从命令推断任务名称""" """从命令推断任务名称"""