From 171f5bc44a63b6e96af93db4825a78e34ecc90af Mon Sep 17 00:00:00 2001 From: Eamon <17516219072@163.com> Date: Thu, 27 Aug 2026 14:06:22 +0800 Subject: [PATCH] =?UTF-8?q?IP=E7=BA=BF=E8=B7=AF=E8=A1=A8=20&=20=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E4=B8=8B=E8=BD=BD=20=20=E9=A1=B5=E9=9D=A2=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E7=AB=AF=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ui/pagination.tsx | 45 ++++++++++++--- src/home/header.tsx | 2 +- src/home/ipLine/index.tsx | 72 ++++++++++++------------ src/home/product/buy.tsx | 96 ++++++++++++++++---------------- src/home/softDownload/index.tsx | 12 ++-- 5 files changed, 127 insertions(+), 100 deletions(-) diff --git a/src/components/ui/pagination.tsx b/src/components/ui/pagination.tsx index bb596fb..ab3f84d 100644 --- a/src/components/ui/pagination.tsx +++ b/src/components/ui/pagination.tsx @@ -40,6 +40,21 @@ function Pagination({ const [currentPage, setCurrentPage] = useState(page) const totalPages = Math.ceil(total / size) + // 移动端检测:小屏幕减少页码按钮数量,避免溢出 + const [isMobile, setIsMobile] = useState( + () => + typeof window !== "undefined" && + window.matchMedia("(max-width: 640px)").matches, + ) + + useEffect(() => { + const mql = window.matchMedia("(max-width: 640px)") + const handleChange = () => setIsMobile(mql.matches) + handleChange() + mql.addEventListener("change", handleChange) + return () => mql.removeEventListener("change", handleChange) + }, []) + // 同步外部 page 变化 useEffect(() => { setCurrentPage(page) @@ -47,12 +62,13 @@ function Pagination({ // 分页器逻辑 const generatePaginationItems = () => { - // 最多显示7个页码,其余用省略号 - const SIBLINGS = 1 // 当前页左右各显示的页码数 + // 桌面端最多显示7个页码,移动端最多显示5个,其余用省略号 + const SIBLINGS = isMobile ? 0 : 1 // 当前页左右各显示的页码数 + const MAX_VISIBLE = isMobile ? 5 : 7 const DOTS = -1 // 省略号标记 - if (totalPages <= 7) { - // 总页数少于7,全部显示 + if (totalPages <= MAX_VISIBLE) { + // 总页数较少,全部显示 return Array.from({ length: totalPages }, (_, i) => i + 1) } @@ -121,8 +137,13 @@ function Pagination({ const paginationItems = generatePaginationItems() return ( -
-
+
+
共 {total} 条记录,每页 - + 暂无可用优惠券 - - 淘宝每次下单获得优惠券 - + 淘宝每次下单获得优惠券
) } @@ -178,8 +176,8 @@ function CouponSelector() { // ============ 批量注册说明 ============ function BatchInfo() { return ( -
-