From 64a350364d820725b5e69d22ac2416809092f97d Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sat, 25 Apr 2026 02:29:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF=E6=9C=AA=E7=BC=96=E8=BE=91=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E4=B9=9F=E6=8F=90=E7=A4=BA=E6=9C=AA=E4=BF=9D=E5=AD=98=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/certd/pipeline/pipeline/index.vue | 2 +- .../src/views/certd/pipeline/template/use.tsx | 81 ++++++++++++++++--- 2 files changed, 71 insertions(+), 12 deletions(-) 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 cca147c3c..7486c97d9 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 @@ -374,7 +374,7 @@ export default defineComponent({ setup(props, ctx) { onBeforeRouteLeave((to, from) => { const newPipelineStr = JSON.stringify(pipeline.value || {}); - if (pipelineOriginStr.value && pipelineOriginStr.value !== newPipelineStr) { + if (props.editMode && pipelineOriginStr.value && pipelineOriginStr.value !== newPipelineStr) { const answer = window.confirm("流水线还未保存,确定要离开吗?"); if (!answer) { return false; // 返回 false 即可阻止本次路由跳转 diff --git a/packages/ui/certd-client/src/views/certd/pipeline/template/use.tsx b/packages/ui/certd-client/src/views/certd/pipeline/template/use.tsx index a781bbb3a..c2157f90f 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/template/use.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/template/use.tsx @@ -1,4 +1,4 @@ -import { dict, useFormWrapper } from "@fast-crud/fast-crud"; +import { compute, dict, useFormWrapper } from "@fast-crud/fast-crud"; import { checkPipelineLimit, eachSteps } from "/@/views/certd/pipeline/utils"; import { templateApi } from "/@/views/certd/pipeline/template/api"; import TemplateForm from "./form.vue"; @@ -7,6 +7,7 @@ import GroupSelector from "/@/views/certd/pipeline/group/group-selector.vue"; import { ref } from "vue"; import { fillPipelineByDefaultForm } from "/@/views/certd/pipeline/certd-form/use"; import { cloneDeep } from "lodash-es"; +import { useI18n } from "vue-i18n"; export function createExtraColumns() { const groupDictRef = dict({ @@ -14,24 +15,82 @@ export function createExtraColumns() { value: "id", label: "name", }); + const { t } = useI18n(); const randomHour = Math.floor(Math.random() * 6); const randomMin = Math.floor(Math.random() * 60); return { - triggerCron: { - title: "定时触发", - type: "text", + // triggerCron: { + // title: "定时触发", + // type: "text", + // form: { + // value: `0 ${randomMin} ${randomHour} * * *`, + // component: { + // name: "cron-editor", + // vModel: "modelValue", + // placeholder: "0 0 4 * * *", + // }, + // col: { + // span: 24, + // }, + // helper: "点击上面的按钮,选择每天几点定时执行。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行", + // order: 100, + // }, + // }, + + random: { + title: "定时类型", + form: { + value: true, + helper: "是否给流水线随机设置一个时间", + show: compute(({ form }) => { + return form.clear !== true; + }), + component: { + name: "fs-dict-switch", + vModel: "checked", + dict: dict({ + data: [ + { + label: "随机时间", + value: true, + }, + { + label: "固定时间", + value: false, + }, + ], + }), + }, + }, + }, + randomRange: { + title: "随机时间范围", + form: { + value: ["00:00:00", "08:00:00"], + helper: "随机时间范围,单位秒", + component: { + // + name: "a-time-range-picker", + vModel: "value", + valueFormat: "HH:mm:ss", + }, + show: compute(({ form }) => { + return form.clear !== true && form.random === true; + }), + rules: [{ required: true, message: "请选择随机时间范围" }], + }, + }, + triggerCron: { + title: t("certd.schedule"), form: { - value: `0 ${randomMin} ${randomHour} * * *`, component: { name: "cron-editor", vModel: "modelValue", - placeholder: "0 0 4 * * *", }, - col: { - span: 24, - }, - helper: "点击上面的按钮,选择每天几点定时执行。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行", - order: 100, + show: compute(({ form }) => { + return form.clear !== true && form?.random !== true; + }), + rules: [{ required: true, message: t("certd.selectCron") }], }, }, notification: {