From 6b29972399a80f802a330d4382d101ea27dee3fa Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Fri, 3 Apr 2026 00:32:00 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E5=A4=8D=E5=8F=AF=E9=80=89?= =?UTF-8?q?=E9=93=BE=E6=93=8D=E4=BD=9C=E7=AC=A6=E5=92=8CDNS=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8F=92=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复多处可选链操作符访问问题,避免潜在的空指针异常 优化DNS管理插件,移除重复的id字段并修正域名匹配逻辑 添加getDomainListPage方法以支持分页查询域名列表 --- .../views/certd/access/access-selector/index.vue | 4 ++-- .../views/certd/addon/addon-selector/index.vue | 2 +- .../notification/notification-selector/index.vue | 4 ++-- .../src/plugins/plugin-dnsmgr/access.ts | 3 ++- .../src/plugins/plugin-dnsmgr/dns-provider.ts | 16 ++++++++++++++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/ui/certd-client/src/views/certd/access/access-selector/index.vue b/packages/ui/certd-client/src/views/certd/access/access-selector/index.vue index e50653f19..0fabb3a4c 100644 --- a/packages/ui/certd-client/src/views/certd/access/access-selector/index.vue +++ b/packages/ui/certd-client/src/views/certd/access/access-selector/index.vue @@ -78,10 +78,10 @@ export default defineComponent({ async function emitValue(value) { const userId = userStore.userInfo.id; const isEnterprice = projectStore.isEnterprise; - if (pipeline.value) { + if (pipeline?.value) { if (isEnterprice) { const projectId = projectStore.currentProjectId; - if (pipeline.value.projectId !== projectId) { + if (pipeline?.value?.projectId !== projectId) { message.error(`对不起,您不能修改其他项目流水线的授权`); return; } diff --git a/packages/ui/certd-client/src/views/certd/addon/addon-selector/index.vue b/packages/ui/certd-client/src/views/certd/addon/addon-selector/index.vue index 5bbc157d7..c14dddbad 100644 --- a/packages/ui/certd-client/src/views/certd/addon/addon-selector/index.vue +++ b/packages/ui/certd-client/src/views/certd/addon/addon-selector/index.vue @@ -136,7 +136,7 @@ async function emitValue(value: any) { const isEnterprice = projectStore.isEnterprise; if (isEnterprice) { const projectId = projectStore.currentProjectId; - if (pipeline.value.projectId !== projectId) { + if (pipeline?.value?.projectId !== projectId) { message.error(`对不起,您不能修改其他项目流水线的${props.addonType}设置`); return; } diff --git a/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue b/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue index fcc9d841c..45c9a4a48 100644 --- a/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue +++ b/packages/ui/certd-client/src/views/certd/notification/notification-selector/index.vue @@ -136,12 +136,12 @@ async function emitValue(value: any) { if (isEnterprice) { const projectId = projectStore.currentProjectId; - if (pipeline.value.projectId !== projectId) { + if (pipeline?.value?.projectId !== projectId) { message.error("对不起,您不能修改其他项目流水线的通知"); return; } } else { - if (pipeline.value.userId !== userId) { + if (pipeline?.value?.userId !== userId) { message.error("对不起,您不能修改他人流水线的通知"); return; } diff --git a/packages/ui/certd-server/src/plugins/plugin-dnsmgr/access.ts b/packages/ui/certd-server/src/plugins/plugin-dnsmgr/access.ts index a647ad9e8..9d05507ee 100644 --- a/packages/ui/certd-server/src/plugins/plugin-dnsmgr/access.ts +++ b/packages/ui/certd-server/src/plugins/plugin-dnsmgr/access.ts @@ -66,7 +66,6 @@ export class DnsmgrAccess extends BaseAccess { const total = resp?.total || 0; let list = resp?.rows?.map((item: any) => { return { - id: item.id, domain: item.name, ...item, }; @@ -77,6 +76,8 @@ export class DnsmgrAccess extends BaseAccess { }; } + + async createDnsRecord(domainId: string, record: string, value: string, type: string, domain: string) { this.ctx.logger.info(`创建DNS记录:${record} ${type} ${value}`); const resp = await this.doRequest({ diff --git a/packages/ui/certd-server/src/plugins/plugin-dnsmgr/dns-provider.ts b/packages/ui/certd-server/src/plugins/plugin-dnsmgr/dns-provider.ts index 2a1b4aed7..fb201e96e 100644 --- a/packages/ui/certd-server/src/plugins/plugin-dnsmgr/dns-provider.ts +++ b/packages/ui/certd-server/src/plugins/plugin-dnsmgr/dns-provider.ts @@ -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 { PageRes, PageSearch } from '@certd/pipeline'; type DnsmgrRecord = { domainId: string; @@ -28,7 +29,7 @@ export class DnsmgrDnsProvider extends AbstractDnsProvider { this.logger.info('添加域名解析:', fullRecord, value, type, 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) { throw new Error(`未找到域名:${domain}`); @@ -54,6 +55,17 @@ export class DnsmgrDnsProvider extends AbstractDnsProvider { this.logger.info('删除域名解析成功:', fullRecord, value); } + + async getDomainListPage(req: PageSearch): Promise> { + 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();