()
| 33 | break |
| 34 | case 'time': { |
| 35 | const executeTaskInterval = () => { |
| 36 | const now = new Date() |
| 37 | const scheduledTime = new Date(now) |
| 38 | scheduledTime.setDate(scheduledTime.getDate() + task.run.time.intervalDays) |
| 39 | scheduledTime.setHours(task.run.time.h, task.run.time.m, task.run.time.s) |
| 40 | |
| 41 | // 如果设置的时间比现在的时间早,则表示下一次执行是明天 |
| 42 | if (scheduledTime < now) { |
| 43 | scheduledTime.setDate(scheduledTime.getDate() + 1) |
| 44 | } |
| 45 | |
| 46 | const timeout = scheduledTime.getTime() - now.getTime() |
| 47 | if (timeout >= 0) { |
| 48 | task.run.runId = window.setTimeout(async () => { |
| 49 | await this.executeTask(task) |
| 50 | // 完成执行后,重新计划下一次执行 |
| 51 | executeTaskInterval() |
| 52 | }, timeout) |
| 53 | } |
| 54 | |
| 55 | task.runInfo.msg += '\r\n' + `${t('next_run_at')}: ${scheduledTime.toLocaleString()}` |
| 56 | } |
| 57 | executeTaskInterval() |
| 58 | break |
| 59 | } |
nothing calls this directly
no test coverage detected