From 425bba67c539b734e2a85a83a4f9ecc9b2434fb4 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Fri, 21 Mar 2025 01:02:57 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B5=81=E6=B0=B4=E7=BA=BF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E4=BC=A0=E8=AF=81=E4=B9=A6=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/pipeline/src/plugin/api.ts | 8 ++ .../src/plugin/cert-plugin/custom/index.ts | 43 +++++++++ packages/plugins/plugin-lib/src/ssh/ssh.ts | 12 ++- .../ui/certd-client/src/components/index.ts | 2 + .../certd-client/src/components/pem-input.vue | 59 +++++++++++++ .../src/components/plugins/index.ts | 2 +- .../src/components/plugins/lib/index.ts | 4 +- .../src/views/certd/monitor/cert/crud.tsx | 19 +--- .../views/certd/pipeline/certd-form/use.ts | 1 - .../src/views/certd/pipeline/crud.tsx | 31 +++++++ .../component/shortcut/task-shortcut.vue | 88 +++++++++++++++++++ .../component/shortcut/task-shortcuts.vue | 50 +++++++++++ .../views/certd/pipeline/pipeline/index.vue | 66 ++++++++------ .../monitor/service/cert-upload-service.ts | 7 +- .../src/modules/pipeline/entity/pipeline.ts | 4 +- 15 files changed, 342 insertions(+), 54 deletions(-) create mode 100644 packages/ui/certd-client/src/components/pem-input.vue create mode 100644 packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcut.vue create mode 100644 packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcuts.vue diff --git a/packages/core/pipeline/src/plugin/api.ts b/packages/core/pipeline/src/plugin/api.ts index 66e95174..30f28c67 100644 --- a/packages/core/pipeline/src/plugin/api.ts +++ b/packages/core/pipeline/src/plugin/api.ts @@ -55,6 +55,14 @@ export type PluginDefine = Registrable & { [key: string]: any; }; + shortcut?: { + [key: string]: { + title: string; + icon: string; + action: string; + form: any; + }; + }; needPlus?: boolean; }; diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/custom/index.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/custom/index.ts index 3a905128..5d9f9372 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/custom/index.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/custom/index.ts @@ -18,6 +18,47 @@ export type { CertInfo }; runStrategy: RunStrategy.AlwaysRun, }, }, + shortcut: { + certUpdate: { + title: "上传证书", + icon: "ph:upload", + action: "onCertUpdate", + form: { + columns: { + crt: { + title: "证书", + type: "textarea", + form: { + component: { + name: "pem-input", + vModel: "modelValue", + textarea: { + row: 4, + }, + }, + rules: [{ required: true, message: "此项必填" }], + col: { span: 24 }, + }, + }, + key: { + title: "私钥", + type: "textarea", + form: { + component: { + name: "pem-input", + vModel: "modelValue", + textarea: { + row: 4, + }, + }, + rules: [{ required: true, message: "此项必填" }], + col: { span: 24 }, + }, + }, + }, + }, + }, + }, }) export class CertApplyUploadPlugin extends CertApplyBaseConvertPlugin { @TaskInput({ @@ -95,6 +136,8 @@ export class CertApplyUploadPlugin extends CertApplyBaseConvertPlugin { await this.output(certReader, true); return; } + + async onCertUpdate(data: any) {} } new CertApplyUploadPlugin(); diff --git a/packages/plugins/plugin-lib/src/ssh/ssh.ts b/packages/plugins/plugin-lib/src/ssh/ssh.ts index 57be88ba..7df2c67d 100644 --- a/packages/plugins/plugin-lib/src/ssh/ssh.ts +++ b/packages/plugins/plugin-lib/src/ssh/ssh.ts @@ -61,7 +61,17 @@ export class AsyncSsh2Client { this.conn = conn; resolve(this.conn); }) - .connect(this.connConf); + .connect({ + ...this.connConf, + algorithms: { + kex: [ + "ecdh-sha2-nistp256", + "diffie-hellman-group1-sha1", + "diffie-hellman-group14-sha1", // 示例:添加服务器支持的旧算法 + "diffie-hellman-group-exchange-sha256", + ], + }, + }); } catch (e) { reject(e); } diff --git a/packages/ui/certd-client/src/components/index.ts b/packages/ui/certd-client/src/components/index.ts index 2954efe4..a2de51da 100644 --- a/packages/ui/certd-client/src/components/index.ts +++ b/packages/ui/certd-client/src/components/index.ts @@ -11,11 +11,13 @@ import LoadingButton from "./loading-button.vue"; import IconSelect from "./icon-select.vue"; import ExpiresTimeText from "./expires-time-text.vue"; import FileInput from "./file-input.vue"; +import PemInput from "./pem-input.vue"; export default { install(app: any) { app.component("PiContainer", PiContainer); app.component("TextEditable", TextEditable); app.component("FileInput", FileInput); + app.component("PemInput", PemInput); app.component("CronLight", CronLight); app.component("CronEditor", CronEditor); diff --git a/packages/ui/certd-client/src/components/pem-input.vue b/packages/ui/certd-client/src/components/pem-input.vue new file mode 100644 index 00000000..544d0f9d --- /dev/null +++ b/packages/ui/certd-client/src/components/pem-input.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/packages/ui/certd-client/src/components/plugins/index.ts b/packages/ui/certd-client/src/components/plugins/index.ts index 7e9af4d8..4142f4c8 100644 --- a/packages/ui/certd-client/src/components/plugins/index.ts +++ b/packages/ui/certd-client/src/components/plugins/index.ts @@ -23,5 +23,5 @@ export default { app.component("RemoteSelect", RemoteSelect); app.component("CertDomainsGetter", CertDomainsGetter); app.component("InputPassword", InputPassword); - } + }, }; diff --git a/packages/ui/certd-client/src/components/plugins/lib/index.ts b/packages/ui/certd-client/src/components/plugins/lib/index.ts index eb6ac83d..922748e2 100644 --- a/packages/ui/certd-client/src/components/plugins/lib/index.ts +++ b/packages/ui/certd-client/src/components/plugins/lib/index.ts @@ -24,9 +24,9 @@ export async function doRequest(req: RequestHandleReq, opts: any = {}) { typeName, action, data, - input + input, }, - ...opts + ...opts, }); return res; } diff --git a/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx b/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx index e6654811..4505b6e0 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/monitor/cert/crud.tsx @@ -1,17 +1,6 @@ // @ts-ignore import { useI18n } from "vue-i18n"; -import { - AddReq, - compute, - CreateCrudOptionsProps, - CreateCrudOptionsRet, - DelReq, - dict, - EditReq, - useFormWrapper, - UserPageQuery, - UserPageRes -} from "@fast-crud/fast-crud"; +import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, useFormWrapper, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; import { certInfoApi } from "./api"; import dayjs from "dayjs"; import { useRouter } from "vue-router"; @@ -166,7 +155,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat show: true, }, rowHandle: { - width: 140, + width: 100, fixed: "right", buttons: { view: { show: false }, @@ -195,9 +184,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }, remove: { order: 10, - show: compute(({ row }) => { - return row.fromType === "upload"; - }), + show: false, }, }, }, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/certd-form/use.ts b/packages/ui/certd-client/src/views/certd/pipeline/certd-form/use.ts index ace5eace..07261c7a 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/certd-form/use.ts +++ b/packages/ui/certd-client/src/views/certd/pipeline/certd-form/use.ts @@ -113,7 +113,6 @@ export function useCertd(certdFormRef: any) { content: JSON.stringify(pipeline), keepHistoryCount: 30, type: "cert", - from: "custom", }); message.success("创建成功,请添加证书部署任务"); router.push({ path: "/certd/pipeline/detail", query: { id, editMode: "true" } }); 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 e0baa49e..cf44c9ca 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -406,6 +406,7 @@ export default function ({ crudExpose, context: { certdFormRef, groupDictRef, se }, column: { sorter: true, + width: 150, align: "center", }, }, @@ -481,6 +482,34 @@ export default function ({ crudExpose, context: { certdFormRef, groupDictRef, se component: { color: "auto", }, + sorter: true, + }, + }, + type: { + title: "类型", + type: "dict-select", + search: { + show: true, + }, + dict: dict({ + data: [ + { value: "cert", label: "证书申请" }, + { value: "cert_upload", label: "证书上传" }, + { value: "custom", label: "自定义" }, + ], + }), + form: { + show: false, + value: "custom", + }, + column: { + sorter: true, + width: 90, + align: "center", + show: true, + component: { + color: "auto", + }, }, }, order: { @@ -505,6 +534,7 @@ export default function ({ crudExpose, context: { certdFormRef, groupDictRef, se column: { width: 130, show: false, + sorter: true, }, }, createTime: { @@ -528,6 +558,7 @@ export default function ({ crudExpose, context: { certdFormRef, groupDictRef, se column: { width: 125, show: false, + sorter: true, }, }, }, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcut.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcut.vue new file mode 100644 index 00000000..644abb6d --- /dev/null +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcut.vue @@ -0,0 +1,88 @@ + + + diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcuts.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcuts.vue new file mode 100644 index 00000000..2d2fd3b2 --- /dev/null +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/shortcut/task-shortcuts.vue @@ -0,0 +1,50 @@ + + 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 1a48804d..97a93e2f 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 @@ -79,7 +79,7 @@ class="task-container" :class="{ 'first-task': taskIndex === 0, - 'validate-error': hasValidateError(task.id) + 'validate-error': hasValidateError(task.id), }" >
@@ -114,6 +114,9 @@
+
+ +
@@ -269,29 +272,30 @@ import PiHistoryTimelineItem from "/@/views/certd/pipeline/pipeline/component/hi import { FsIcon } from "@fast-crud/fast-crud"; import { useSettingStore } from "/@/store/modules/settings"; import { useUserStore } from "/@/store/modules/user"; +import TaskShortcuts from "./component/shortcut/task-shortcuts.vue"; export default defineComponent({ name: "PipelineEdit", // eslint-disable-next-line vue/no-unused-components - components: { FsIcon, PiHistoryTimelineItem, PiTaskForm, PiTriggerForm, PiTaskView, PiStatusShow, PiNotificationForm, VDraggable }, + components: { FsIcon, PiHistoryTimelineItem, PiTaskForm, PiTriggerForm, PiTaskView, PiStatusShow, PiNotificationForm, VDraggable, TaskShortcuts }, props: { pipelineId: { type: [Number, String], - default: 0 + default: 0, }, historyId: { type: [Number, String], - default: 0 + default: 0, }, editMode: { type: Boolean, - default: false + default: false, }, options: { type: Object as PropType, default() { return {}; - } - } + }, + }, }, emits: ["update:modelValue", "update:editMode"], setup(props, ctx) { @@ -341,8 +345,9 @@ export default defineComponent({ histories.value = historyList; if (historyList.length > 0) { + //@ts-ignore if (props.historyId > 0) { - const found = historyList.find((item) => { + const found = historyList.find(item => { //字符串==int return item.id == props.historyId; }); @@ -383,7 +388,7 @@ export default defineComponent({ () => { return props.editMode; }, - (editMode) => { + editMode => { if (editMode) { changeCurrentHistory(); } else if (histories.value.length > 0) { @@ -407,7 +412,7 @@ export default defineComponent({ await loadHistoryList(true); }, { - immediate: true + immediate: true, } ); @@ -438,7 +443,7 @@ export default defineComponent({ }; return { taskViewOpen, - taskViewRef + taskViewRef, }; } @@ -503,7 +508,7 @@ export default defineComponent({ id: nanoid(), title: "新阶段", tasks: [], - status: null + status: null, }; //stage: any, stageIndex: number, onSuccess useTaskRet.taskAdd(stage, stageIndex, () => { @@ -519,7 +524,7 @@ export default defineComponent({ } return { stageAdd, - isLastStage + isLastStage, }; } @@ -551,7 +556,7 @@ export default defineComponent({ return { triggerAdd, triggerEdit, - triggerFormRef + triggerFormRef, }; } @@ -586,7 +591,7 @@ export default defineComponent({ return { notificationAdd, notificationEdit, - notificationFormRef + notificationFormRef, }; } @@ -604,7 +609,7 @@ export default defineComponent({ }, onCancel() { resolve(false); - } + }, }); }); if (!res) { @@ -628,7 +633,7 @@ export default defineComponent({ watchNewHistoryList(); await props.options.doTrigger({ pipelineId: pipeline.value.id, stepId: stepId }); notification.success({ message: "管道已经开始运行" }); - } + }, }); }; @@ -684,10 +689,10 @@ export default defineComponent({ hasError = true; const message = `任务${step.title}的前置输出步骤${paramName}不存在,请重新修改此任务`; addValidateError(task.id, { - message + message, }); addValidateError(step.id, { - message + message, }); errorMessage += message + ";"; } @@ -744,7 +749,7 @@ export default defineComponent({ edit, cancel, saveLoading, - hasValidateError + hasValidateError, }; } @@ -767,7 +772,7 @@ export default defineComponent({ historyView, historyCancel, logsCollapse, - toggleLogsCollapse + toggleLogsCollapse, }; } @@ -829,9 +834,9 @@ export default defineComponent({ ...useActions(), ...useHistory(), ...useNotification(), - ...useScroll() + ...useScroll(), }; - } + }, });