mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: 证书仓库页面增加到期状态查询条件
This commit is contained in:
@@ -53,6 +53,8 @@ export class SysPublicSettings extends BaseSettings {
|
|||||||
|
|
||||||
//默认到期前更新天数
|
//默认到期前更新天数
|
||||||
defaultCertRenewDays?: number;
|
defaultCertRenewDays?: number;
|
||||||
|
// 即将到期天数
|
||||||
|
defaultWillExpireDays?: number = 15;
|
||||||
|
|
||||||
// 第三方OAuth配置
|
// 第三方OAuth配置
|
||||||
oauthEnabled?: boolean = false;
|
oauthEnabled?: boolean = false;
|
||||||
|
|||||||
@@ -445,6 +445,11 @@ function openUpgrade() {
|
|||||||
<div class="vip-type-vs">
|
<div class="vip-type-vs">
|
||||||
<a-row gutter={20}>{slots}</a-row>
|
<a-row gutter={20}>{slots}</a-row>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="https://certd.docmirror.cn/guide/donate/#相关问题" target="_blank">
|
||||||
|
{t("vip.question")}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
<div class=" w-100 flex-col md:flex-row ">
|
<div class=" w-100 flex-col md:flex-row ">
|
||||||
<span>{t("vip.site_id")}:</span>
|
<span>{t("vip.site_id")}:</span>
|
||||||
|
|||||||
@@ -330,6 +330,11 @@ export default {
|
|||||||
certValidDays: "Certificate Valid Days",
|
certValidDays: "Certificate Valid Days",
|
||||||
certValidDaysHelper: "Number of days before expiration to send a notification",
|
certValidDaysHelper: "Number of days before expiration to send a notification",
|
||||||
},
|
},
|
||||||
|
cert: {
|
||||||
|
expired: "Expired",
|
||||||
|
expiring: "Expiring",
|
||||||
|
noExpired: "Not Expired",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
checkStatus: {
|
checkStatus: {
|
||||||
success: "Success",
|
success: "Success",
|
||||||
|
|||||||
@@ -100,4 +100,5 @@ export default {
|
|||||||
confirm: "Confirm",
|
confirm: "Confirm",
|
||||||
not_effective: "Not effective or duration not sync?",
|
not_effective: "Not effective or duration not sync?",
|
||||||
learn_more: "More privileges",
|
learn_more: "More privileges",
|
||||||
|
question: "More VIP related questions",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -337,6 +337,12 @@ export default {
|
|||||||
certValidDays: "证书到期前天数",
|
certValidDays: "证书到期前天数",
|
||||||
certValidDaysHelper: "证书到期前多少天发送通知",
|
certValidDaysHelper: "证书到期前多少天发送通知",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cert: {
|
||||||
|
expired: "已过期",
|
||||||
|
expiring: "即将过期",
|
||||||
|
noExpired: "未过期",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
checkStatus: {
|
checkStatus: {
|
||||||
success: "成功",
|
success: "成功",
|
||||||
|
|||||||
@@ -99,4 +99,5 @@ export default {
|
|||||||
confirm: "确认",
|
confirm: "确认",
|
||||||
not_effective: "VIP没有生效/时长未同步?",
|
not_effective: "VIP没有生效/时长未同步?",
|
||||||
learn_more: "更多特权(加VIP群等)",
|
learn_more: "更多特权(加VIP群等)",
|
||||||
|
question: "更多VIP相关问题",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ export type SysPublicSetting = {
|
|||||||
|
|
||||||
// 默认到期前更新天数
|
// 默认到期前更新天数
|
||||||
defaultCertRenewDays?: number;
|
defaultCertRenewDays?: number;
|
||||||
|
// 默认即将到期天数
|
||||||
|
defaultWillExpireDays?: number;
|
||||||
|
|
||||||
//证书域名添加到监控
|
//证书域名添加到监控
|
||||||
certDomainAddToMonitorEnabled?: boolean;
|
certDomainAddToMonitorEnabled?: boolean;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useI18n } from "/src/locales";
|
|||||||
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 { certInfoApi } from "./api";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useModal } from "/@/use/use-modal";
|
import { useModal } from "/@/use/use-modal";
|
||||||
import { notification } from "ant-design-vue";
|
import { notification } from "ant-design-vue";
|
||||||
import CertView from "/@/views/certd/pipeline/cert-view.vue";
|
import CertView from "/@/views/certd/pipeline/cert-view.vue";
|
||||||
@@ -57,7 +57,14 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const { openUploadCreateDialog, openUpdateCertDialog } = useCertUpload();
|
const { openUploadCreateDialog } = useCertUpload();
|
||||||
|
|
||||||
|
const DEFAULT_WILL_EXPIRE_DAYS = settingStore.sysPublic.defaultWillExpireDays || settingStore.sysPublic.defaultCertRenewDays || 15;
|
||||||
|
const route = useRoute();
|
||||||
|
const expireStatus = route?.query?.expireStatus as string;
|
||||||
|
const searchInitForm = {
|
||||||
|
expiresLeft: expireStatus,
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
crudOptions: {
|
crudOptions: {
|
||||||
request: {
|
request: {
|
||||||
@@ -66,6 +73,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
editRequest,
|
editRequest,
|
||||||
delRequest,
|
delRequest,
|
||||||
},
|
},
|
||||||
|
search: {
|
||||||
|
initialForm: searchInitForm,
|
||||||
|
},
|
||||||
form: {
|
form: {
|
||||||
labelCol: {
|
labelCol: {
|
||||||
//固定label宽度
|
//固定label宽度
|
||||||
@@ -213,7 +223,17 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
expiresLeft: {
|
expiresLeft: {
|
||||||
title: t("certd.validDays"),
|
title: t("certd.validDays"),
|
||||||
search: {
|
search: {
|
||||||
show: false,
|
show: true,
|
||||||
|
component: {
|
||||||
|
name: "fs-dict-select",
|
||||||
|
dict: dict({
|
||||||
|
data: [
|
||||||
|
{ label: t("certd.monitor.cert.expired"), value: "expired" },
|
||||||
|
{ label: t("certd.monitor.cert.expiring"), value: "expiring" },
|
||||||
|
{ label: t("certd.monitor.cert.noExpired"), value: "noExpired" },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
type: "date",
|
type: "date",
|
||||||
form: {
|
form: {
|
||||||
@@ -242,9 +262,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
|||||||
|
|
||||||
// 距离失效时间剩余天数
|
// 距离失效时间剩余天数
|
||||||
const leftDays = dayjs(expiresTime).diff(dayjs(), "day");
|
const leftDays = dayjs(expiresTime).diff(dayjs(), "day");
|
||||||
const color = leftDays < 20 ? "red" : "#389e0d";
|
const color = leftDays < DEFAULT_WILL_EXPIRE_DAYS ? "red" : "#389e0d";
|
||||||
const percent = (leftDays / effectiveDays) * 100;
|
const percent = (leftDays / effectiveDays) * 100;
|
||||||
const textColor = leftDays < 20 ? "red" : leftDays > 60 ? "#389e0d" : "";
|
const textColor = leftDays < DEFAULT_WILL_EXPIRE_DAYS ? "red" : leftDays > 60 ? "#389e0d" : "";
|
||||||
const format = () => {
|
const format = () => {
|
||||||
return <span style={{ color: textColor }}>{`${leftDays}${t("certd.days")}`}</span>;
|
return <span style={{ color: textColor }}>{`${leftDays}${t("certd.days")}`}</span>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
|
|
||||||
|
const DEFAULT_WILL_EXPIRE_DAYS = settingStore.sysPublic.defaultWillExpireDays || settingStore.sysPublic.defaultCertRenewDays || 15;
|
||||||
|
|
||||||
function onDialogOpen(opt: any) {
|
function onDialogOpen(opt: any) {
|
||||||
const searchForm = crudExpose.getSearchValidatedFormData();
|
const searchForm = crudExpose.getSearchValidatedFormData();
|
||||||
opt.initialForm = {
|
opt.initialForm = {
|
||||||
@@ -389,9 +391,9 @@ export default function ({ crudExpose, context: { selectedRowKeys, openCertApply
|
|||||||
}
|
}
|
||||||
// 距离失效时间剩余天数
|
// 距离失效时间剩余天数
|
||||||
const leftDays = dayjs(expiresTime).diff(dayjs(), "day");
|
const leftDays = dayjs(expiresTime).diff(dayjs(), "day");
|
||||||
const color = leftDays < 20 ? "red" : "#389e0d";
|
const color = leftDays < DEFAULT_WILL_EXPIRE_DAYS ? "red" : "#389e0d";
|
||||||
const percent = (leftDays / effectiveDays) * 100;
|
const percent = (leftDays / effectiveDays) * 100;
|
||||||
const textColor = leftDays < 20 ? "red" : leftDays > 60 ? "#389e0d" : "";
|
const textColor = leftDays < DEFAULT_WILL_EXPIRE_DAYS ? "red" : leftDays > 60 ? "#389e0d" : "";
|
||||||
const format = () => {
|
const format = () => {
|
||||||
return <span style={{ color: textColor }}>{`${leftDays}${t("certd.days")}`}</span>;
|
return <span style={{ color: textColor }}>{`${leftDays}${t("certd.days")}`}</span>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { ALL, Body, Controller, Get, Inject, Post, Provide, Query } from "@midwayjs/core";
|
import { ALL, Body, Controller, Get, Inject, Post, Provide, Query } from "@midwayjs/core";
|
||||||
import { CommonException, Constants, CrudController } from "@certd/lib-server";
|
import { CommonException, Constants, CrudController, SysSettingsService } from "@certd/lib-server";
|
||||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||||
import { CertInfoService } from "../../../modules/monitor/index.js";
|
import { CertInfoService } from "../../../modules/monitor/index.js";
|
||||||
import { PipelineService } from "../../../modules/pipeline/service/pipeline-service.js";
|
import { PipelineService } from "../../../modules/pipeline/service/pipeline-service.js";
|
||||||
import { SelectQueryBuilder } from "typeorm";
|
import { SelectQueryBuilder } from "typeorm";
|
||||||
import { logger } from "@certd/basic";
|
import { logger } from "@certd/basic";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@@ -19,6 +20,9 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
|||||||
@Inject()
|
@Inject()
|
||||||
pipelineService: PipelineService;
|
pipelineService: PipelineService;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
sysSettingService: SysSettingsService;
|
||||||
|
|
||||||
getService(): CertInfoService {
|
getService(): CertInfoService {
|
||||||
return this.service;
|
return this.service;
|
||||||
}
|
}
|
||||||
@@ -29,6 +33,12 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
|||||||
body.query.userId = this.getUserId();
|
body.query.userId = this.getUserId();
|
||||||
const domains = body.query?.domains;
|
const domains = body.query?.domains;
|
||||||
delete body.query.domains;
|
delete body.query.domains;
|
||||||
|
|
||||||
|
const expiresLeft = body.query?.expiresLeft;
|
||||||
|
delete body.query.expiresLeft;
|
||||||
|
|
||||||
|
const sysSetting = await this.sysSettingService.getPublicSettings();
|
||||||
|
const DEFAULT_WILL_EXPIRE_DAYS = sysSetting?.defaultWillExpireDays || sysSetting?.defaultCertRenewDays || 15;
|
||||||
const res = await this.service.page({
|
const res = await this.service.page({
|
||||||
query: body.query,
|
query: body.query,
|
||||||
page: body.page,
|
page: body.page,
|
||||||
@@ -37,6 +47,16 @@ export class CertInfoController extends CrudController<CertInfoService> {
|
|||||||
if (domains) {
|
if (domains) {
|
||||||
bq.andWhere('domains like :domains', { domains: `%${domains}%` });
|
bq.andWhere('domains like :domains', { domains: `%${domains}%` });
|
||||||
}
|
}
|
||||||
|
if (expiresLeft) {
|
||||||
|
const willExpire = dayjs().add(DEFAULT_WILL_EXPIRE_DAYS, 'day').valueOf();
|
||||||
|
if (expiresLeft === "expired") {
|
||||||
|
bq.andWhere('expires_time < :now', { now: Date.now() });
|
||||||
|
} else if (expiresLeft === "expiring") {
|
||||||
|
bq.andWhere('expires_time <= :willExpire and expires_time > :now', { willExpire, now: Date.now() });
|
||||||
|
} else if (expiresLeft === "noExpired") {
|
||||||
|
bq.andWhere('expires_time > :willExpire', { willExpire });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export abstract class CertApplyBaseConvertPlugin extends AbstractTaskPlugin {
|
|||||||
vModel: "value",
|
vModel: "value",
|
||||||
mode: "tags",
|
mode: "tags",
|
||||||
// open: false,
|
// open: false,
|
||||||
placeholder: "请输入证书域名,比如:foo.com / *.foo.com / *.sub.foo.com / *.bar.com",
|
placeholder: "请输入证书域名,比如:foo.com , *.foo.com , *.sub.foo.com , *.bar.com",
|
||||||
tokenSeparators: [",", " ", ",", "、", "|"],
|
tokenSeparators: [",", " ", ",", "、", "|"],
|
||||||
search: true,
|
search: true,
|
||||||
pager:true,
|
pager:true,
|
||||||
|
|||||||
Reference in New Issue
Block a user