mirror of
https://github.com/certd/certd.git
synced 2026-04-03 14:10:54 +08:00
chore: 修复可选链操作符和DNS管理插件问题
修复多处可选链操作符访问问题,避免潜在的空指针异常 优化DNS管理插件,移除重复的id字段并修正域名匹配逻辑 添加getDomainListPage方法以支持分页查询域名列表
This commit is contained in:
@@ -78,10 +78,10 @@ export default defineComponent({
|
|||||||
async function emitValue(value) {
|
async function emitValue(value) {
|
||||||
const userId = userStore.userInfo.id;
|
const userId = userStore.userInfo.id;
|
||||||
const isEnterprice = projectStore.isEnterprise;
|
const isEnterprice = projectStore.isEnterprise;
|
||||||
if (pipeline.value) {
|
if (pipeline?.value) {
|
||||||
if (isEnterprice) {
|
if (isEnterprice) {
|
||||||
const projectId = projectStore.currentProjectId;
|
const projectId = projectStore.currentProjectId;
|
||||||
if (pipeline.value.projectId !== projectId) {
|
if (pipeline?.value?.projectId !== projectId) {
|
||||||
message.error(`对不起,您不能修改其他项目流水线的授权`);
|
message.error(`对不起,您不能修改其他项目流水线的授权`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ async function emitValue(value: any) {
|
|||||||
const isEnterprice = projectStore.isEnterprise;
|
const isEnterprice = projectStore.isEnterprise;
|
||||||
if (isEnterprice) {
|
if (isEnterprice) {
|
||||||
const projectId = projectStore.currentProjectId;
|
const projectId = projectStore.currentProjectId;
|
||||||
if (pipeline.value.projectId !== projectId) {
|
if (pipeline?.value?.projectId !== projectId) {
|
||||||
message.error(`对不起,您不能修改其他项目流水线的${props.addonType}设置`);
|
message.error(`对不起,您不能修改其他项目流水线的${props.addonType}设置`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,12 +136,12 @@ async function emitValue(value: any) {
|
|||||||
|
|
||||||
if (isEnterprice) {
|
if (isEnterprice) {
|
||||||
const projectId = projectStore.currentProjectId;
|
const projectId = projectStore.currentProjectId;
|
||||||
if (pipeline.value.projectId !== projectId) {
|
if (pipeline?.value?.projectId !== projectId) {
|
||||||
message.error("对不起,您不能修改其他项目流水线的通知");
|
message.error("对不起,您不能修改其他项目流水线的通知");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pipeline.value.userId !== userId) {
|
if (pipeline?.value?.userId !== userId) {
|
||||||
message.error("对不起,您不能修改他人流水线的通知");
|
message.error("对不起,您不能修改他人流水线的通知");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ export class DnsmgrAccess extends BaseAccess {
|
|||||||
const total = resp?.total || 0;
|
const total = resp?.total || 0;
|
||||||
let list = resp?.rows?.map((item: any) => {
|
let list = resp?.rows?.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
|
||||||
domain: item.name,
|
domain: item.name,
|
||||||
...item,
|
...item,
|
||||||
};
|
};
|
||||||
@@ -77,6 +76,8 @@ export class DnsmgrAccess extends BaseAccess {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async createDnsRecord(domainId: string, record: string, value: string, type: string, domain: string) {
|
async createDnsRecord(domainId: string, record: string, value: string, type: string, domain: string) {
|
||||||
this.ctx.logger.info(`创建DNS记录:${record} ${type} ${value}`);
|
this.ctx.logger.info(`创建DNS记录:${record} ${type} ${value}`);
|
||||||
const resp = await this.doRequest({
|
const resp = await this.doRequest({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
import { AbstractDnsProvider, CreateRecordOptions, DomainRecord, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||||
import { DnsmgrAccess } from './access.js';
|
import { DnsmgrAccess } from './access.js';
|
||||||
|
import { PageRes, PageSearch } from '@certd/pipeline';
|
||||||
|
|
||||||
type DnsmgrRecord = {
|
type DnsmgrRecord = {
|
||||||
domainId: string;
|
domainId: string;
|
||||||
@@ -28,7 +29,7 @@ export class DnsmgrDnsProvider extends AbstractDnsProvider<DnsmgrRecord> {
|
|||||||
this.logger.info('添加域名解析:', fullRecord, value, type, domain);
|
this.logger.info('添加域名解析:', fullRecord, value, type, domain);
|
||||||
|
|
||||||
const domainList = await this.access.GetDomainList({ searchKey: domain });
|
const domainList = await this.access.GetDomainList({ searchKey: domain });
|
||||||
const domainInfo = domainList.list?.find((item: any) => item.domain === domain);
|
const domainInfo = domainList.list?.find((item: any) => item.name === domain);
|
||||||
|
|
||||||
if (!domainInfo) {
|
if (!domainInfo) {
|
||||||
throw new Error(`未找到域名:${domain}`);
|
throw new Error(`未找到域名:${domain}`);
|
||||||
@@ -54,6 +55,17 @@ export class DnsmgrDnsProvider extends AbstractDnsProvider<DnsmgrRecord> {
|
|||||||
|
|
||||||
this.logger.info('删除域名解析成功:', fullRecord, value);
|
this.logger.info('删除域名解析成功:', fullRecord, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getDomainListPage(req: PageSearch): Promise<PageRes<DomainRecord>> {
|
||||||
|
const res = await this.access.GetDomainList(req);
|
||||||
|
res.list = res.list?.map((item: any) => {
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
domain: item.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new DnsmgrDnsProvider();
|
new DnsmgrDnsProvider();
|
||||||
|
|||||||
Reference in New Issue
Block a user