mirror of https://github.com/certd/certd
perf: 修复内置插件分页查询逻辑
- 在前端添加 lastType 变量,用于判断类型变化并重置分页偏移量 - 在后端修改内置插件查询逻辑,支持分页请求 - 优化后端返回数据结构,使其与前端请求一致pull/373/head
parent
70101bfa7a
commit
a2710ddc25
|
@ -10,7 +10,14 @@ import yaml from "js-yaml";
|
||||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
let lastType = "";
|
||||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||||
|
if (lastType && lastType != query?.query?.type) {
|
||||||
|
//lastType有变化
|
||||||
|
query.page.offset = 0;
|
||||||
|
}
|
||||||
|
lastType = query?.query?.type;
|
||||||
return await api.GetList(query);
|
return await api.GetList(query);
|
||||||
};
|
};
|
||||||
const editRequest = async ({ form, row }: EditReq) => {
|
const editRequest = async ({ form, row }: EditReq) => {
|
||||||
|
|
|
@ -33,13 +33,21 @@ export class PluginService extends BaseService<PluginEntity> {
|
||||||
if (pageReq.query.type && pageReq.query.type !== "builtIn") {
|
if (pageReq.query.type && pageReq.query.type !== "builtIn") {
|
||||||
return await super.page(pageReq);
|
return await super.page(pageReq);
|
||||||
}
|
}
|
||||||
|
//仅查询内置插件
|
||||||
|
const offset = pageReq.page.offset;
|
||||||
|
const limit = pageReq.page.limit;
|
||||||
|
|
||||||
|
|
||||||
const builtInList = await this.getBuiltInEntityList();
|
const builtInList = await this.getBuiltInEntityList();
|
||||||
|
|
||||||
|
//获取分页数据
|
||||||
|
const data = builtInList.slice(offset, offset + limit);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
records: builtInList,
|
records: data,
|
||||||
total: builtInList.length,
|
total: builtInList.length,
|
||||||
offset: 0,
|
offset: offset,
|
||||||
limit: 99999
|
limit: limit
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue