From 2aefca3813a19dd28db3c55d963f17eb870e14bc Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 4 Dec 2024 12:36:17 +0800 Subject: [PATCH] chore: --- packages/core/pipeline/src/core/executor.ts | 14 ++++++++++---- .../src/views/certd/notification/api.ts | 9 ++++++++- .../src/views/certd/notification/crud.tsx | 4 ++-- .../src/views/certd/notification/index.vue | 4 ++-- .../notification-selector/index.vue | 4 ++-- .../notification-selector/modal/index.vue | 4 ++-- .../views/certd/pipeline/certd-form/crud.tsx | 7 +++---- .../views/certd/pipeline/certd-form/index.vue | 19 ++++++++++++++++--- .../src/views/certd/pipeline/crud.tsx | 17 +++++++++++++---- .../pipeline/notification-controller.ts | 6 ++++++ .../pipeline/service/notification-service.ts | 18 ++++++++++++++++++ .../pipeline/service/pipeline-service.ts | 13 ++++++++++--- 12 files changed, 92 insertions(+), 27 deletions(-) diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index 79f066e2..d67d9ece 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -11,6 +11,10 @@ import { ICnameProxyService, IEmailService, IPluginConfigService, IUrlService } import { FileStore } from "./file-store.js"; import { cloneDeep, forEach, merge } from "lodash-es"; import { INotificationService, NotificationBody, NotificationContext, notificationRegistry } from "../notification/index.js"; +export type SysInfo = { + //系统标题 + title?: string; +}; export type ExecutorOptions = { pipeline: Pipeline; @@ -25,6 +29,7 @@ export type ExecutorOptions = { fileRootDir?: string; user: UserInfo; baseURL?: string; + sysInfo?: SysInfo; }; export class Executor { @@ -368,17 +373,18 @@ export class Executor { let subject = ""; let content = ""; const errorMessage = error?.message; + const sysTitle = this.options.sysInfo?.title || "Certd"; if (when === "start") { - subject = `【Certd】开始执行,${this.pipeline.title}【${this.pipeline.id}】`; + subject = `【${sysTitle}】开始执行,${this.pipeline.title}【${this.pipeline.id}】`; content = `流水线ID:${this.pipeline.id},运行ID:${this.runtime.id}`; } else if (when === "success") { - subject = `【Certd】执行成功,${this.pipeline.title}【${this.pipeline.id}】`; + subject = `【${sysTitle}】执行成功,${this.pipeline.title}【${this.pipeline.id}】`; content = `流水线ID:${this.pipeline.id},运行ID:${this.runtime.id}`; } else if (when === "turnToSuccess") { - subject = `【Certd】执行成功(失败转成功),${this.pipeline.title}【${this.pipeline.id}】`; + subject = `【${sysTitle}】执行成功(失败转成功),${this.pipeline.title}【${this.pipeline.id}】`; content = `流水线ID:${this.pipeline.id},运行ID:${this.runtime.id}`; } else if (when === "error") { - subject = `【Certd】执行失败,${this.pipeline.title}【${this.pipeline.id}】`; + subject = `【${sysTitle}】执行失败,${this.pipeline.title}【${this.pipeline.id}】`; content = `流水线ID:${this.pipeline.id},运行ID:${this.runtime.id}\n错误详情:${error.message}`; } else { return; diff --git a/packages/ui/certd-client/src/views/certd/notification/api.ts b/packages/ui/certd-client/src/views/certd/notification/api.ts index 459b07e9..9544440b 100644 --- a/packages/ui/certd-client/src/views/certd/notification/api.ts +++ b/packages/ui/certd-client/src/views/certd/notification/api.ts @@ -1,6 +1,6 @@ import { request } from "/src/api/service"; -export function createApi() { +export function createNotificationApi() { const apiPrefix = "/pi/notification"; return { async GetList(query: any) { @@ -94,6 +94,13 @@ export function createApi() { method: "post", params: { type } }); + }, + async GetOrCreateDefault(param: { email: any }) { + return await request({ + url: apiPrefix + "/getOrCreateDefault", + method: "post", + data: param + }); } }; } diff --git a/packages/ui/certd-client/src/views/certd/notification/crud.tsx b/packages/ui/certd-client/src/views/certd/notification/crud.tsx index 8e7b615b..ae2d1d27 100644 --- a/packages/ui/certd-client/src/views/certd/notification/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/notification/crud.tsx @@ -1,8 +1,8 @@ import { ref } from "vue"; import { getCommonColumnDefine } from "./common"; import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; -import { createApi } from "/@/views/certd/notification/api"; -const api = createApi(); +import { createNotificationApi } from "/@/views/certd/notification/api"; +const api = createNotificationApi(); export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const pageRequest = async (query: UserPageQuery): Promise => { return await api.GetList(query); diff --git a/packages/ui/certd-client/src/views/certd/notification/index.vue b/packages/ui/certd-client/src/views/certd/notification/index.vue index a0b8e6ec..64ff6182 100644 --- a/packages/ui/certd-client/src/views/certd/notification/index.vue +++ b/packages/ui/certd-client/src/views/certd/notification/index.vue @@ -14,12 +14,12 @@ import { defineComponent, onActivated, onMounted } from "vue"; import { useFs } from "@fast-crud/fast-crud"; import createCrudOptions from "./crud"; -import { createApi } from "./api"; +import { createNotificationApi } from "./api"; export default defineComponent({ name: "NotificationManager", setup() { - const api = createApi(); + const api = createNotificationApi(); const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api } }); // 页面打开后获取列表数据 diff --git a/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue b/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue index 7d9d02e1..f6297f5c 100644 --- a/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue +++ b/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue @@ -41,7 +41,7 @@