From 8ed16b3ea2dfe847357863a0bfa614e4fa5fc041 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 11 Sep 2024 16:49:50 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BB=BB=E5=8A=A1=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/pipeline/src/core/executor.ts | 11 ++++++-- .../core/pipeline/src/core/run-history.ts | 11 ++++++++ packages/core/pipeline/src/dt/pipeline.ts | 2 ++ .../ui/certd-client/src/style/common.less | 9 +++++++ .../pipeline/component/task-form/index.vue | 3 ++- .../views/certd/pipeline/pipeline/index.vue | 27 +++++++++++++------ .../pipeline/pipeline/utils/util.status.ts | 6 +++++ packages/ui/certd-server/package.json | 4 ++- 8 files changed, 61 insertions(+), 12 deletions(-) diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index 619c69338..cabb9c2ad 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -104,11 +104,18 @@ export class Executor { async runWithHistory(runnable: Runnable, runnableType: string, run: () => Promise) { runnable.runnableType = runnableType; + this.runtime.start(runnable); - // const timeout = runnable.timeout ?? 20 * 60 * 1000; - await this.onChanged(this.runtime); try { + if (runnable.disabled) { + //该任务被禁用 + this.runtime.disabled(runnable); + return ResultType.disabled; + } + + await this.onChanged(this.runtime); + if (this.abort.signal.aborted) { this.runtime.cancel(runnable); return ResultType.canceled; diff --git a/packages/core/pipeline/src/core/run-history.ts b/packages/core/pipeline/src/core/run-history.ts index 641b18712..e6ee250a1 100644 --- a/packages/core/pipeline/src/core/run-history.ts +++ b/packages/core/pipeline/src/core/run-history.ts @@ -74,6 +74,17 @@ export class RunHistory { this.log(runnable, `跳过`); } + disabled(runnable: Runnable) { + const now = new Date().getTime(); + const status = runnable.status; + _.merge(status, { + status: "canceled", + endTime: now, + result: "disabled", + }); + this.log(runnable, `禁用`); + } + error(runnable: Runnable, e: Error) { const now = new Date().getTime(); const status = runnable.status; diff --git a/packages/core/pipeline/src/dt/pipeline.ts b/packages/core/pipeline/src/dt/pipeline.ts index 90b746490..c95323279 100644 --- a/packages/core/pipeline/src/dt/pipeline.ts +++ b/packages/core/pipeline/src/dt/pipeline.ts @@ -70,6 +70,7 @@ export type Runnable = { default?: { [key: string]: any; }; + disabled?: boolean; }; export type EmailOptions = { @@ -108,6 +109,7 @@ export enum ResultType { error = "error", canceled = "canceled", skip = "skip", + disabled = "disabled", none = "none", } diff --git a/packages/ui/certd-client/src/style/common.less b/packages/ui/certd-client/src/style/common.less index b93c3540f..edf517d65 100644 --- a/packages/ui/certd-client/src/style/common.less +++ b/packages/ui/certd-client/src/style/common.less @@ -184,3 +184,12 @@ h1, h2, h3, h4, h5, h6 { .need-plus { color: #c5913f !important; } + + +.disabled{ + color: #c7c7c7; +} +.deleted{ + //删除线 + text-decoration: line-through; +} \ No newline at end of file diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue index 352cebe45..4d20cf0e9 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue @@ -48,9 +48,10 @@
-

{{ element.title }}

+

{{ element.title }}

+ {{ element.disabled ? "启用" : "禁用" }} 编辑 复制 删除 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 072396f8f..c523ebcd7 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 @@ -94,7 +94,9 @@