Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/app/service/sandbox/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@App/app/repo/scripts";
import type { Server } from "@Packages/message/server";
import type { WindowMessage } from "@Packages/message/window_message";
import { CronJob } from "cron";
import { createCronJob, type CronJob } from "@App/pkg/utils/cron";
import { proxyUpdateRunStatus } from "../offscreen/client";
import { BgExecScriptWarp } from "../content/exec_warp";
import type ExecScript from "../content/exec_script";
Expand Down Expand Up @@ -268,7 +268,11 @@ export class Runtime {
ok = 2;
const onTick = this.crontabExec(script, oncePos);
ok = 4;
const cron = new CronJob(cronExpr, onTick);
const cron = createCronJob({
cronTime: cronExpr,
onTick,
start: false, // 不使用 start: true。下面手动执行。
});
ok = 6;
cron.start();
ok = 8;
Expand Down
12 changes: 2 additions & 10 deletions src/pages/options/routes/Agent/Tasks/cron.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import { nextTimeInfo, nextTimeDisplay } from "@App/pkg/utils/cron";
import { nextRunText } from "@App/pkg/utils/cron";

// 复用仓库既有的 cron 解析工具,给出「下次运行」预览、合法性与可排序的时间戳。
export function nextRunText(crontab: string): { text: string; valid: boolean; at: number | null } {
if (!crontab.trim()) return { text: "", valid: false, at: null };
try {
const info = nextTimeInfo(crontab); // 非法表达式会抛错
return { text: nextTimeDisplay(crontab), valid: true, at: info.next.toMillis() };
} catch {
return { text: "", valid: false, at: null };
}
}
export { nextRunText };
Loading
Loading