perf: 增加域名管理 子域名检查提醒

This commit is contained in:
xiaojunnuo
2026-04-11 22:43:42 +08:00
parent a846c4b66e
commit 2bdf1832da
3 changed files with 40 additions and 1 deletions

View File

@@ -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,
});
}

View File

@@ -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: {

View File

@@ -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);
}
}