From ea775adae18d57a04470cfba6b9460d761d74035 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 2 Sep 2024 18:36:12 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=94=AF=E6=8C=81=E5=B7=B2=E8=B7=B3?= =?UTF-8?q?=E8=BF=87=E7=9A=84=E6=AD=A5=E9=AA=A4=E9=87=8D=E6=96=B0=E8=BF=90?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/pipeline/src/core/executor.ts | 10 +++++++ .../core/pipeline/src/core/run-history.ts | 8 +++++ .../ui/certd-client/src/style/common.less | 9 ++++++ .../src/views/certd/pipeline/api.ts | 4 +-- .../src/views/certd/pipeline/crud.tsx | 27 ++++++++++++++--- .../src/views/certd/pipeline/detail.vue | 6 ++-- .../component/history-timeline-item.vue | 2 +- .../pipeline/component/status-show.vue | 2 +- .../views/certd/pipeline/pipeline/index.vue | 26 +++++++++++----- .../src/views/certd/pipeline/pipeline/type.ts | 2 +- .../controller/pipeline-controller.ts | 4 +-- .../pipeline/service/pipeline-service.ts | 10 +++++-- .../plugin-aliyun/access/aliyun-access.ts | 30 ------------------- .../src/plugins/plugin-aliyun/access/index.ts | 1 - .../dns-provider/aliyun-dns-provider.ts | 21 +++---------- .../src/plugins/plugin-aliyun/index.ts | 1 - .../plugin/deploy-to-ack-ingress/index.ts | 12 ++++---- .../plugin/deploy-to-cdn/index.ts | 14 ++++----- .../plugin/upload-to-aliyun/index.ts | 2 +- .../plugin/host-shell-execute/index.ts | 1 + 20 files changed, 105 insertions(+), 87 deletions(-) delete mode 100644 packages/ui/certd-server/src/plugins/plugin-aliyun/access/aliyun-access.ts delete mode 100644 packages/ui/certd-server/src/plugins/plugin-aliyun/access/index.ts diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index daba79ec..1825fb08 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -36,6 +36,8 @@ export class Executor { options: ExecutorOptions; abort: AbortController = new AbortController(); + _inited = false; + onChanged: (history: RunHistory) => Promise; constructor(options: ExecutorOptions) { this.options = options; @@ -50,6 +52,10 @@ export class Executor { } async init() { + if (this._inited) { + return; + } + this._inited = true; const lastRuntime = await this.pipelineContext.getObj(`lastRuntime`); this.lastRuntime = lastRuntime; this.lastStatusMap = new RunnableCollection(lastRuntime?.pipeline); @@ -315,4 +321,8 @@ export class Executor { } } } + + clearLastStatus(stepId: string) { + this.lastStatusMap.clearById(stepId); + } } diff --git a/packages/core/pipeline/src/core/run-history.ts b/packages/core/pipeline/src/core/run-history.ts index a3f63482..df26cbef 100644 --- a/packages/core/pipeline/src/core/run-history.ts +++ b/packages/core/pipeline/src/core/run-history.ts @@ -166,6 +166,14 @@ export class RunnableCollection { }); } + clearById(id: string) { + const runnable = this.collection[id]; + if (runnable?.status) { + runnable.status.status = ResultType.none; + runnable.status.result = ResultType.none; + } + } + add(runnable: Runnable) { this.collection[runnable.id] = runnable; } diff --git a/packages/ui/certd-client/src/style/common.less b/packages/ui/certd-client/src/style/common.less index 2f78e516..fc950097 100644 --- a/packages/ui/certd-client/src/style/common.less +++ b/packages/ui/certd-client/src/style/common.less @@ -45,6 +45,10 @@ h1, h2, h3, h4, h5, h6 { vertical-align: 0 !important; } +.pointer{ + cursor: pointer; +} + .flex-center{ display: flex; justify-content: center; @@ -122,3 +126,8 @@ h1, h2, h3, h4, h5, h6 { padding-bottom:3px; border-bottom: 1px solid #dedede; } + + +.color-blue{ + color: #1890ff; +} \ No newline at end of file diff --git a/packages/ui/certd-client/src/views/certd/pipeline/api.ts b/packages/ui/certd-client/src/views/certd/pipeline/api.ts index ffc64ffd..e10c2433 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/api.ts +++ b/packages/ui/certd-client/src/views/certd/pipeline/api.ts @@ -59,11 +59,11 @@ export function Save(pipelineEntity: any) { }); } -export function Trigger(id: any) { +export function Trigger(id: any, stepId?: string) { return request({ url: apiPrefix + "/trigger", method: "post", - params: { id } + params: { id, stepId } }); } 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 c97ec8b0..6488839e 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -2,7 +2,7 @@ import * as api from "./api"; import { useI18n } from "vue-i18n"; import { computed, ref } from "vue"; import { useRouter } from "vue-router"; -import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; +import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes, useUi } from "@fast-crud/fast-crud"; import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status"; import { nanoid } from "nanoid"; import { message, Modal } from "ant-design-vue"; @@ -29,9 +29,16 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp }; const addRequest = async ({ form }: AddReq) => { - form.content = JSON.stringify({ - title: form.title - }); + if (form.content == null) { + form.content = JSON.stringify({ + title: form.title + }); + } else { + const content = JSON.parse(form.content); + content.title = form.title; + form.content = JSON.stringify(content); + } + const res = await api.AddObj(form); lastResRef.value = res; return res; @@ -136,6 +143,18 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp router.push({ path: "/certd/pipeline/detail", query: { id: row.id, editMode: "false" } }); } }, + copy: { + click: async (context) => { + const { ui } = useUi(); + // @ts-ignore + const row = context[ui.tableColumn.row]; + row.title = row.title + "_copy"; + await crudExpose.openCopy({ + row: row, + index: context.index + }); + } + }, config: { order: 1, title: null, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue index 1512fd4a..a9df38a2 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/detail.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/detail.vue @@ -54,9 +54,9 @@ export default defineComponent({ content: JSON.stringify(pipelineConfig) }); }, - async doTrigger(options: { pipelineId: number }) { - const { pipelineId } = options; - await api.Trigger(pipelineId); + async doTrigger(options: { pipelineId: number; stepId?: string }) { + const { pipelineId, stepId } = options; + await api.Trigger(pipelineId, stepId); } }; diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue index 9e2fdfab..d9dcf5a4 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/history-timeline-item.vue @@ -5,7 +5,7 @@

- + {{ status.label }} 当前 diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue index 7d9e1cd3..140979c2 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/status-show.vue @@ -1,5 +1,5 @@