diff --git a/admin-frontend/src/components/ProductList.tsx b/admin-frontend/src/components/ProductList.tsx index 1160ff3..6f50459 100644 --- a/admin-frontend/src/components/ProductList.tsx +++ b/admin-frontend/src/components/ProductList.tsx @@ -32,7 +32,8 @@ export default function ProductList({ const [q, setQ] = useState(""); const [input, setInput] = useState(""); const [page, setPage] = useState(1); - const [size] = useState(20); + const [size, setSize] = useState(20); + const [jump, setJump] = useState(""); const [rows, setRows] = useState([]); const [total, setTotal] = useState(0); const [loading, setLoading] = useState(false); @@ -319,7 +320,25 @@ export default function ProductList({ -
+
+
+ 每页 + + 条 · 共 {total} 条 +
+
{ + e.preventDefault(); + const n = Number(jump); + if (Number.isFinite(n) && n >= 1) { + setPage(Math.min(Math.max(1, Math.trunc(n)), pages)); + setJump(""); + } + }} + className="flex items-center gap-1" + > + 跳至 + setJump(e.target.value.replace(/[^0-9]/g, ""))} + placeholder={String(page)} + className="w-14 rounded border border-gray-300 px-2 py-1 text-center" + aria-label="跳转页码" + /> + +
);