fix(ui): 修复固定列表头并优化官网指标配置
This commit is contained in:
@@ -89,11 +89,15 @@ const markFixedRight = (
|
||||
index,
|
||||
action = false,
|
||||
measuredWidths = {},
|
||||
containerWidth = 0,
|
||||
) => ({
|
||||
...column,
|
||||
fixed: 'right',
|
||||
width: action
|
||||
? actionWidth(column, measuredWidths[index])
|
||||
? Math.min(
|
||||
actionWidth(column, measuredWidths[index]),
|
||||
containerWidth > 0 ? Math.max(56, containerWidth) : Infinity,
|
||||
)
|
||||
: columnWidth(column),
|
||||
...(action ? { title: i18next.t('操作') || '操作' } : {}),
|
||||
className: [
|
||||
@@ -110,6 +114,22 @@ export function prepareCenterColumns(columns, width = 0, measuredWidths = {}) {
|
||||
const leaves = leafColumns(columns);
|
||||
const last = leaves.at(-1);
|
||||
const hasAction = last && isActionColumn(last);
|
||||
const pinnedWidth = hasAction
|
||||
? leaves.reduce(
|
||||
(total, column, index) =>
|
||||
total +
|
||||
(column === last
|
||||
? Math.min(
|
||||
actionWidth(column, measuredWidths[index]),
|
||||
width || Infinity,
|
||||
)
|
||||
: column.fixed
|
||||
? columnWidth(column)
|
||||
: 0),
|
||||
0,
|
||||
)
|
||||
: 0;
|
||||
const releaseOtherFixed = width > 0 && pinnedWidth > width;
|
||||
const estimatedTotal = leaves.reduce(
|
||||
(total, column) => total + columnWidth(column),
|
||||
0,
|
||||
@@ -125,8 +145,12 @@ export function prepareCenterColumns(columns, width = 0, measuredWidths = {}) {
|
||||
return { ...column, children: column.children.map(mapColumn) };
|
||||
const columnIndex = index++;
|
||||
if (hasAction && column === last)
|
||||
return markFixedRight(column, columnIndex, true, measuredWidths);
|
||||
return markFixedRight(column, columnIndex, true, measuredWidths, width);
|
||||
if (fallback.has(column)) return markFixedRight(column, columnIndex);
|
||||
if (releaseOtherFixed && column.fixed) {
|
||||
const { fixed: _fixed, ...scrollable } = column;
|
||||
return scrollable;
|
||||
}
|
||||
if (column.fixed) return { ...column, width: columnWidth(column) };
|
||||
return column;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user