From de58e69933a81305d868478bad7a695c2dce462e Mon Sep 17 00:00:00 2001 From: OuYingJun1024 <1034284404@qq.com> Date: Sun, 14 Jun 2026 15:37:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin-web):=20=E4=B8=BB=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E6=94=B9=E9=A1=B5=E7=A0=81=E5=88=86=E9=A1=B5(usePaged?= =?UTF-8?q?List=20+=20antd=20pagination)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户/提现/上报/审计日志四页从「加载更多」改为页码分页: - 新增 usePagedList hook:页码→offset、暴露 total,配 antd Table pagination; 与 useCursorList(加载更多)并存,详情子表/反馈页仍用后者 - CursorPage 类型加 total? - 四页接入 pagination(页码/跳页/共 N 条/showSizeChanger);提现页移除自定义 「每次加载」选择器,统一用 showSizeChanger(20/50/100) - 反馈页本轮不动(后端反馈接口在 feat/feedback-iteration 迭代中) tsc --noEmit 通过。 Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app/(main)/audit-logs/page.tsx | 23 ++++---- src/app/(main)/price-reports/page.tsx | 22 ++++---- src/app/(main)/users/page.tsx | 22 ++++---- src/app/(main)/withdraws/page.tsx | 52 +++++-------------- src/lib/types.ts | 1 + src/lib/usePagedList.ts | 75 +++++++++++++++++++++++++++ 6 files changed, 122 insertions(+), 73 deletions(-) create mode 100644 src/lib/usePagedList.ts diff --git a/src/app/(main)/audit-logs/page.tsx b/src/app/(main)/audit-logs/page.tsx index 6a8ce28..91fd662 100644 --- a/src/app/(main)/audit-logs/page.tsx +++ b/src/app/(main)/audit-logs/page.tsx @@ -4,7 +4,7 @@ import { useState } from 'react'; import type { ColumnsType } from 'antd/es/table'; import { Button, Input, Space, Table, Tag } from 'antd'; import { formatUtcTime } from '@/lib/format'; -import { useCursorList } from '@/lib/useCursorList'; +import { usePagedList } from '@/lib/usePagedList'; import type { AuditLog } from '@/lib/types'; // 审计 created_at 为 UTC 口径(server_default now()),按北京显示(勿用 new Date().toLocaleString) @@ -13,11 +13,8 @@ const dt = (v: string) => formatUtcTime(v, 'YYYY-MM-DD HH:mm:ss'); export default function AuditLogsPage() { const [action, setAction] = useState(''); const [filters, setFilters] = useState>({}); - const { items, nextCursor, loading, loadMore } = useCursorList( - '/admin/api/audit-logs', - filters, - 50, - ); + const { items, total, page, pageSize, loading, onChange: onPageChange } = + usePagedList('/admin/api/audit-logs', filters, 50); const search = () => setFilters({ action: action || undefined }); @@ -61,14 +58,16 @@ export default function AuditLogsPage() { columns={columns} dataSource={items} loading={loading} - pagination={false} + pagination={{ + current: page, + pageSize, + total, + showSizeChanger: true, + showTotal: (t) => `共 ${t} 条`, + onChange: onPageChange, + }} scroll={{ x: 1000 }} /> -
- -
); } diff --git a/src/app/(main)/price-reports/page.tsx b/src/app/(main)/price-reports/page.tsx index d59bf6c..db2d17d 100644 --- a/src/app/(main)/price-reports/page.tsx +++ b/src/app/(main)/price-reports/page.tsx @@ -20,7 +20,7 @@ import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons'; import dayjs from 'dayjs'; import { api, errMsg } from '@/lib/api'; import { canDo } from '@/lib/auth'; -import { useCursorList } from '@/lib/useCursorList'; +import { usePagedList } from '@/lib/usePagedList'; import type { PriceReport, PriceReportSummary } from '@/lib/types'; const { Text } = Typography; @@ -65,10 +65,8 @@ export default function PriceReportsPage() { const filters: Record = {}; if (activeStatus !== 'all') filters.status = activeStatus; - const { items, nextCursor, loading, loadMore, reload } = useCursorList( - '/admin/api/price-reports', - filters, - ); + const { items, total, page, pageSize, loading, onChange: onPageChange, reload } = + usePagedList('/admin/api/price-reports', filters); const canReview = canDo(['operator']); @@ -277,14 +275,16 @@ export default function PriceReportsPage() { columns={columns} dataSource={items} loading={loading} - pagination={false} + pagination={{ + current: page, + pageSize, + total, + showSizeChanger: true, + showTotal: (t) => `共 ${t} 条`, + onChange: onPageChange, + }} scroll={{ x: 1100 }} /> -
- -
= { ...applied, sort_by: sortBy, sort_order: sortOrder }; const filterKey = JSON.stringify(filters); - const { items, nextCursor, loading, loadMore, reload } = useCursorList( - '/admin/api/users', - filters, - ); + const { items, total, page, pageSize, loading, onChange: onPageChange, reload } = + usePagedList('/admin/api/users', filters); const canCoins = canDo(['finance']); const canStatus = canDo(['operator']); @@ -339,15 +337,17 @@ export default function UsersPage() { columns={columns} dataSource={items} loading={loading} - pagination={false} + pagination={{ + current: page, + pageSize, + total, + showSizeChanger: true, + showTotal: (t) => `共 ${t} 个用户`, + onChange: onPageChange, + }} scroll={{ x: 1160 }} onChange={onTableChange} /> -
- -
setCoinUser(null)} /> setCashUser(null)} /> diff --git a/src/app/(main)/withdraws/page.tsx b/src/app/(main)/withdraws/page.tsx index aef4d36..a33a067 100644 --- a/src/app/(main)/withdraws/page.tsx +++ b/src/app/(main)/withdraws/page.tsx @@ -39,7 +39,7 @@ import dayjs, { type Dayjs } from 'dayjs'; import { api, errMsg } from '@/lib/api'; import { canDo } from '@/lib/auth'; import { formatUtcTime, formatWallTime, utcDayjs, utcFromNow, yuan } from '@/lib/format'; -import { useCursorList } from '@/lib/useCursorList'; +import { usePagedList } from '@/lib/usePagedList'; import type { AuditLog, CashTxn, @@ -181,7 +181,6 @@ export default function WithdrawsPage() { const [bulkRejecting, setBulkRejecting] = useState([]); const [rejectReason, setRejectReason] = useState(''); const [selectedRowKeys, setSelectedRowKeys] = useState([]); - const [pageSize, setPageSize] = useState(20); const [searchDraft, setSearchDraft] = useState(''); const [keyword, setKeyword] = useState(''); const [dateRange, setDateRange] = useState<[Dayjs, Dayjs] | null>(null); @@ -202,11 +201,8 @@ export default function WithdrawsPage() { filters.sort_by = sortBy; filters.sort_order = sortOrder; const filterKey = JSON.stringify(filters); - const { items, nextCursor, loading, loadMore, reload } = useCursorList( - '/admin/api/withdraws', - filters, - pageSize, - ); + const { items, total, page, pageSize, loading, onChange: onPageChange, reload } = + usePagedList('/admin/api/withdraws', filters, 20); const canManage = canDo(['finance']); const selectedOrders = items.filter((item) => selectedRowKeys.includes(item.id)); const selectedReviewing = selectedOrders.filter((item) => item.status === 'reviewing'); @@ -290,7 +286,7 @@ export default function WithdrawsPage() { useEffect(() => { setSelectedRowKeys([]); - }, [filterKey, pageSize]); + }, [filterKey, page, pageSize]); const refreshAfterChange = async (outBillNo?: string) => { setSelectedRowKeys([]); @@ -887,31 +883,6 @@ export default function WithdrawsPage() { )} - - - 当前已加载 {items.length} 条{nextCursor ? ',还有更多' : ',已到最后一页'} - - - 每次加载 -