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 ? ',还有更多' : ',已到最后一页'} - - - 每次加载 -