Skip to content

Commit 8cd6d72

Browse files
committed
feat: enhance PAGE_SIZE_OPTIONS computation for better type handling and clarity
1 parent c03a3a7 commit 8cd6d72

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

adminforth/spa/src/views/ListView.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,12 @@ watch(() => coreStore.resource?.resourceId, () => {
273273
const PAGE_SIZE_OPTIONS = computed(() => {
274274
const array = coreStore.resource?.options?.listPageSizeOptions;
275275
276-
if (!array || array.length === 0) return undefined;
276+
if (!Array.isArray(array)) return undefined;
277277
278-
return array.map(size => ({ label: size.toString(), value: size }));
278+
return array.map((size: number) => ({
279+
label: size.toString(),
280+
value: size
281+
}));
279282
});
280283
281284
const pageSize = ref(DEFAULT_PAGE_SIZE);
@@ -450,8 +453,7 @@ async function init() {
450453
}
451454
if (route.query.pageSize) {
452455
const parsedPageSize = parseInt(route.query.pageSize as string);
453-
// Перевіряємо наявність опцій перед використанням .includes
454-
if (PAGE_SIZE_OPTIONS.value && PAGE_SIZE_OPTIONS.value.some(o => o.value === parsedPageSize)) {
456+
if (PAGE_SIZE_OPTIONS.value && PAGE_SIZE_OPTIONS.value.some((o: { value: number }) => o.value === parsedPageSize)) {
455457
pageSize.value = parsedPageSize;
456458
}
457459
} else if (coreStore.resource?.options?.listPageSize) {

0 commit comments

Comments
 (0)