Skip to content

Commit 707947c

Browse files
committed
feat: enhance pageSizeOptions type and improve computed logic for dropdown rendering
1 parent 5f5d671 commit 707947c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ const props = withDefaults(defineProps<{
393393
rows: any[] | null,
394394
totalRows: number,
395395
pageSize: number,
396-
pageSizeOptions?: { label: string; value: any }[];
396+
pageSizeOptions?: { label: string; value: any }[] | number[] | null;
397397
checkboxes: any[],
398398
sort: any[],
399399
noRoundings?: boolean,
@@ -436,9 +436,18 @@ const pageSizeInternal = ref(props.pageSize);
436436
437437
const pageSizeOptionsComputed = computed(() => {
438438
if (!props.pageSizeOptions || props.pageSizeOptions.length === 0) {
439-
return undefined;
439+
return null;
440440
}
441-
return props.pageSizeOptions;
441+
442+
const firstItem = props.pageSizeOptions[0];
443+
if (typeof firstItem === 'object' && firstItem !== null) {
444+
return props.pageSizeOptions as { label: string; value: any }[];
445+
}
446+
447+
return (props.pageSizeOptions as number[]).map(size => ({
448+
label: size.toString(),
449+
value: size
450+
}));
442451
});
443452
444453
const sort: Ref<Array<{field: string, direction: string}>> = ref([]);

0 commit comments

Comments
 (0)