From 66d1886663972ce818796f590d53e6466dc9e4c1 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sun, 29 Jun 2025 19:59:13 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E7=BF=BB=E9=A1=B5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/pipeline/src/context/index.ts | 30 ++++++++----------- .../plugins/common/remote-select.vue | 27 +++++++++-------- .../plugin/deploy-to-waf/index.ts | 10 ++++--- .../plugins/plugin-refresh-cert.ts | 11 +++---- .../src/plugins/plugin-rainyun/access.ts | 18 +++++------ .../plugins/plugin-refresh-cert.ts | 12 ++++---- 6 files changed, 51 insertions(+), 57 deletions(-) diff --git a/packages/core/pipeline/src/context/index.ts b/packages/core/pipeline/src/context/index.ts index 97c6babc..0dd6b147 100644 --- a/packages/core/pipeline/src/context/index.ts +++ b/packages/core/pipeline/src/context/index.ts @@ -4,39 +4,33 @@ export type UserContext = IContext; export type PipelineContext = IContext; export type PageSearch = { - offset?: number; - limit?: number; + pageNo?: number; + pageSize?: number; searchKey?: string; // sortBy?: string; // sortOrder?: "asc" | "desc"; }; export type PageRes = { - offset?: number; - limit?: number; + pageNo?: number; + pageSize?: number; total?: string; list: any[]; }; export class Pager { - offset: number; - limit: number; + pageNo: number; + pageSize: number; constructor(req: PageSearch) { - this.offset = req.offset ?? 0; - this.limit = req.limit || 50; + this.pageNo = req.pageNo ?? 1; + this.pageSize = req.pageSize || 50; } - getPageNo() { - const size = this.limit; - const offset = this.offset; - let page = Math.floor(offset / size); - if (offset % size === 0) { - page++; - } - return page; + getOffset() { + return (this.pageNo - 1) * (this.pageSize ?? 50); } - setPageNo(pageNo: number) { - this.offset = (pageNo - 1) * (this.limit ?? 50); + setOffset(offset: number) { + this.pageNo = Math.ceil(offset / (this.pageSize ?? 50)) + 1; } } diff --git a/packages/ui/certd-client/src/components/plugins/common/remote-select.vue b/packages/ui/certd-client/src/components/plugins/common/remote-select.vue index b4953379..89e62e00 100644 --- a/packages/ui/certd-client/src/components/plugins/common/remote-select.vue +++ b/packages/ui/certd-client/src/components/plugins/common/remote-select.vue @@ -21,7 +21,7 @@
- +
@@ -119,9 +119,8 @@ const getOptions = async () => { message.value = ""; hasError.value = false; loading.value = true; - optionsRef.value = []; - - const offset = (pagerRef.value.current - 1) * (pagerRef.value.limit ?? 100); + const pageNo = pagerRef.value.pageNo; + const pageSize = pagerRef.value.pageSize; try { const res = await doRequest( { @@ -131,8 +130,8 @@ const getOptions = async () => { input, data: { searchKey: props.search ? searchKeyRef.value : "", - offset: offset, - limit: pagerRef.value.limit, + pageNo, + pageSize, }, }, { @@ -150,17 +149,15 @@ const getOptions = async () => { optionsRef.value = list; pagerRef.value.total = list.length; if (props.pager) { - if (res.offset != null) { - pagerRef.value.offset = res.offset ?? 0; + if (res.pageNo != null) { + pagerRef.value.pageNo = res.pageNo ?? 1; } - if (res.limit != null) { - pagerRef.value.limit = res.limit ?? 100; + if (res.pageSize != null) { + pagerRef.value.pageSize = res.pageSize ?? 100; } if (res.total != null) { pagerRef.value.total = res.total ?? list.length; } - const { offset, limit } = pagerRef.value; - pagerRef.value.current = offset % limit === 0 ? offset / limit + 1 : offset / limit; } return res; @@ -184,7 +181,7 @@ async function refreshOptions() { } async function doSearch() { - pagerRef.value.current = 1; + pagerRef.value.pageNo = 1; await refreshOptions(); } @@ -222,6 +219,10 @@ watch( immediate: true, } ); + +async function onPageChange(current: any) { + await refreshOptions(); +} diff --git a/packages/ui/certd-server/src/plugins/plugin-aliyun/plugin/deploy-to-waf/index.ts b/packages/ui/certd-server/src/plugins/plugin-aliyun/plugin/deploy-to-waf/index.ts index 1c758048..09913b7c 100644 --- a/packages/ui/certd-server/src/plugins/plugin-aliyun/plugin/deploy-to-waf/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-aliyun/plugin/deploy-to-waf/index.ts @@ -183,8 +183,8 @@ export class AliyunDeployCertToWaf extends AbstractTaskPlugin { const params:any = { RegionId: this.regionId, InstanceId: instanceId, - PageSize: pager.limit, - PageNumber: pager.getPageNo(), + PageSize: pager.pageSize, + PageNumber: pager.pageNo, }; if (data.searchKey){ params.Domain = data.searchKey @@ -206,11 +206,13 @@ export class AliyunDeployCertToWaf extends AbstractTaskPlugin { }); const list= this.ctx.utils.options.buildGroupOptions(options, this.certDomains); + // const list = [{value:"1",label:"1"},{value:"2",label:"2"}] + // const total = 120 return { list, total: total, - offset: pager.offset, - limit: pager.limit + pageNo: pager.pageNo, + pageSize: pager.pageSize }; } } diff --git a/packages/ui/certd-server/src/plugins/plugin-farcdn/plugins/plugin-refresh-cert.ts b/packages/ui/certd-server/src/plugins/plugin-farcdn/plugins/plugin-refresh-cert.ts index 4a10892b..7c509cf8 100644 --- a/packages/ui/certd-server/src/plugins/plugin-farcdn/plugins/plugin-refresh-cert.ts +++ b/packages/ui/certd-server/src/plugins/plugin-farcdn/plugins/plugin-refresh-cert.ts @@ -1,4 +1,4 @@ -import { AbstractTaskPlugin, IsTaskPlugin, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline"; +import { AbstractTaskPlugin, IsTaskPlugin, Pager, PageSearch, pluginGroups, RunStrategy, TaskInput } from "@certd/pipeline"; import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert"; import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib"; import { FarcdnAccess } from "../access.js"; @@ -81,9 +81,10 @@ export class FarcdnRefreshCert extends AbstractTaskPlugin { async onGetCertList(data:PageSearch = {}) { const access = await this.getAccess(this.accessId); + const pager = new Pager(data); const res = await access.getSSLCertList({ - offset: data.offset?? 0, - size: data.limit?? 100, + offset: pager.getOffset(), + size: pager.pageSize, }); const list = res.list if (!list || list.length === 0) { @@ -100,8 +101,8 @@ export class FarcdnRefreshCert extends AbstractTaskPlugin { return { list:this.ctx.utils.options.buildGroupOptions(options, this.certDomains), total:res.total, - offset: res.offset, - limit:res.size + pageNo: pager.pageNo, + pageSize: pager.pageSize } } } diff --git a/packages/ui/certd-server/src/plugins/plugin-rainyun/access.ts b/packages/ui/certd-server/src/plugins/plugin-rainyun/access.ts index 18e44529..b02c7d01 100644 --- a/packages/ui/certd-server/src/plugins/plugin-rainyun/access.ts +++ b/packages/ui/certd-server/src/plugins/plugin-rainyun/access.ts @@ -75,20 +75,16 @@ export class RainyunAccess extends BaseAccess { } - async getCertList(req:{offset?:number,limit?:number,query?:string}){ - const size = req.limit ?? 20; - const offset = req.offset ?? 0; - let page = Math.floor(offset / size); - if(offset % size === 0 ){ - page++ - } + async getCertList(req:{pageNo?:number,pageSize?:number,query?:string}){ + const pageNo = req.pageNo ?? 1; + const pageSize = req.pageSize ?? 20; const options ={ columnFilters: { Domain: req.query??"" }, sort:[], - page: page, - perPage: size, + page: pageNo, + perPage: pageSize, } const res = await this.doRequest({ @@ -99,8 +95,8 @@ export class RainyunAccess extends BaseAccess { return { total: res.TotalRecords, list: res.Records || [], - limit: size, - offset: offset + pageNo: pageNo, + pageSize: pageSize } } diff --git a/packages/ui/certd-server/src/plugins/plugin-rainyun/plugins/plugin-refresh-cert.ts b/packages/ui/certd-server/src/plugins/plugin-rainyun/plugins/plugin-refresh-cert.ts index f05b3ae4..b925db03 100644 --- a/packages/ui/certd-server/src/plugins/plugin-rainyun/plugins/plugin-refresh-cert.ts +++ b/packages/ui/certd-server/src/plugins/plugin-rainyun/plugins/plugin-refresh-cert.ts @@ -81,11 +81,11 @@ export class RainyunRefreshCert extends AbstractTaskPlugin { async onGetCertList(req: PageSearch = {}) { const access = await this.getAccess(this.accessId); - const offset = req.offset ?? 0; - const limit = req.limit ?? 100; + const pageNo = req.pageNo ?? 1; + const pageSize = req.pageSize ?? 100; const res = await access.getCertList({ - offset, - limit + pageNo, + pageSize }); const total = res.total; const list = res.list; @@ -103,8 +103,8 @@ export class RainyunRefreshCert extends AbstractTaskPlugin { return { list: this.ctx.utils.options.buildGroupOptions(options, this.certDomains), total: total, - offset: offset, - limit: limit + pageNo: pageNo, + pageSize: pageSize }; } }