账号管理:分页按钮优化,支持切换每页条数并持久化
This commit is contained in:
@@ -28,6 +28,11 @@ export default function AccountsPage() {
|
|||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
|
||||||
const [batchTagInput, setBatchTagInput] = useState('');
|
const [batchTagInput, setBatchTagInput] = useState('');
|
||||||
const [batchTagVisible, setBatchTagVisible] = useState(false);
|
const [batchTagVisible, setBatchTagVisible] = useState(false);
|
||||||
|
const [pageSize, setPageSize] = useState(() => {
|
||||||
|
const v = localStorage.getItem('account_page_size');
|
||||||
|
return v ? Number(v) || 20 : 20;
|
||||||
|
});
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const { can } = usePermissions();
|
const { can } = usePermissions();
|
||||||
|
|
||||||
const canViewAll = can('account:view_all');
|
const canViewAll = can('account:view_all');
|
||||||
@@ -342,7 +347,20 @@ export default function AccountsPage() {
|
|||||||
rowKey="id"
|
rowKey="id"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
size="small"
|
size="small"
|
||||||
pagination={{ pageSize: 20 }}
|
pagination={{
|
||||||
|
current: currentPage,
|
||||||
|
pageSize,
|
||||||
|
showSizeChanger: true,
|
||||||
|
showTotal: (t) => `共 ${t} 条`,
|
||||||
|
onChange: (page, size) => {
|
||||||
|
setCurrentPage(page);
|
||||||
|
if (size !== pageSize) {
|
||||||
|
setPageSize(size);
|
||||||
|
localStorage.setItem('account_page_size', String(size));
|
||||||
|
setCurrentPage(1); // 切换 pageSize 时重置到第1页
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
Reference in New Issue
Block a user