fix: show published models and support multi-model key selection
This commit is contained in:
1 parent
1a57de5bf9
commit
0a44a0802b
14 files changed
+360
-60
No files matched your search
@@ -0,0 +1,11 @@
|
||||
import { computed, ref, watch, type Ref } from 'vue'
|
||||
|
||||
export function usePagination<T>(items: Ref<T[]>, initialSize = 12) {
|
||||
const page = ref(1)
|
||||
const pageSize = ref(initialSize)
|
||||
const pages = computed(() => Math.max(1, Math.ceil(items.value.length / pageSize.value)))
|
||||
watch(pageSize, () => { page.value = 1 })
|
||||
watch(pages, count => { page.value = Math.max(1, Math.min(page.value, count)) })
|
||||
const pagedItems = computed(() => items.value.slice((page.value - 1) * pageSize.value, page.value * pageSize.value))
|
||||
return { page, pageSize, pages, pagedItems }
|
||||
}
|
||||
Reference in new issue
Block a user