Add champions feat

This commit is contained in:
Blossomi Shymae
2024-05-01 21:56:30 -05:00
parent cab1684b7c
commit 32b961dd32
9 changed files with 217 additions and 83 deletions

View File

@@ -0,0 +1,32 @@
export default function usePagination<T>(iterable: Array<T>, pageSize: number) {
const length = Math.ceil(iterable.length / pageSize);
const pages = Array.from({ length: length }, (v, k) => {
return iterable.slice(k * pageSize, k * pageSize + pageSize);
});
const index = ref(0);
const prev = () => {
if (index.value - 1 < 0) return;
index.value--;
};
const next = () => {
if (index.value + 1 >= length) return;
index.value++;
};
const first = () => {
index.value = 0;
};
const last = () => {
index.value = length - 1;
};
return {
count: length,
pages: pages,
index: index,
prev,
next,
first,
last,
};
}