perf: 阿里云waf cname站点选择支持翻页及域名查询

This commit is contained in:
xiaojunnuo
2025-06-29 19:36:46 +08:00
parent 3fb3cee423
commit 4cf98584da
6 changed files with 46 additions and 16 deletions
+24 -1
View File
@@ -3,7 +3,7 @@ import { IContext } from "../core/index.js";
export type UserContext = IContext;
export type PipelineContext = IContext;
export type PageReq = {
export type PageSearch = {
offset?: number;
limit?: number;
searchKey?: string;
@@ -17,3 +17,26 @@ export type PageRes = {
total?: string;
list: any[];
};
export class Pager {
offset: number;
limit: number;
constructor(req: PageSearch) {
this.offset = req.offset ?? 0;
this.limit = req.limit || 50;
}
getPageNo() {
const size = this.limit;
const offset = this.offset;
let page = Math.floor(offset / size);
if (offset % size === 0) {
page++;
}
return page;
}
setPageNo(pageNo: number) {
this.offset = (pageNo - 1) * (this.limit ?? 50);
}
}