Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 36e2abf6
authored
Nov 11, 2026
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化table视觉
1 parent
f3cd7821
Pipeline
#403
for
36e2abf6
failed
in 0 seconds
Changes
9
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
256 additions
and
41 deletions
apps/web/shell/src/theme/design.css
docs/table-redesign.html
packages/biz/src/components/DataTable/index.tsx
packages/design-tokens/src/themeConfig.ts
packages/ui/src/components/FillTable/index.tsx
packages/ui/src/components/Table/index.tsx
packages/ui/src/components/Tag/index.tsx
packages/ui/src/hooks/useScrollbarRemeasure.ts
packages/ui/src/styles/ui.css
apps/web/shell/src/theme/design.css
View file @
36e2abf
...
@@ -673,7 +673,7 @@
...
@@ -673,7 +673,7 @@
/* 固定标题槽:起点与宽度由四列网格保证,字数差被槽内留白吸收 */
/* 固定标题槽:起点与宽度由四列网格保证,字数差被槽内留白吸收 */
.uj-chap-label
{
.uj-chap-label
{
font-size
:
13px
;
font-size
:
13px
;
font-weight
:
600
;
/* font-weight: 600; */
letter-spacing
:
0
;
letter-spacing
:
0
;
white-space
:
nowrap
;
white-space
:
nowrap
;
overflow
:
hidden
;
overflow
:
hidden
;
...
...
docs/table-redesign.html
0 → 100644
View file @
36e2abf
This diff is collapsed.
Click to expand it.
packages/biz/src/components/DataTable/index.tsx
View file @
36e2abf
...
@@ -137,13 +137,10 @@ export function DataTable<T extends object>({
...
@@ -137,13 +137,10 @@ export function DataTable<T extends object>({
// 行内操作按 small 出:默认高度会把每一行撑到 60px 以上,
// 行内操作按 small 出:默认高度会把每一行撑到 60px 以上,
// 两个四字操作并排就会换行,整行再翻一倍(见 .uj-row-actions 的 nowrap 说明)。
// 两个四字操作并排就会换行,整行再翻一倍(见 .uj-row-actions 的 nowrap 说明)。
size: isRowAction ? ('small' as const) : undefined,
size: isRowAction ? ('small' as const) : undefined,
style:
// 行内配色统一交给 @uj/ui 的 .uj-row-actions / .uj-row-action 规则。
isRowAction && type === 'text'
// 旧版在这里给每个 text 按钮塞内联 color(主色或 error),内联样式会压过
? {
// 组件层 CSS,导致「一行只留一个常驻彩色」这类规范根本无法收口。
color: action.danger ? 'var(--ant-color-error)' : 'var(--ant-color-primary)',
style,
...style,
}
: style,
};
};
return action.permission ? (
return action.permission ? (
...
@@ -156,20 +153,28 @@ export function DataTable<T extends object>({
...
@@ -156,20 +153,28 @@ export function DataTable<T extends object>({
</UButton>
</UButton>
);
);
};
};
// 操作列宽度:页面可显式给 actionColumnWidth,但多数页面估不准、给小了按钮就被列宽砍掉
// 操作列宽由「内容」决定,页面传值降级为下限建议。
// (.uj-row-actions 是 nowrap,不会换行、只会溢出)。这里按按钮文案自动算出所需宽度,
// 旧公式 Math.max(页面值, 估算值) 会无条件尊重页面拍出来的宽列:角色页传 280,
// 取「页面给的」与「算出来的」二者较大值——页面给大了尊重页面,给小了或没给就自动兜底。
// 三个按钮实际只需约 154px,多出的 94px 全变成「表头在左、按钮在右」之间的空白;
// 列宽是 fixed 布局下的硬约束,算出来的宽度已包住整组按钮,保证一行放得下、不被砍。
// 11 个列表页传了 80~280 共 8 种宽度,留白随页面随机变化,这是列表组件的通病。
const resolvedActionWidth =
// 现在把宽度钳制在 [估算值, 估算值+16px]:下限保证 fixed 布局下 nowrap 的按钮组
actionColumnWidth != null
// 不被裁掉,上限给动态文案(函数型 label 按 4 字估)留约一个汉字的余量。
? Math.max(actionColumnWidth, estimateActionWidth(rowActions))
const estimatedActionWidth = estimateActionWidth(rowActions);
: estimateActionWidth(rowActions);
const resolvedActionWidth = Math.min(
Math.max(actionColumnWidth ?? 0, estimatedActionWidth),
estimatedActionWidth + 16,
);
const actionColumn: ColumnsType<T>[number] | undefined = rowActions?.length
const actionColumn: ColumnsType<T>[number] | undefined = rowActions?.length
? {
? {
title: actionColumnTitle,
title: actionColumnTitle,
key: '__actions',
key: '__actions',
width: resolvedActionWidth,
width: resolvedActionWidth,
fixed: actionColumnFixed,
fixed: actionColumnFixed,
// 表头与单元格共用左锚点:内容由 .uj-row-actions 的 flex-start 落在 +16px,
// 表头也落在 +16px,不再出现「表头贴左、按钮贴右」的两个起点。
align: 'left',
// 固定右列的 1px 左边界由这个类名承担(见 ui.css),不依赖 antd 内部类名。
className: 'uj-table-cell-actions',
render: (_: unknown, record: T) => {
render: (_: unknown, record: T) => {
const visibleActions = rowActions.filter((action) => action.visible?.(record) ?? true);
const visibleActions = rowActions.filter((action) => action.visible?.(record) ?? true);
// 操作间距由 .uj-row-actions 的 gap 统一给:原来按「后面还有没有权限按钮」
// 操作间距由 .uj-row-actions 的 gap 统一给:原来按「后面还有没有权限按钮」
...
@@ -227,7 +232,7 @@ export function DataTable<T extends object>({
...
@@ -227,7 +232,7 @@ export function DataTable<T extends object>({
<TableComponent
<TableComponent
{...props}
{...props}
// 默认 medium:antd 的默认档是 large(上下各 16px padding),
// 默认 medium:antd 的默认档是 large(上下各 16px padding),
// 列表页因此比设计令牌(Table.cellPaddingBlockMD 1
1
)整整高出一档。
// 列表页因此比设计令牌(Table.cellPaddingBlockMD 1
2
)整整高出一档。
size={props.size ?? 'middle'}
size={props.size ?? 'middle'}
dataSource={dataSource}
dataSource={dataSource}
columns={tableColumns}
columns={tableColumns}
...
...
packages/design-tokens/src/themeConfig.ts
View file @
36e2abf
...
@@ -153,7 +153,9 @@ export const themeConfig: ThemeConfig = {
...
@@ -153,7 +153,9 @@ export const themeConfig: ThemeConfig = {
rowHoverBg
:
palette
.
surface
.
raised
,
rowHoverBg
:
palette
.
surface
.
raised
,
rowSelectedBg
:
palette
.
soft
.
info
,
rowSelectedBg
:
palette
.
soft
.
info
,
rowSelectedHoverBg
:
'#E4ECFD'
,
rowSelectedHoverBg
:
'#E4ECFD'
,
cellPaddingBlockMD
:
10
,
// 12 而非 antd middle 的默认 10:13px 正文配 12px 上下内距,行高约 46px,
// 与列表页「密但不挤」的节奏一致;紧凑场景由页面显式传 size="small"。
cellPaddingBlockMD
:
12
,
// 左右留白取 antd 的 middle 默认值 16,不再追「与卡片 20px 对齐」:
// 左右留白取 antd 的 middle 默认值 16,不再追「与卡片 20px 对齐」:
// 20px 会把 90~110px 的窄列挤到内容宽不足 4 个汉字,
// 20px 会把 90~110px 的窄列挤到内容宽不足 4 个汉字,
// 表头「变更次数」这类四字标题就换行,整行表头被撑成两倍高。
// 表头「变更次数」这类四字标题就换行,整行表头被撑成两倍高。
...
...
packages/ui/src/components/FillTable/index.tsx
View file @
36e2abf
import { Table, type TableProps } from 'antd';
import { Table, type TableProps } from 'antd';
import { useFillHeight } from './tools/useFillHeight';
import { useFillHeight } from './tools/useFillHeight';
import { useScrollbarRemeasure } from '../../hooks/useScrollbarRemeasure';
/**
/**
* 自动铺满父容器剩余高度的表格。
* 自动铺满父容器剩余高度的表格。
...
@@ -14,14 +15,21 @@ import { useFillHeight } from './tools/useFillHeight';
...
@@ -14,14 +15,21 @@ import { useFillHeight } from './tools/useFillHeight';
* 表体会塌成内容高度,补一个同样大小的下限才会铺满;
* 表体会塌成内容高度,补一个同样大小的下限才会铺满;
* 3) 空态高度用 --uj-fill-h 由占位单元格吃掉 —— 表头还在、空态垂直居中、分页落底。
* 3) 空态高度用 --uj-fill-h 由占位单元格吃掉 —— 表头还在、空态垂直居中、分页落底。
*
*
* scrollbarRemeasure:wujie 把细滚动条规则异步注入 shadowRoot 的时机可能晚于表格首次
* 挂载,导致 rc-table 那一次滚动条测量量到原生宽、表头永久错位(详见 hook 注释)。
* 等规则确实进入文档后强制重挂载一次,让 rc-table 重新测量。
*
* 用法:放在具有确定高度的 flex 容器内(.uj-card--fill > .ant-card-body)。
* 用法:放在具有确定高度的 flex 容器内(.uj-card--fill > .ant-card-body)。
*/
*/
export function FillTable<T extends object = Record<string, unknown>>(props: TableProps<T>) {
export function FillTable<T extends object = Record<string, unknown>>(props: TableProps<T>) {
const { wrapRef, size } = useFillHeight();
const { wrapRef, size } = useFillHeight();
// 只在 scroll.y 落地(表格进入最终滚动形态)后再判定重测时机
const remeasureEpoch = useScrollbarRemeasure(Boolean(size?.scrollY));
return (
return (
<div ref={wrapRef} className="uj-table-fill">
<div ref={wrapRef} className="uj-table-fill">
<Table
<Table
key={`uj-fill-${remeasureEpoch}`}
{...props}
{...props}
rootClassName="uj-table"
rootClassName="uj-table"
scroll={{ ...props.scroll, y: size?.scrollY ?? props.scroll?.y }}
scroll={{ ...props.scroll, y: size?.scrollY ?? props.scroll?.y }}
...
...
packages/ui/src/components/Table/index.tsx
View file @
36e2abf
import { Table, type TableProps } from 'antd';
import { Table, type TableProps } from 'antd';
import { useScrollbarRemeasure } from '../../hooks/useScrollbarRemeasure';
/**
/**
* 项目统一表格。
* 项目统一表格。
...
@@ -6,11 +7,16 @@ import { Table, type TableProps } from 'antd';
...
@@ -6,11 +7,16 @@ import { Table, type TableProps } from 'antd';
* rootClassName 统一挂 uj:表头底色、行 hover、分隔线、分页贴底这些规则
* rootClassName 统一挂 uj:表头底色、行 hover、分隔线、分页贴底这些规则
* 都在 @uj/ui 的 styles/ui.css 里以 .uj-table 为作用域,页面不需要自己写。
* 都在 @uj/ui 的 styles/ui.css 里以 .uj-table 为作用域,页面不需要自己写。
* 组件的几何量仍然由 themeConfig 的 Table token 下发。
* 组件的几何量仍然由 themeConfig 的 Table token 下发。
*
* scrollbarRemeasure:见 FillTable 同名字段注释 —— wujie 异步注入细滚动条规则可能晚于
* 首次挂载,强制表格在规则进入文档后重挂载一次,消除表头/表体错位。
*/
*/
export function UTable<T>(props: TableProps<T>) {
export function UTable<T>(props: TableProps<T>) {
const { size = 'middle', rootClassName, ...rest } = props;
const { size = 'middle', rootClassName, ...rest } = props;
const remeasureEpoch = useScrollbarRemeasure(true);
return (
return (
<Table<T>
<Table<T>
key={`uj-ut-${remeasureEpoch}`}
size={size}
size={size}
rootClassName={['uj-table', rootClassName].filter(Boolean).join(' ')}
rootClassName={['uj-table', rootClassName].filter(Boolean).join(' ')}
{...rest}
{...rest}
...
...
packages/ui/src/components/Tag/index.tsx
View file @
36e2abf
import { Tag, type TagProps } from 'antd';
import { Tag, type TagProps } from 'antd';
import type { ReactNode } from 'react';
export type UTagProps = TagProps;
export type UTagProps = TagProps;
/**
/**
* 把状态标签里的文字圆点「● 启用」收成 CSS 圆点(见 ui.css 的 .uj-tag--dot)。
* 页面常写成 `● {expr}`,children 会是 ['● ', '启用'] 这样的数组,两种形态都要认。
* 只处理以 ● 开头的标签,其余 children 原样透传,普通标签不受影响 ——
* 因此不必去改各列表页的文案,组件层一处收口即可全站统一。
*/
function splitDot(children: ReactNode): ReactNode | null {
const strip = (text: string) => text.replace(/^\s*●\s*/, '');
if (typeof children === 'string' && /^\s*●/.test(children)) return strip(children);
if (Array.isArray(children) && typeof children[0] === 'string' && /^\s*●/.test(children[0])) {
return [strip(children[0]), ...children.slice(1)];
}
return null;
}
/**
* 项目标签。
* 项目标签。
*
*
* 默认无描边:后台列表里的标签常成组出现(角色、场景、分类),每个都描一圈边会显得吵;
* 默认无描边:后台列表里的标签常成组出现(角色、场景、分类),每个都描一圈边会显得吵;
* 柔和填充 + 6px 圆角既分得清层级,又不抢正文。需要强分隔时显式传 bordered。
* 柔和填充 + 4px 圆角既分得清层级,又不抢正文。需要强分隔时显式传 bordered。
* 传「● 状态」时圆点自动改由 CSS 绘制,基线不随字体漂移。
*/
*/
export function UTag({ bordered = false, className, ...rest }: UTagProps) {
export function UTag({ bordered = false, className, children, ...rest }: UTagProps) {
const dotless = splitDot(children);
const hasDot = dotless !== null;
return (
return (
<Tag
<Tag
bordered={bordered}
bordered={bordered}
className={['uj-tag', className].filter(Boolean).join(' ')}
className={['uj-tag',
hasDot ? 'uj-tag--dot' : '',
className].filter(Boolean).join(' ')}
{...rest}
{...rest}
/>
>
{hasDot ? dotless : children}
</Tag>
);
);
}
}
packages/ui/src/hooks/useScrollbarRemeasure.ts
0 → 100644
View file @
36e2abf
import
{
useEffect
,
useState
}
from
'react'
;
/**
* 修复 wujie 子应用里「表头操作列宽 ≠ 表体」的错位。
*
* 根因:rc-table 在挂载时的 useLayoutEffect 里只测一次滚动条宽度(getTargetScrollBarSize),
* 之后永不重测。我们给表格加了「document 级细滚动条」规则(让表体滚动条收成 8px),
* 但 wujie 把 ui.css 异步注入 shadowRoot 的时机可能晚于表格首次挂载——
* 于是测量探针量到的是浏览器原生滚动条(Windows 约 15px),表头据此多预留约 7px,
* 而表体随后被规则收成 8px,表头比表体宽、且不会自愈。CSS 已就位的页面一次量准就对齐,
* 晚到的页面就错位(同一子应用内部分页对齐、部分不对齐,正是路由/分包加载时序不同)。
*
* 修法:等细滚动条规则确实进入当前文档(shadowRoot)后,把表格重挂载一次,
* 触发 rc-table 重新测量,此时探针量到的就是 8px,表头/表体一致。
* 已就位的页面重测后仍是 8px(无副作用);规则永远不进文档的极端情况两者都是原生宽也一致。
*
* 只在首次挂载后触发一次,之后不再干预,避免无限重挂。
*/
export
function
useScrollbarRemeasure
(
ready
:
boolean
):
number
{
const
[
epoch
,
setEpoch
]
=
useState
(
0
);
useEffect
(()
=>
{
if
(
!
ready
||
epoch
!==
0
)
return
;
let
raf1
=
0
;
let
raf2
=
0
;
let
timer
=
0
;
let
fired
=
false
;
const
ruleIsInDocument
=
():
boolean
=>
{
// 探针一个普通 div,读它的 ::-webkit-scrollbar 宽度(有细滚动条规则则非空,如 "8px");
// Firefox 走 scrollbar-width: thin。两者任一命中即说明规则已进入当前文档。
const
probe
=
document
.
createElement
(
'div'
);
probe
.
style
.
cssText
=
'position:absolute;left:-9999px;top:-9999px;width:100px;height:100px;overflow:scroll;'
;
document
.
body
.
appendChild
(
probe
);
const
cs
=
getComputedStyle
(
probe
,
'::-webkit-scrollbar'
);
const
webkitW
=
cs
.
width
;
const
firefoxW
=
getComputedStyle
(
probe
).
scrollbarWidth
;
document
.
body
.
removeChild
(
probe
);
return
(
!!
webkitW
&&
webkitW
!==
'0px'
&&
webkitW
!==
'auto'
)
||
firefoxW
===
'thin'
;
};
const
remeasure
=
()
=>
{
if
(
fired
)
return
;
fired
=
true
;
setEpoch
(
1
);
};
// 双 rAF:等 wujie 把 shadowRoot 样式注入完成后再判定;再兜底一个超时,
// 防止注入极慢时永远不触发(届时两者都是原生宽,本就一致,重挂无副作用)。
raf1
=
requestAnimationFrame
(()
=>
{
raf2
=
requestAnimationFrame
(()
=>
{
if
(
ruleIsInDocument
())
remeasure
();
});
});
timer
=
window
.
setTimeout
(
remeasure
,
400
);
return
()
=>
{
cancelAnimationFrame
(
raf1
);
cancelAnimationFrame
(
raf2
);
clearTimeout
(
timer
);
};
},
[
ready
,
epoch
]);
return
epoch
;
}
packages/ui/src/styles/ui.css
View file @
36e2abf
...
@@ -122,24 +122,48 @@ body {
...
@@ -122,24 +122,48 @@ body {
border-radius
:
var
(
--uj-radius-pill
,
999px
);
border-radius
:
var
(
--uj-radius-pill
,
999px
);
color
:
var
(
--uj-text-2
);
color
:
var
(
--uj-text-2
);
font-size
:
var
(
--uj-font-md
,
14px
);
font-size
:
var
(
--uj-font-md
,
14px
);
transition
:
color
0.2s
ease
,
background-color
0.2s
ease
;
transition
:
}
color
0.2s
ease
,
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
:hover:not
(
.ant-tabs-tab-active
)
{
background-color
0.2s
ease
;
}
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
:hover:not
(
.ant-tabs-tab-active
)
{
background
:
var
(
--uj-surface
);
background
:
var
(
--uj-surface
);
}
}
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
:hover
>
.ant-tabs-tab-btn
{
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
:hover
>
.ant-tabs-tab-btn
{
color
:
var
(
--uj-text-1
);
color
:
var
(
--uj-text-1
);
}
}
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab.ant-tabs-tab-active
>
.ant-tabs-tab-btn
{
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab.ant-tabs-tab-active
>
.ant-tabs-tab-btn
{
color
:
var
(
--uj-on-primary
);
color
:
var
(
--uj-on-primary
);
font-weight
:
600
;
font-weight
:
600
;
}
}
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab.ant-tabs-tab-disabled
{
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab.ant-tabs-tab-disabled
{
color
:
var
(
--uj-text-4
);
color
:
var
(
--uj-text-4
);
}
}
/* 滑块:复用 antd ink-bar,从「底部下划线」改为「撑满标签高度的圆角主色背景」,
/* 滑块:复用 antd ink-bar,从「底部下划线」改为「撑满标签高度的圆角主色背景」,
随选中项平滑滑动(z-index 低于标签,文字浮在其上)。 */
随选中项平滑滑动(z-index 低于标签,文字浮在其上)。 */
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-ink-bar
{
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-ink-bar
{
top
:
3px
;
top
:
3px
;
bottom
:
3px
;
bottom
:
3px
;
height
:
auto
;
height
:
auto
;
...
@@ -148,11 +172,18 @@ body {
...
@@ -148,11 +172,18 @@ body {
z-index
:
0
;
z-index
:
0
;
/* rc-tabs 默认用 inline left/width 定位滑块(indicator.align 非 center/end 时不走
/* rc-tabs 默认用 inline left/width 定位滑块(indicator.align 非 center/end 时不走
transform),动画必须同时覆盖 left/right/width 才跟手。 */
transform),动画必须同时覆盖 left/right/width 才跟手。 */
transition
:
left
0.28s
cubic-bezier
(
0.4
,
0
,
0.2
,
1
),
right
0.28s
cubic-bezier
(
0.4
,
0
,
0.2
,
1
),
transition
:
left
0.28s
cubic-bezier
(
0.4
,
0
,
0.2
,
1
),
right
0.28s
cubic-bezier
(
0.4
,
0
,
0.2
,
1
),
width
0.28s
cubic-bezier
(
0.4
,
0
,
0.2
,
1
);
width
0.28s
cubic-bezier
(
0.4
,
0
,
0.2
,
1
);
}
}
/* 键盘聚焦可见:胶囊形聚焦环。 */
/* 键盘聚焦可见:胶囊形聚焦环。 */
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
>
.ant-tabs-tab-btn
:focus-visible
{
.uj-page__tabs.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
>
.ant-tabs-tab-btn
:focus-visible
{
outline
:
none
;
outline
:
none
;
box-shadow
:
var
(
--uj-ring
);
box-shadow
:
var
(
--uj-ring
);
border-radius
:
var
(
--uj-radius-pill
,
999px
);
border-radius
:
var
(
--uj-radius-pill
,
999px
);
...
@@ -161,7 +192,11 @@ body {
...
@@ -161,7 +192,11 @@ body {
.uj-page__tabs--lg.ant-tabs
>
.ant-tabs-nav
{
.uj-page__tabs--lg.ant-tabs
>
.ant-tabs-nav
{
margin-bottom
:
var
(
--uj-space-4
,
16px
);
margin-bottom
:
var
(
--uj-space-4
,
16px
);
}
}
.uj-page__tabs--lg.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
{
.uj-page__tabs--lg.ant-tabs
>
.ant-tabs-nav
>
.ant-tabs-nav-wrap
>
.ant-tabs-nav-list
>
.ant-tabs-tab
{
padding
:
6px
16px
;
padding
:
6px
16px
;
font-size
:
var
(
--uj-font-xl
,
16px
);
font-size
:
var
(
--uj-font-xl
,
16px
);
line-height
:
24px
;
line-height
:
24px
;
...
@@ -187,7 +222,9 @@ body {
...
@@ -187,7 +222,9 @@ body {
font-weight
:
600
;
font-weight
:
600
;
line-height
:
1
;
line-height
:
1
;
font-variant-numeric
:
var
(
--uj-num
,
tabular-nums
);
font-variant-numeric
:
var
(
--uj-num
,
tabular-nums
);
transition
:
background-color
0.2s
ease
,
color
0.2s
ease
;
transition
:
background-color
0.2s
ease
,
color
0.2s
ease
;
}
}
.uj-tabs__count--primary
{
.uj-tabs__count--primary
{
background
:
var
(
--uj-primary
);
background
:
var
(
--uj-primary
);
...
@@ -378,21 +415,35 @@ body {
...
@@ -378,21 +415,35 @@ body {
min-height
:
var
(
--uj-table-body-h
,
0px
);
min-height
:
var
(
--uj-table-body-h
,
0px
);
overflow-y
:
auto
!important
;
overflow-y
:
auto
!important
;
}
}
/* 表体滚动条收细:默认 15px 的槽在密集表格里太抢眼,
/* 表体滚动条收细:默认 15px 的槽在密集表格里太抢眼。
而且横向滚动条越窄,表体可视高度越接近测量值。 */
关键:这条规则必须是「document 级、不依赖 .ant-table-body 祖先类」的全局形态,
.uj-table-fill
.ant-table-body
{
不能只写在 .uj-table-fill .ant-table-body 上 —— 否则会复现「表头操作列宽 ≠ 表体」错位。
真正的根因(已用 antd 真实 Table headless 复现 + 实测验证):rc-table 在挂载时
用 useLayoutEffect([]) 只测一次滚动条宽度(getTargetScrollBarSize),之后永不重测,
还会强制覆盖任何传入的 scrollbarSize prop。wujie 把 ui.css 注入子应用 shadowRoot 是异步的,
时机受路由/分包影响,可能晚于表格首次挂载 —— 于是首次测量量到浏览器原生宽(Windows 约 15px),
表头据此预留、而表体随后被本规则收成 8px,永久差约 5px 且不自愈。同子应用内 CSS 早到的页
一次量准就对齐,晚到的页错位。
配套修复见 packages/ui/src/hooks/useScrollbarRemeasure.ts:等本规则确实进入文档后强制表格
重挂载一次、触发 rc-table 重测。本规则必须写成全局(而非 scoped),因为 rc-table 的测量探针
是挂在 document.body 上的普通 div,匹配不到 .uj-table-fill .ant-table-body 这类选择器,
只有全局规则才能在重测时让它读到的宽度(8px)= 真实表体的宽度(8px)。 */
*
{
scrollbar-width
:
thin
;
scrollbar-width
:
thin
;
scrollbar-color
:
var
(
--uj-border-strong
)
transparent
;
scrollbar-color
:
var
(
--uj-border-strong
)
transparent
;
}
}
.uj-table-fill
.ant-table-body
::-webkit-scrollbar
{
::-webkit-scrollbar
{
width
:
8px
;
width
:
8px
;
height
:
8px
;
height
:
8px
;
}
}
.uj-table-fill
.ant-table-body
::-webkit-scrollbar-thumb
{
::-webkit-scrollbar-thumb
{
border-radius
:
4px
;
border-radius
:
4px
;
background
:
var
(
--uj-border-strong
);
background
:
var
(
--uj-border-strong
);
}
}
.uj-table-fill
.ant-table-body
::-webkit-scrollbar-track
{
::-webkit-scrollbar-thumb:hover
{
background
:
var
(
--uj-border-strong
);
}
::-webkit-scrollbar-track
{
background
:
transparent
;
background
:
transparent
;
}
}
...
@@ -518,19 +569,74 @@ body {
...
@@ -518,19 +569,74 @@ body {
/* 行内操作:间距由容器给,避免每列自己写 marginRight。
/* 行内操作:间距由容器给,避免每列自己写 marginRight。
不换行是刻意的:换行只会在「列宽差几像素」时发生,代价是把整行撑高一倍,
不换行是刻意的:换行只会在「列宽差几像素」时发生,代价是把整行撑高一倍,
而列宽本身是页面给的配置(actionColumnWidth),该改配置而不是靠换行兜底。 */
而列宽现在由 DataTable 按按钮文案自动估算,不该靠换行兜底。
左对齐不是审美选择:表头「操作」落在单元格 +16px,按钮组必须落在同一条线上。
旧版 flex-end 把按钮推到列右端,宽列里就出现「表头贴左、按钮贴右」的两个锚点。 */
.uj-row-actions
{
.uj-row-actions
{
display
:
flex
;
display
:
flex
;
flex-wrap
:
nowrap
;
flex-wrap
:
nowrap
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
flex-
end
;
justify-content
:
flex-
start
;
white-space
:
nowrap
;
white-space
:
nowrap
;
gap
:
var
(
--uj-space-1
,
4px
);
gap
:
var
(
--uj-space-1
,
4px
);
}
}
/* 一行只留一个常驻彩色:首项是该行的主操作,其余退到中性色。
删除不常驻亮红 —— 它已有二次确认弹窗,常驻红只会把视线从数据拉走,
hover / 键盘聚焦才亮语义色。三级作用域压过 antd cssinjs 的 .ant-btn-text 规则。
几何量(高度、内距)仍由 Button token 下发,这里只收口颜色与 hover 反馈。 */
.uj-table
.uj-row-actions
.ant-btn.ant-btn-text
{
border-radius
:
var
(
--uj-radius-sm
);
color
:
var
(
--uj-text-2
);
}
.uj-table
.uj-row-actions
.ant-btn.ant-btn-text
:first-child:not
(
.ant-btn-dangerous
)
{
color
:
var
(
--uj-primary
);
}
/* 按钮 hover 时整行必然已变浅蓝,白底把热区浮出来比再叠一层淡蓝更可辨识。 */
.uj-table
.uj-row-actions
.ant-btn.ant-btn-text
:hover
{
background
:
var
(
--uj-surface
);
color
:
var
(
--uj-primary
);
}
.uj-table
.uj-row-actions
.ant-btn.ant-btn-text.ant-btn-dangerous
:hover
{
background
:
var
(
--uj-error-soft
);
color
:
var
(
--uj-error
);
}
.uj-table
.uj-row-actions
.ant-btn.ant-btn-text
:focus-visible
{
outline
:
2px
solid
var
(
--uj-primary
);
outline-offset
:
1px
;
}
/* 表头下边界比行线深一档,把表头「坐实」;行线仍由 Table token 的 borderColor 给。
不加阴影、不加斑马纹 —— 横向滚动 + 固定右列时斑马纹会露出错位。 */
.uj-table
.ant-table-thead
>
tr
>
th
{
border-bottom
:
1px
solid
var
(
--uj-border
);
}
/* 固定右操作列的 1px 左边界:横向滚动时明确「这列是钉住的」。
类名由 DataTable 的 actionColumn.className 下发,不依赖 antd 内部类名,
也不会误伤页面里其它自定义的固定列。 */
.uj-table
.uj-table-cell-actions
{
box-shadow
:
inset
1px
0
0
0
var
(
--uj-border
);
}
/* 一组标签:间距同样由容器给,多个标签时不会挤成一串。 */
/* 一组标签:间距同样由容器给,多个标签时不会挤成一串。 */
.uj-tag-list
{
.uj-tag-list
{
display
:
inline-flex
;
display
:
inline-flex
;
flex-wrap
:
wrap
;
flex-wrap
:
wrap
;
gap
:
var
(
--uj-space-1
,
4px
);
gap
:
var
(
--uj-space-1
,
4px
);
}
}
/* 状态标签里的文字圆点「●」由 UTag 自动收成 6px CSS 圆点:
基线与直径不再随字体、字号漂移,启用 / 停用共用同一形状。 */
.uj-tag--dot
{
display
:
inline-flex
;
align-items
:
center
;
gap
:
5px
;
}
.uj-tag--dot
::before
{
content
:
''
;
flex
:
none
;
width
:
6px
;
height
:
6px
;
border-radius
:
50%
;
background
:
currentColor
;
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment