feat(hooks): 优化表格响应数据处理
This commit is contained in:
@@ -6,7 +6,6 @@ import useLoading from './use-loading';
|
||||
export interface PaginationData<T> {
|
||||
data: T[];
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,9 +131,6 @@ export function useNaivePaginatedTable<ResponseData, ApiData>(
|
||||
getColumns,
|
||||
onFetched: data => {
|
||||
pagination.itemCount = data.total;
|
||||
if (data.pageSize) {
|
||||
pagination.pageSize = data.pageSize;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -249,17 +246,15 @@ export function defaultTransform<ApiData>(
|
||||
return {
|
||||
data: [],
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
};
|
||||
}
|
||||
|
||||
const { rows: records, pageSize: size, pageNum: current, total } = data;
|
||||
const { rows: records, pageNum: current, total } = data;
|
||||
|
||||
return {
|
||||
data: records,
|
||||
pageNum: current,
|
||||
pageSize: size,
|
||||
total
|
||||
};
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -10,7 +10,7 @@ declare namespace Api {
|
||||
/** current page number */
|
||||
pageNum: number;
|
||||
/** page size */
|
||||
pageSize: number;
|
||||
pageSize?: number;
|
||||
/** total count */
|
||||
total: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user