From 63ec5b5519c760a3330569c0da6dac157302a330 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Thu, 31 Oct 2024 15:14:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E5=85=A8=E6=96=B0?= =?UTF-8?q?=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/plugin/cert-plugin/convert.ts | 23 ++-- packages/ui/certd-client/package.json | 2 + .../views/certd/pipeline/certd-form/crud.tsx | 3 +- .../pipeline/component/trigger-form/index.vue | 5 +- .../src/views/framework/home/dashboard/api.ts | 8 ++ .../framework/home/dashboard/charts/d.ts | 4 + .../home/dashboard/charts/day-count.vue | 104 ++++++++++++++++ .../home/dashboard/charts/expiring-list.vue | 51 ++++++++ .../home/dashboard/charts/pie-count.vue | 74 ++++++++++++ .../views/framework/home/dashboard/index.vue | 113 +++++++++++++----- .../home/dashboard/statistic-card.vue | 14 ++- .../dashboard/statistic-controller.ts | 68 +++++++++++ .../pipeline/service/history-service.ts | 21 +++- .../pipeline/service/pipeline-service.ts | 55 ++++++++- 14 files changed, 492 insertions(+), 53 deletions(-) create mode 100644 packages/ui/certd-client/src/views/framework/home/dashboard/api.ts create mode 100644 packages/ui/certd-client/src/views/framework/home/dashboard/charts/d.ts create mode 100644 packages/ui/certd-client/src/views/framework/home/dashboard/charts/day-count.vue create mode 100644 packages/ui/certd-client/src/views/framework/home/dashboard/charts/expiring-list.vue create mode 100644 packages/ui/certd-client/src/views/framework/home/dashboard/charts/pie-count.vue create mode 100644 packages/ui/certd-server/src/controller/dashboard/statistic-controller.ts diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts index e320a975..1861e875 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/convert.ts @@ -30,7 +30,7 @@ export class CertConverter { // 转der derPath = await this.convertDer(ctx); - //jksPath = await this.convertJks(ctx, pfxPath, opts.pfxPassword); + //jksPath = await this.convertJks(ctx, opts.pfxPassword); }; await certReader.readCertFile({ logger: this.logger, handle }); @@ -64,7 +64,7 @@ export class CertConverter { if (pfxPassword) { passwordArg = `-password pass:${pfxPassword}`; } - // 兼容server 2016 + // 兼容server 2016,旧版本不能用sha256 const oldPfxCmd = `openssl pkcs12 -macalg SHA1 -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -export -out ${pfxPath} -inkey ${tmpKeyPath} -in ${tmpCrtPath} ${passwordArg}`; // const newPfx = `openssl pkcs12 -export -out ${pfxPath} -inkey ${tmpKeyPath} -in ${tmpCrtPath} ${passwordArg}`; await this.exec(oldPfxCmd); @@ -98,18 +98,18 @@ export class CertConverter { // this.saveFile(filename, fileBuffer); } - async convertJks(opts: CertReaderHandleContext, pfxPath: string, pfxPassword = "") { + async convertJks(opts: CertReaderHandleContext, pfxPassword = "") { const jksPassword = pfxPassword || "123456"; try { const randomStr = Math.floor(Math.random() * 1000000) + ""; - // const p12Path = path.join(os.tmpdir(), "/certd/tmp/", randomStr + `_cert.p12`); - // const { tmpCrtPath, tmpKeyPath } = opts; - // let passwordArg = "-passout pass:"; - // if (pfxPassword) { - // passwordArg = `-password pass:${pfxPassword}`; - // } - // await this.exec(`openssl pkcs12 -export -in ${tmpCrtPath} -inkey ${tmpKeyPath} -out ${p12Path} -name certd ${passwordArg}`); + const p12Path = path.join(os.tmpdir(), "/certd/tmp/", randomStr + `_cert.p12`); + const { tmpCrtPath, tmpKeyPath } = opts; + let passwordArg = "-passout pass:"; + if (pfxPassword) { + passwordArg = `-password pass:${pfxPassword}`; + } + await this.exec(`openssl pkcs12 -export -in ${tmpCrtPath} -inkey ${tmpKeyPath} -out ${p12Path} -name certd ${passwordArg}`); const jksPath = path.join(os.tmpdir(), "/certd/tmp/", randomStr + `_cert.jks`); const dir = path.dirname(jksPath); @@ -117,8 +117,9 @@ export class CertConverter { fs.mkdirSync(dir, { recursive: true }); } await this.exec( - `keytool -importkeystore -srckeystore ${pfxPath} -srcstoretype PKCS12 -srcstorepass "${pfxPassword}" -destkeystore ${jksPath} -deststoretype PKCS12 -deststorepass "${jksPassword}" ` + `keytool -importkeystore -srckeystore ${p12Path} -srcstoretype PKCS12 -srcstorepass "${pfxPassword}" -destkeystore ${jksPath} -deststoretype PKCS12 -deststorepass "${jksPassword}" ` ); + fs.unlinkSync(p12Path); return jksPath; } catch (e) { this.logger.error("转换jks失败", e); diff --git a/packages/ui/certd-client/package.json b/packages/ui/certd-client/package.json index 2370e660..a8350352 100644 --- a/packages/ui/certd-client/package.json +++ b/packages/ui/certd-client/package.json @@ -45,6 +45,7 @@ "cron-parser": "^4.9.0", "cropperjs": "^1.6.1", "dayjs": "^1.11.10", + "echarts": "^5.5.1", "highlight.js": "^11.9.0", "humanize-duration": "^3.27.3", "lodash-es": "^4.17.21", @@ -58,6 +59,7 @@ "sortablejs": "^1.15.2", "vue": "^3.4.21", "vue-cropperjs": "^5.0.0", + "vue-echarts": "^7.0.3", "vue-i18n": "^9.10.2", "vue-router": "^4.3.0", "vuedraggable": "^4.1.0" diff --git a/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx index f4523a07..f294bb12 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/certd-form/crud.tsx @@ -98,8 +98,7 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre vModel: "modelValue", placeholder: "0 0 4 * * *" }, - helper: - "点击上面的按钮,选择每天几点几分定时执行,后面的分秒都要选择0。\n例如:0 0 4 * * *,每天凌晨4点0分0秒触发\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行", + helper: "点击上面的按钮,选择每天几点几分定时执行,后面的分秒都要选择0。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行", order: 100 } }, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/trigger-form/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/trigger-form/index.vue index d4909738..b6dacaf3 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/trigger-form/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/trigger-form/index.vue @@ -3,7 +3,7 @@ v-model:open="triggerDrawerVisible" placement="right" :closable="true" - width="600px" + width="650px" class="pi-trigger-form" @after-open-change="triggerDrawerOnAfterVisibleChange" > @@ -58,8 +58,7 @@ name: 'cron-editor', vModel: 'modelValue' }, - helper: - '点击上面的按钮,选择每天几点几分定时执行,后面的分秒都要选择0。\n例如:0 0 4 * * *,每天凌晨4点0分0秒触发\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行', + helper: '点击上面的按钮,选择每天几点几分定时执行,后面的分秒都要选择0。\n建议设置为每天触发一次,证书未到期之前任务会跳过,不会重复执行', rules: [{ required: true, message: '此项必填' }] }" /> diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/api.ts b/packages/ui/certd-client/src/views/framework/home/dashboard/api.ts new file mode 100644 index 00000000..72ec90b5 --- /dev/null +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/api.ts @@ -0,0 +1,8 @@ +import { request } from "/@/api/service"; + +export async function GetStatisticCount() { + return await request({ + url: "/statistic/count", + method: "POST" + }); +} diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/charts/d.ts b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/d.ts new file mode 100644 index 00000000..18d71221 --- /dev/null +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/d.ts @@ -0,0 +1,4 @@ +export type ChartItem = { + name: string; + value: number; +}; diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/charts/day-count.vue b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/day-count.vue new file mode 100644 index 00000000..50e4ae63 --- /dev/null +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/day-count.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/charts/expiring-list.vue b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/expiring-list.vue new file mode 100644 index 00000000..18db458b --- /dev/null +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/expiring-list.vue @@ -0,0 +1,51 @@ + + + + diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/charts/pie-count.vue b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/pie-count.vue new file mode 100644 index 00000000..a7b30ebd --- /dev/null +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/charts/pie-count.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue index 79474a70..5a525408 100644 --- a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue @@ -2,15 +2,19 @@
- + + + {{ userInfo.username }} +
- 您好,{{ userStore?.userInfo?.nickName || userStore?.userInfo?.username }}。 欢迎使用 {{ siteInfo.title }} + 您好,{{ userInfo.nickName || userInfo.username }}。 欢迎使用 {{ siteInfo.title }}
{{ now }} + v{{ version }}
@@ -18,7 +22,7 @@
- 仅需3步,让你的证书永不过期 @@ -28,7 +32,7 @@