fix(web): offset sticky table headers below layout header
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
// 列表表格使用页面纵向滚动与 sticky 表头吸顶,不设置表内纵向滚动。
|
||||
// 保留横向滚动、固定首列/操作列与分页(每页 20 条,单页隐藏分页条)。
|
||||
import { ProProvider, RouteContext } from '@ant-design/pro-components';
|
||||
import type { ColumnsType, ColumnType } from 'antd/es/table';
|
||||
import { useContext } from 'react';
|
||||
|
||||
export const TABLE_PAGE_SIZE = 20;
|
||||
|
||||
export function useTableSticky() {
|
||||
const { hasHeader, fixedHeader, layout } = useContext(RouteContext);
|
||||
const { token } = useContext(ProProvider);
|
||||
// ProLayout 的 mix 布局默认固定顶部栏;高度与其原生 token/default 保持一致。
|
||||
const headerHeight = token.layout?.header?.heightLayoutHeader || 56;
|
||||
return { offsetHeader: hasHeader && (fixedHeader || layout === 'mix') ? headerHeight : 0 };
|
||||
}
|
||||
|
||||
export function tablePagination() {
|
||||
return { pageSize: TABLE_PAGE_SIZE, hideOnSinglePage: true };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user