update
This commit is contained in:
45
app/components/Pagination.tsx
Normal file
45
app/components/Pagination.tsx
Normal file
@ -0,0 +1,45 @@
|
||||
import Link from "next/link";
|
||||
|
||||
const Pagination = ({
|
||||
page,
|
||||
total,
|
||||
perPage,
|
||||
}: {
|
||||
page: number;
|
||||
total: number;
|
||||
perPage: number;
|
||||
}) => {
|
||||
const pageCount = Math.ceil(total / perPage);
|
||||
return (
|
||||
<div
|
||||
className={"w-full flex justify-center mt-2.5 h-10 items-center text-sm"}
|
||||
>
|
||||
{page <= 1 ? (
|
||||
<div className={"prev mx-3"}>上一页</div>
|
||||
) : (
|
||||
<Link className={"next block mx-3"} href={`./${page - 1}`}>
|
||||
上一页
|
||||
</Link>
|
||||
)}
|
||||
{[...Array(pageCount)].map((el, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className={`page-item mx-3 ${
|
||||
page === index + 1 ? "text-[#009fe9]" : "text-[#666666]"
|
||||
}`}
|
||||
>
|
||||
{index + 1}
|
||||
</div>
|
||||
))}
|
||||
{page >= pageCount ? (
|
||||
<div className={"next mx-3"}>下一页</div>
|
||||
) : (
|
||||
<Link className={"next block mx-3"} href={`./${page + 1}`}>
|
||||
下一页
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Pagination;
|
Reference in New Issue
Block a user