From 44a6190e1759cbb69e8d54ce1cfd238ee37179b9 Mon Sep 17 00:00:00 2001 From: "Yoan.liu" Date: Sun, 13 Apr 2025 09:14:08 +0800 Subject: [PATCH] resolve build error --- ui/src/utils/cron.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/src/utils/cron.ts b/ui/src/utils/cron.ts index 6bccd729..46d806e3 100644 --- a/ui/src/utils/cron.ts +++ b/ui/src/utils/cron.ts @@ -1,8 +1,8 @@ -import { parseExpression } from "cron-parser"; +import { CronExpressionParser } from "cron-parser"; export const validCronExpression = (expr: string): boolean => { try { - parseExpression(expr); + CronExpressionParser.parse(expr); if (expr.trim().split(" ").length !== 5) return false; // pocketbase 后端仅支持五段式的表达式 return true; @@ -15,7 +15,7 @@ export const getNextCronExecutions = (expr: string, times = 1): Date[] => { if (!validCronExpression(expr)) return []; const now = new Date(); - const cron = parseExpression(expr, { currentDate: now }); + const cron = CronExpressionParser.parse(expr, { currentDate: now }); - return cron.iterate(times).map((date) => date.toDate()); + return cron.take(times).map((date) => date.toDate()); };