feat(ui): new WorkflowStartNodeForm using antd

This commit is contained in:
Fu Diwei
2024-12-25 00:36:02 +08:00
parent 401fa3dcdd
commit c9024c5611
13 changed files with 262 additions and 179 deletions

26
ui/src/utils/cron.ts Normal file
View File

@@ -0,0 +1,26 @@
import { parseExpression } from "cron-parser";
export const validCronExpression = (expr: string): boolean => {
try {
parseExpression(expr);
return true;
} catch {
return false;
}
};
export const getNextCronExecutions = (expr: string, times = 1): Date[] => {
try {
const now = new Date();
const cron = parseExpression(expr, { currentDate: now, iterator: true });
const result: Date[] = [];
for (let i = 0; i < times; i++) {
const next = cron.next();
result.push(next.value.toDate());
}
return result;
} catch {
return [];
}
};