mirror of
https://github.com/certd/certd.git
synced 2026-04-14 20:40:53 +08:00
perf: 增加域名管理 子域名检查提醒
This commit is contained in:
@@ -99,3 +99,11 @@ export async function SyncExpirationStatus() {
|
||||
method: "post",
|
||||
});
|
||||
}
|
||||
|
||||
export async function IsSubdomain(body: any) {
|
||||
return await request({
|
||||
url: apiPrefix + "/isSubdomain",
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
});
|
||||
|
||||
const openDomainImportManageDialog = useDomainImportManage();
|
||||
|
||||
const subdomainConfirmed = ref(false);
|
||||
return {
|
||||
crudOptions: {
|
||||
settings: {
|
||||
@@ -85,10 +87,29 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
fixed: "right",
|
||||
},
|
||||
form: {
|
||||
beforeSubmit({ form }) {
|
||||
async beforeSubmit({ form }) {
|
||||
if (form.challengeType === "cname") {
|
||||
throw new Error("CNAME方式请前往CNAME记录页面进行管理");
|
||||
}
|
||||
if (form.challengeType === "dns") {
|
||||
const isSubdomain = await api.IsSubdomain({ domain: form.domain });
|
||||
if (isSubdomain && !subdomainConfirmed.value) {
|
||||
Modal.confirm({
|
||||
title: "子域名确认",
|
||||
content: `检测到${form.domain}为子域名,只有托管子域名和免费二级子域名才需要在此处维护,否则会导致申请证书失败,请确认是否继续?`,
|
||||
okText: "确认",
|
||||
okType: "danger",
|
||||
onOk: () => {
|
||||
subdomainConfirmed.value = true;
|
||||
crudExpose.getFormWrapperRef().submit();
|
||||
},
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
afterSubmit({ form }) {
|
||||
subdomainConfirmed.value = false;
|
||||
},
|
||||
},
|
||||
actionbar: {
|
||||
@@ -163,6 +184,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
},
|
||||
form: {
|
||||
required: true,
|
||||
helper: "注意:DNS校验方式下,子域名不需要在此处维护,否则会影响证书申请(子域名托管或免费二级域名除外)",
|
||||
},
|
||||
editForm: {
|
||||
component: {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Constants, CrudController } from '@certd/lib-server';
|
||||
import { DomainService } from "../../../modules/cert/service/domain-service.js";
|
||||
import { checkPlus } from '@certd/plus-core';
|
||||
import { ApiTags } from '@midwayjs/swagger';
|
||||
import { parseDomainByPsl } from '@certd/plugin-lib';
|
||||
|
||||
/**
|
||||
* 授权
|
||||
@@ -187,4 +188,12 @@ export class DomainController extends CrudController<DomainService> {
|
||||
return this.ok(setting);
|
||||
}
|
||||
|
||||
@Post('/isSubdomain', { description: Constants.per.authOnly, summary: "判断是否为子域名" })
|
||||
async isSubdomain(@Body(ALL) body: any) {
|
||||
const { domain } = body;
|
||||
const parsed = parseDomainByPsl(domain)
|
||||
const mainDomain = parsed.domain || ''
|
||||
return this.ok(mainDomain !== domain);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user