From a3cabd5f36ed41225ad418098596e9b2c44e31a1 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sun, 15 Feb 2026 14:19:16 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=88=97=E8=A1=A8=E4=B8=AD=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=8B=E6=AC=A1=E6=89=A7=E8=A1=8C=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/cron-editor/utils.ts | 2 +- .../src/locales/langs/en-US/certd.ts | 1 + .../src/locales/langs/zh-CN/certd.ts | 1 + .../src/views/certd/pipeline/crud.tsx | 13 +++++++ .../views/certd/pipeline/pipeline/index.vue | 1 + .../src/modules/pipeline/entity/pipeline.ts | 3 ++ .../pipeline/service/pipeline-service.ts | 39 +++++++++++++++++-- 7 files changed, 55 insertions(+), 5 deletions(-) diff --git a/packages/ui/certd-client/src/components/cron-editor/utils.ts b/packages/ui/certd-client/src/components/cron-editor/utils.ts index 7a2be77e0..8b566c3d8 100644 --- a/packages/ui/certd-client/src/components/cron-editor/utils.ts +++ b/packages/ui/certd-client/src/components/cron-editor/utils.ts @@ -9,7 +9,7 @@ export function getCronNextTimes(cron: string, count: number = 1) { const interval = parser.parseExpression(cron); for (let i = 0; i < count; i++) { const next = interval.next().getTime(); - nextTimes.push(dayjs(next).format("YYYY-MM-DD HH:mm:ss")); + nextTimes.push(dayjs(next).valueOf()); } return nextTimes; } diff --git a/packages/ui/certd-client/src/locales/langs/en-US/certd.ts b/packages/ui/certd-client/src/locales/langs/en-US/certd.ts index 161ea6801..1dae3f4bc 100644 --- a/packages/ui/certd-client/src/locales/langs/en-US/certd.ts +++ b/packages/ui/certd-client/src/locales/langs/en-US/certd.ts @@ -160,6 +160,7 @@ export default { updateTime: "Update Time", triggerType: "Trigger Type", pipelineId: "Pipeline Id", + nextRunTime: "Next Run Time", }, pi: { diff --git a/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts b/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts index af5ee3a79..8141a89f0 100644 --- a/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts +++ b/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts @@ -167,6 +167,7 @@ export default { updateTime: "更新时间", triggerType: "触发类型", pipelineId: "流水线Id", + nextRunTime: "下次运行时间", }, pi: { validTime: "流水线有效期", diff --git a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx index 812857aaf..2ac300a1a 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -352,6 +352,7 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply column: { align: "center", width: 120, + show: false, sorter: true, }, form: { @@ -464,6 +465,18 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply align: "center", }, }, + nextRunTime: { + title: t("certd.fields.nextRunTime"), + type: "datetime", + form: { + show: false, + }, + column: { + sorter: true, + width: 150, + align: "center", + }, + }, disabled: { title: t("certd.fields.enabled"), type: "dict-switch", diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue index a2eadc6f3..59f973726 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue @@ -885,6 +885,7 @@ export default defineComponent({ saveLoading.value = false; } }; + const edit = () => { pipeline.value = cloneDeep(currentPipeline.value); currentHistory.value = null; diff --git a/packages/ui/certd-server/src/modules/pipeline/entity/pipeline.ts b/packages/ui/certd-server/src/modules/pipeline/entity/pipeline.ts index 4f1d0d4be..1f36ee639 100644 --- a/packages/ui/certd-server/src/modules/pipeline/entity/pipeline.ts +++ b/packages/ui/certd-server/src/modules/pipeline/entity/pipeline.ts @@ -58,6 +58,8 @@ export class PipelineEntity { // 变量 lastVars: any; + nextRunTime: number; + @Column({name: 'order', comment: '排序', nullable: true,}) order: number; @@ -69,4 +71,5 @@ export class PipelineEntity { default: () => 'CURRENT_TIMESTAMP', }) updateTime: Date; + } diff --git a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts index 0e8d3f2c2..2e570ab14 100644 --- a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts +++ b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts @@ -48,7 +48,7 @@ import { TaskServiceBuilder } from "./getter/task-service-getter.js"; import { nanoid } from "nanoid"; import { set } from "lodash-es"; import { executorQueue } from "@certd/lib-server"; - +import parser from "cron-parser"; const runningTasks: Map = new Map(); @@ -141,16 +141,47 @@ export class PipelineService extends BaseService { } // @ts-ignore item.stepCount = stepCount; - if(item.triggerCount == 0 ){ + if (item.triggerCount == 0) { item.triggerCount = pipeline.triggers?.length; } - + + //获取下次执行时间 + if (pipeline.triggers?.length > 0) { + const triggers = pipeline.triggers.filter((item) => item.type === 'timer'); + if (triggers && triggers.length > 0) { + let nextTimes: any = []; + for (const item of triggers) { + if (!item.props?.cron) { + continue; + } + const ret = this.getCronNextTimes(item.props?.cron, 1); + nextTimes.push(...ret); + } + item.nextRunTime = nextTimes[0] + } + + } + delete item.content; } return result; } + getCronNextTimes(cron: string, count: number = 1) { + if (cron == null) { + return []; + } + const nextTimes = []; + const interval = parser.parseExpression(cron); + for (let i = 0; i < count; i++) { + const next = interval.next().getTime(); + nextTimes.push(dayjs(next).format("YYYY-MM-DD HH:mm:ss")); + } + return nextTimes; + } + + private async fillLastVars(records: PipelineEntity[]) { const pipelineIds: number[] = []; const recordMap = {}; @@ -220,7 +251,7 @@ export class PipelineService extends BaseService { //修改 old = await this.info(bean.id); } - if (!old || !old.webhookKey ) { + if (!old || !old.webhookKey) { bean.webhookKey = await this.genWebhookKey(); }