mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
perf: 支持列表展示时固定证书最大天数,有助于列表进度条整齐展示
This commit is contained in:
@@ -46,6 +46,9 @@ export class SysPublicSettings extends BaseSettings {
|
||||
//证书域名添加到监控
|
||||
certDomainAddToMonitorEnabled?: boolean = false;
|
||||
|
||||
// 固定证书有效期天数,0表示不固定
|
||||
fixedCertExpireDays?: number;
|
||||
|
||||
}
|
||||
|
||||
export class SysPrivateSettings extends BaseSettings {
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -757,6 +757,9 @@ export default {
|
||||
pipelineValidTimeEnabledHelper: "是否启用流水线有效期",
|
||||
certDomainAddToMonitorEnabled: "证书域名添加到证书监控",
|
||||
certDomainAddToMonitorEnabledHelper: "创建证书流水线时是否可以选择将域名添加到证书监控",
|
||||
|
||||
fixedCertExpireDays: "固定证书有效期天数",
|
||||
fixedCertExpireDaysHelper: "固定证书有效期天数,有助于列表进度条整齐显示",
|
||||
},
|
||||
},
|
||||
modal: {
|
||||
|
||||
@@ -56,6 +56,9 @@ export type SysPublicSetting = {
|
||||
|
||||
//证书域名添加到监控
|
||||
certDomainAddToMonitorEnabled?: boolean;
|
||||
|
||||
// 固定证书有效期天数,0表示不固定
|
||||
fixedCertExpireDays?: number;
|
||||
};
|
||||
export type SuiteSetting = {
|
||||
enabled?: boolean;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -24,6 +24,14 @@
|
||||
<div class="helper">{{ t("certd.sys.setting.certDomainAddToMonitorEnabledHelper") }}</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item :label="t('certd.sys.setting.fixedCertExpireDays')" :name="['public', 'fixedCertExpireDays']">
|
||||
<div class="flex items-center">
|
||||
<a-input-number v-model:value="formState.public.fixedCertExpireDays" />
|
||||
<vip-button class="ml-5" mode="button"></vip-button>
|
||||
</div>
|
||||
<div class="helper">{{ t("certd.sys.setting.fixedCertExpireDaysHelper") }}</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t("certd.saveButton") }}</a-button>
|
||||
</a-form-item>
|
||||
|
||||
Reference in New Issue
Block a user