fix: preserve pagination and filters across list navigation
douyin-release-gate / verify (push) Failing after 18m33s
douyin-release-gate / verify (push) Failing after 18m33s
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { ProProvider, RouteContext } from '@ant-design/pro-components';
|
||||
import type { ColumnsType, ColumnType } from 'antd/es/table';
|
||||
import { useContext } from 'react';
|
||||
import { usePageState } from '@/hooks/usePageState';
|
||||
|
||||
export const TABLE_PAGE_SIZE = 20;
|
||||
|
||||
@@ -18,6 +19,17 @@ export function tablePagination() {
|
||||
return { pageSize: TABLE_PAGE_SIZE, hideOnSinglePage: true };
|
||||
}
|
||||
|
||||
export function useTablePagination() {
|
||||
const [pagination, setPagination] = usePageState('pagination', { current: 1, pageSize: TABLE_PAGE_SIZE });
|
||||
return {
|
||||
...tablePagination(),
|
||||
...pagination,
|
||||
onChange: (current: number, pageSize: number) => {
|
||||
setPagination(previous => ({ current: pageSize === previous.pageSize ? current : 1, pageSize }));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function fixedLeft<RecordType>(column: ColumnType<RecordType>): ColumnType<RecordType> {
|
||||
return { ...column, fixed: 'left' as const };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user