first commit

This commit is contained in:
2026-05-08 03:06:24 +08:00
commit 8da6567178
146 changed files with 82014 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import { ref, computed } from 'vue'
export function usePagination(items, pageSize = 10) {
const currentPage = ref(1)
const itemsPerPage = ref(pageSize)
const totalPages = computed(() => Math.ceil(items.value.length / itemsPerPage.value))
const paginatedItems = computed(() => {
const start = (currentPage.value - 1) * itemsPerPage.value
const end = start + itemsPerPage.value
return items.value.slice(start, end)
})
const goToPage = (page) => {
if (page >= 1 && page <= totalPages.value) {
currentPage.value = page
}
}
const nextPage = () => {
if (currentPage.value < totalPages.value) {
currentPage.value++
}
}
const prevPage = () => {
if (currentPage.value > 1) {
currentPage.value--
}
}
const resetPage = () => {
currentPage.value = 1
}
return {
currentPage,
itemsPerPage,
totalPages,
paginatedItems,
goToPage,
nextPage,
prevPage,
resetPage
}
}