feat: 计划任务运行周期支持重启后,close #1456

This commit is contained in:
耗子
2026-03-08 00:42:09 +08:00
parent 4a6fdc45d5
commit 971aaddc85
2 changed files with 16 additions and 0 deletions
@@ -32,6 +32,12 @@ const formatTime = (hour: string, minute: string): string => {
// 解析 Cron 表达式并生成人类可读描述
const parseDescription = computed((): string => {
const cron = props.cron.trim()
// 特殊表达式
if (cron === '@reboot') {
return $gettext('Run once after system reboot')
}
const parts = cron.split(/\s+/)
// Cron 表达式应该有 5 个部分:分 时 日 月 周
@@ -38,6 +38,12 @@ const initialized = ref(false)
const parseCron = (cron: string) => {
if (!cron) return
// 特殊表达式
if (cron === '@reboot') {
selectedOption.value = 'reboot'
return
}
const parts = cron.split(' ')
if (parts.length !== 5) {
// 无法解析,使用自定义模式
@@ -155,6 +161,7 @@ const options = [
{ label: $gettext('Weekly'), value: 'every-week' },
{ label: $gettext('Monthly'), value: 'every-month' },
{ label: $gettext('Yearly'), value: 'every-year' },
{ label: $gettext('After Reboot'), value: 'reboot' },
{ label: $gettext('Custom'), value: 'custom' }
]
@@ -219,6 +226,9 @@ const generateCron = (): string => {
case 'custom':
return customCron
case 'reboot':
return '@reboot'
default:
return '* * * * *'
}