From 4a94eab3935c89a63892661d9cf0d0891e54aa81 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Thu, 6 Nov 2025 23:20:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=94=AF=E6=8C=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=97=B6=E5=9B=BA=E5=AE=9A=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=A4=A9=E6=95=B0=EF=BC=8C=E6=9C=89=E5=8A=A9?= =?UTF-8?q?=E4=BA=8E=E5=88=97=E8=A1=A8=E8=BF=9B=E5=BA=A6=E6=9D=A1=E6=95=B4?= =?UTF-8?q?=E9=BD=90=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib-server/src/system/settings/service/models.ts | 3 +++ .../ui/certd-client/src/locales/langs/en-US/certd.ts | 2 ++ .../ui/certd-client/src/locales/langs/zh-CN/certd.ts | 3 +++ .../ui/certd-client/src/store/settings/api.basic.ts | 3 +++ .../src/views/certd/monitor/cert/crud.tsx | 12 +++++++++++- .../src/views/certd/monitor/site/crud.tsx | 10 +++++++++- .../certd-client/src/views/certd/pipeline/crud.tsx | 6 +++++- .../src/views/sys/settings/tabs/pipeline.vue | 8 ++++++++ 8 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/libs/lib-server/src/system/settings/service/models.ts b/packages/libs/lib-server/src/system/settings/service/models.ts index 0419ac0a..5256dbed 100644 --- a/packages/libs/lib-server/src/system/settings/service/models.ts +++ b/packages/libs/lib-server/src/system/settings/service/models.ts @@ -46,6 +46,9 @@ export class SysPublicSettings extends BaseSettings { //证书域名添加到监控 certDomainAddToMonitorEnabled?: boolean = false; + // 固定证书有效期天数,0表示不固定 + fixedCertExpireDays?: number; + } export class SysPrivateSettings extends BaseSettings { diff --git a/packages/ui/certd-client/src/locales/langs/en-US/certd.ts b/packages/ui/certd-client/src/locales/langs/en-US/certd.ts index 255d9e6b..b5bb6376 100644 --- a/packages/ui/certd-client/src/locales/langs/en-US/certd.ts +++ b/packages/ui/certd-client/src/locales/langs/en-US/certd.ts @@ -757,6 +757,8 @@ export default { pipelineValidTimeEnabledHelper: "Whether to enable the valid time of the pipeline", certDomainAddToMonitorEnabled: "Add Domain to Certificate Monitor", certDomainAddToMonitorEnabledHelper: "Whether to add the domain to the certificate monitor", + fixedCertExpireDays: "Fixed Cert Expire Days", + fixedCertExpireDaysHelper: "Fixed cert expiration days, helpful for table list progress bar display", }, }, modal: { diff --git a/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts b/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts index e37f0a8d..f0726d04 100644 --- a/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts +++ b/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts @@ -757,6 +757,9 @@ export default { pipelineValidTimeEnabledHelper: "是否启用流水线有效期", certDomainAddToMonitorEnabled: "证书域名添加到证书监控", certDomainAddToMonitorEnabledHelper: "创建证书流水线时是否可以选择将域名添加到证书监控", + + fixedCertExpireDays: "固定证书有效期天数", + fixedCertExpireDaysHelper: "固定证书有效期天数,有助于列表进度条整齐显示", }, }, modal: { diff --git a/packages/ui/certd-client/src/store/settings/api.basic.ts b/packages/ui/certd-client/src/store/settings/api.basic.ts index 7868cc99..f8c19852 100644 --- a/packages/ui/certd-client/src/store/settings/api.basic.ts +++ b/packages/ui/certd-client/src/store/settings/api.basic.ts @@ -56,6 +56,9 @@ export type SysPublicSetting = { //证书域名添加到监控 certDomainAddToMonitorEnabled?: boolean; + + // 固定证书有效期天数,0表示不固定 + fixedCertExpireDays?: number; }; export type SuiteSetting = { enabled?: boolean; 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 696f36be..1e9e8b69 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 @@ -9,6 +9,7 @@ import { useModal } from "/@/use/use-modal"; import { notification } from "ant-design-vue"; import CertView from "/@/views/certd/pipeline/cert-view.vue"; import { useCertUpload } from "/@/views/certd/pipeline/cert-upload/use"; +import { useSettingStore } from "/@/store/settings"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const { t } = useI18n(); @@ -35,6 +36,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const { openCrudFormDialog } = useFormWrapper(); const router = useRouter(); + const settingStore = useSettingStore(); + const model = useModal(); const viewCert = async (row: any) => { const cert = await api.GetCert(row.id); @@ -224,12 +227,19 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat if (!expiresTime) { return "-"; } + // 申请时间 ps:此处为证书在certd创建的时间而非实际证书申请时间 const applyDate = dayjs(effectiveTime ?? applyTime ?? Date.now()).format("YYYY-MM-DD"); // 失效时间 const expireDate = dayjs(expiresTime).format("YYYY-MM-DD"); // 有效天数 ps:此处证书最小设置为90d - const effectiveDays = Math.max(90, dayjs(expiresTime).diff(applyDate, "day")); + let effectiveDays = Math.max(90, dayjs(expiresTime).diff(applyDate, "day")); + + const fixedCertExpireDays = settingStore.getSysPublic?.fixedCertExpireDays; + if (fixedCertExpireDays && fixedCertExpireDays > 0) { + effectiveDays = fixedCertExpireDays; + } + // 距离失效时间剩余天数 const leftDays = dayjs(expiresTime).diff(dayjs(), "day"); const color = leftDays < 20 ? "red" : "#389e0d"; diff --git a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx index bc1c913b..6a03d079 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx @@ -61,6 +61,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat const selectedRowKeys = ref([]); + const settingStore = useSettingStore(); + const handleBatchDelete = () => { if (selectedRowKeys.value?.length > 0) { Modal.confirm({ @@ -506,7 +508,13 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat // 失效时间 const expireDate = dayjs(expiresTime).format("YYYY-MM-DD"); // 有效天数 ps:此处证书最小设置为90d - const effectiveDays = Math.max(90, dayjs(expiresTime).diff(applyDate, "day")); + let effectiveDays = Math.max(90, dayjs(expiresTime).diff(applyDate, "day")); + + const fixedCertExpireDays = settingStore.getSysPublic?.fixedCertExpireDays; + if (fixedCertExpireDays && fixedCertExpireDays > 0) { + effectiveDays = fixedCertExpireDays; + } + // 距离失效时间剩余天数 const leftDays = dayjs(expiresTime).diff(dayjs(), "day"); const color = leftDays < certValidDays ? "red" : "#389e0d"; 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 de10d481..ee6e50be 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -375,7 +375,11 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys // 失效时间 const expireDate = dayjs(expiresTime).format("YYYY-MM-DD"); // 有效天数 ps:此处证书最小设置为90d - const effectiveDays = Math.max(90, dayjs(expiresTime).diff(applyDate, "day")); + let effectiveDays = Math.max(90, dayjs(expiresTime).diff(applyDate, "day")); + const fixedCertExpireDays = settingStore.sysPublic.fixedCertExpireDays; + if (fixedCertExpireDays && fixedCertExpireDays > 0) { + effectiveDays = fixedCertExpireDays; + } // 距离失效时间剩余天数 const leftDays = dayjs(expiresTime).diff(dayjs(), "day"); const color = leftDays < 20 ? "red" : "#389e0d"; diff --git a/packages/ui/certd-client/src/views/sys/settings/tabs/pipeline.vue b/packages/ui/certd-client/src/views/sys/settings/tabs/pipeline.vue index a9a44383..f1920dc3 100644 --- a/packages/ui/certd-client/src/views/sys/settings/tabs/pipeline.vue +++ b/packages/ui/certd-client/src/views/sys/settings/tabs/pipeline.vue @@ -24,6 +24,14 @@
{{ t("certd.sys.setting.certDomainAddToMonitorEnabledHelper") }}
+ +
+ + +
+
{{ t("certd.sys.setting.fixedCertExpireDaysHelper") }}
+
+ {{ t("certd.saveButton") }}