fix: pageSize to perPage

This commit is contained in:
chenos 2021-10-10 12:54:48 +08:00
parent effedd77a7
commit d2c534243e

View File

@ -21,6 +21,7 @@ export interface SaveOptions {
export interface ListOptions { export interface ListOptions {
defaultFilter?: any; defaultFilter?: any;
filter?: any; filter?: any;
pageSize?: number;
defaultAppends?: any[]; defaultAppends?: any[];
appends?: string[]; appends?: string[];
perPage?: number; perPage?: number;
@ -53,7 +54,7 @@ export class Resource {
} }
list(options: ListOptions = {}) { list(options: ListOptions = {}) {
const { defaultAppends = [], appends = [], defaultFilter, filter, ...others } = options; const { defaultAppends = [], appends = [], defaultFilter, filter, pageSize, ...others } = options;
const { associatedKey, associatedName, resourceName } = this.options; const { associatedKey, associatedName, resourceName } = this.options;
let url = `${resourceName}:list`; let url = `${resourceName}:list`;
if (associatedName && associatedKey) { if (associatedName && associatedKey) {
@ -64,6 +65,7 @@ export class Resource {
params: { params: {
filter: decodeURIComponent(JSON.stringify({ and: [defaultFilter, filter].filter(Boolean) })), filter: decodeURIComponent(JSON.stringify({ and: [defaultFilter, filter].filter(Boolean) })),
'fields[appends]': defaultAppends.concat(appends).join(','), 'fields[appends]': defaultAppends.concat(appends).join(','),
perPage: pageSize,
...others, ...others,
}, },
}); });