NEX 阶段 6 拆 kit 与清死代码:Panel/Controls 按职责分成五份、删 7 个 0 调用导出与 2 个死 hook、R8 承认 app 为外壳层

main
mula.liu 2026-11-07 18:21:47 +08:00
parent bc5d1bcc90
commit 3e86b282e0
22 changed files with 521 additions and 610 deletions

View File

@ -100,11 +100,11 @@ NEX 与本项目差异用「项目适配」解决,**不得反向修改本项
|---|---|---|---|
| §1 组件分层 / §2 包装原则 | COMPLIANT | `components/ui/`(21 文件)+ `components/forms/`(6 文件)= 27 文件 / 151 具名导出 | 页面从 kit 取件(R8),kit 包住 antd 并只暴露档位 |
| §3.1 NexPageHeader | COMPLIANT | `ui/Page.tsx::PageHead` | 已含 actions / 描述 / 层级 |
| §3.2 NexSearchToolbar | COMPLIANT | `ui/Page.tsx::Ctlbar` + `ui/Controls.tsx::ChipBar/SearchInput` | 含 `tableaudit`/`btnclustercheck` 把关 |
| §3.2 NexSearchToolbar | COMPLIANT | `ui/Ctlbar.tsx::Ctlbar/ChipBar` + `ui/Input.tsx::SearchInput` | 含 `tableaudit`/`btnclustercheck` 把关 |
| §3.3 NexDataTable | COMPLIANT | `ui/Table.tsx`(含键盘行导航)+ R17 行高预算 | 超出 NEX 要求:常驻 `tableaudit.py` |
| §3.4 NexStatCard | COMPLIANT | `ui/Panel.tsx::Stat/StatGrid` + R16 纯色统计卡 | — |
| §3.5 NexModal / NexDrawer | COMPLIANT | `ui/Overlay.tsx::{Modal,Drawer,Scrim,ConfirmHost}` + `DRAWER_HEAD/BODY/ACTIONS` | 三段式与底部动作条口径由 `classaudit` 第 4 闸验 |
| §3.6 NexPageState | **COMPLIANT**(阶段 4) | `ui/Panel.tsx::{Empty,SkeletonBlock,Notice}`、`ui/Button.tsx::ErrorText`、`pages/{Forbidden,NotFound}.tsx`、`UI规范.md` §13.8 | Empty **三分类**(没数据/没匹配/引导)是本项目成熟设计,保留(ADAPTED)。阶段 4 补齐六态表面:首屏 `SkeletonBlock`(路由兜底 / 页面首屏 / 抽屉正文三类落点)、权限不足 `Forbidden`、地址不存在 `NotFound`(`path:'*'` 不再静默跳首页,`visualcheck` 名单 +1 条并断言文案)。旧 `<Loading>` 随最后一处首屏调用一起删除 |
| §3.6 NexPageState | **COMPLIANT**(阶段 4) | `ui/State.tsx::{Empty,SkeletonBlock,Notice}`(阶段 6 起六态表面单独成文件)、`ui/Button.tsx::ErrorText`、`pages/{Forbidden,NotFound}.tsx`、`UI规范.md` §13.8 | Empty **三分类**(没数据/没匹配/引导)是本项目成熟设计,保留(ADAPTED)。阶段 4 补齐六态表面:首屏 `SkeletonBlock`(路由兜底 / 页面首屏 / 抽屉正文三类落点)、权限不足 `Forbidden`、地址不存在 `NotFound`(`path:'*'` 不再静默跳首页,`visualcheck` 名单 +1 条并断言文案)。旧 `<Loading>` 随最后一处首屏调用一起删除 |
| §4 NexDocus 现有组件迁移映射 | **NOT APPLICABLE** | — | 映射表左列是 NexDocus 的组件名 |
| §5 组件代码约定 | COMPLIANT | `UI规范.md` §0 R10(ref 透传契约)、R8(`app.css` 是全站唯一 `.ant-*` 出口)、组件不内聚数据请求 | — |
| (隐含)组件以 npm 包形式提供 | **ADAPTED**(E7) | `nex.config.yaml` `components.nex_react_package: forbidden` | 用本项目 kit,不引入第二套 NEX React 组件包 |
@ -145,7 +145,7 @@ NEX 与本项目差异用「项目适配」解决,**不得反向修改本项
| §2 焦点与键盘 | COMPLIANT(+ 阶段 2 增补拖拽替代) | `app.css` 全站 `:focus-visible` 兜底;`ui/Table.tsx`、`MediaThumb.tsx`、`AgentConsole.tsx` 键盘处理;`lib/layers.ts::floatingLayerOpen` 分层 Esc | 拖拽排序的键盘替代 NEX 未覆盖 → **N14**,阶段 2 一并补 |
| §3 对比度 / 状态不只靠颜色 | COMPLIANT | `UI规范.md` §2.1(标签=点+文字,非仅颜色)、`Status` 文案来自 `lib/format.ts::statusLabel` | 状态一律「点 + 文字」双通道 |
| §4 响应式(明确滚动容器) | COMPLIANT;侧栏 <768 **DEFERRED(待产品决策)** | `UI规范.md` §0 R13/R15;`LogBox`/`Drawer` 滚动容器在组件内 | — |
| §5 内容与长文本(截断须给完整文案) | COMPLIANT(标签一处破口 **本轮阶段 1 修**) | `ui/Panel.tsx::Clamp`、`min-w-0` 约定、`app.css:425-430`(`.nex-tag-text` 省略)| 分镜卡状态标签截断后**取不到完整文案**(缺 `title`)→ D1,阶段 1 修并补探针 |
| §5 内容与长文本(截断须给完整文案) | COMPLIANT(标签一处破口 **本轮阶段 1 修**) | `ui/Table.tsx::Clamp`、`min-w-0` 约定、`app.css:425-430`(`.nex-tag-text` 省略)| 分镜卡状态标签截断后**取不到完整文案**(缺 `title`)→ D1,阶段 1 修并补探针 |
| §6 动效与性能 | COMPLIANT | 路由懒加载 + 空闲预取(`app/App.tsx`) | 大数据虚拟化列 **DEFERRED** 为观察项(实测最大列表受 `page_size` 约束) |
### 2.9 `docs/09-agent-execution-rules.md` — Agent 执行规则
@ -278,9 +278,11 @@ cd frontend/src && grep -roh -- '--nex-[a-z0-9-]*' . | sort | uniq -c | sort -rn
| # | 漂移 | 现状 | 建议 |
|---|---|---|---|
| **R8 文档白名单口径** | `UI规范.md` 写的允许 import antd 的范围是 `theme/`、`app/providers.tsx`、`components/{ui,forms}`、`app/layout/`;`classaudit.py` 第 5 闸实际放行整个 `app/` | 结果:`app/App.tsx:21` 裸用 `Button/Flex/Layout/Spin`、`app/ErrorBoundary.tsx:17` 裸用 `Result/Typography` 都能通过 | 二选一(下轮决策):① 文档承认「外壳层可直接用 antd」;② 收紧探针到 `app/layout/`。倾向 ① —— 外壳层与 kit 的差别是「只此一份、不扩散」 |
| ~~R8 文档白名单口径~~ | ✅ **阶段 6 已解决(采纳 ①)** | 文档与探针原本各说各话:`UI规范.md` R8 只放行到 `app/layout/`,第 5 闸实际放行整个 `app/`(`app/App.tsx:21` 裸用 `Button/Layout`、`app/ErrorBoundary.tsx:17` 裸用 `Result/Typography`) | R8 改写为「`theme/` · **`app/` 整个外壳层** · `components/{ui,forms}`」并与 §15.1 同一口径。理由:外壳只此一份、不往 `pages/` 扩散,包一层只会多一个名字;真正要拦的是**页面** import 组件库。② 收紧探针被否——那会把 `App.tsx` 的首屏骨架与错误边界再包一层空壳 |
| kit 里两个 0 调用但**故意保留**的名字 | `ui/Page.tsx::Breadcrumb`(antd `Breadcrumb` 的薄封装)与 `ui/Controls.tsx`→`ui/Ctlbar.tsx::RadioGroup`(antd `Radio.Group` 封装)当前 0 处调用 | 阶段 6 决策:**不删**。`Breadcrumb` 是 NEX 04 §7 详情/层级导航的唯一落点,删了下次做层级页就得重造;`RadioGroup` 是 R19/§9 里「互斥选项」的唯一名字(分段切换用 `Segmented`,二选一互斥表单用 `RadioGroup`)。复核口径:下一个用到它的页面必须同时删掉本行;若连续两轮仍未被使用,转删除 |
| **D16 kit `Tag` 吞 className**(阶段 1 新发现) | `components/ui/Status.tsx::Tag` 形参收了 `className`,但下面的 `cn('nex-tag', …)` 没有把它并进去 → 页面写 `<Tag className=…>` / `<Status className=…>` **全部空转**(同文件的 `Badge`、`TagGroup` 都并了;`Chip` 走 antd `Tag`,不受影响) | 受影响 10 处:`app/layout/ActivityCenter.tsx:70`、`pages/ModelCenter.tsx:959`、`pages/project/Dispatch.tsx:405,457`、`pages/project/Review.tsx:363`、`pages/project/Timeline.tsx:727`、`pages/project/Storyboard.tsx:1976,1978`、`pages/project/AgentConsole.tsx:551`(原 `app/layout/PipelineConsole.tsx:155` 已用外套 `<span>` 绕过,现渲染于 `:165`,见下) | **本轮不修**:修好后会同时点亮两处真实视觉变化——ModelCenter 的实心蓝「默认」标签、分镜卡缩略图上的 `absolute` 角标——越出阶段 1 授权(「不得引入额外视觉改动」)。**修法(下轮)**:`className` 并进 `cn()`,然后逐站点回归那 10 处;`PipelineConsole:165` 与 `Storyboard:1995` 的两层 `<span>` 包装届时可撤 (两处代码注释已写明「D16 修好后可撤」) |
| **D17 窄屏顶栏项目名压到品牌块**(阶段 2 复测新发现) | 430 视口下 `.nex-console` 内容比自己的盒子还宽(改前 `scrollWidth` 214 / `clientWidth` 173 → 项目名 `<strong>` 从 x=57 起,压住品牌块 49..81;阶段 1 收口后 203/170,窄了 11px,**同一处问题改前就存在**) | 不是阶段 1/2 引入的回归;影响 430 一档的顶栏可读性,且让 `elementFromPoint` 类探针在品牌块处拿到错的节点 | **本轮不修**:修法要么缩顶栏内容、要么改窄屏品牌块形态,二者都属「Header 尺寸/移动端导航形态」(授权 §八 明确排除)。留待与 N7 一起决策(阶段 5 已用于反馈预算,未包含导航形态;A/B 方案见实施报告) |
| 阶段 6 交付项 | kit 拆分与死代码清理:`ui/Panel.tsx` → `Panel`(容器与栅格)+ `State`(六态表面)+ `Info`(只读回显);`ui/Controls.tsx` → `Ctlbar`(控件栏与胶囊)+ `Fields`(字段);`ROW_STEPS` 并入 `grid.tsx`(等分控件栏与 `FormRow` 共读一张降列表);出口仍是 `ui/index.ts`,**业务页 0 diff**,净代码行 655 → 650。删死代码 7 个:`useAsync`、`usePolling`(连带删两个 hook 文件)、`navItemAt`、`Page.Sub`、`Controls.Req`、`Panel.Meta`、`forms/options.summaryOf`、`forms/Select.SelectOptionList`;`Breadcrumb` / `RadioGroup` **保留待用**(见下一行);`classaudit` 第 6 闸 `FB_IMPL` 白名单同步认出 `State.tsx` | ✅ 已完成(见 §7) | 明细见 `reports/NEX阶段4-7实施-2026-11-07.md` |
| 阶段 5 交付项 | 反馈预算(N10)落地:`UI规范.md` §13.3 ⑤ 新增两条预算 + 判据;`ModelCenter` 两颗开关补吐司、「已保存/已删除」从抽屉外的页头 `Notice` 改走吐司(页内 `Notice` 只留错误与故障注入);`Library` 5 处裸 `confirm()` → `confirmAction`,录音链 3 颗 → 1 颗(`lib/versions.ts::keepOrRestoreCurrent` 加 `sink` 出口,默认 `notify` 故平台资产库零改动);`Dashboard` 统计卡 xs 档降列改两列(430 首屏可见第一张项目卡);`classaudit` 第 6 闸正则放宽并修掉「只匹配 `window.confirm(`」的反向漏检 | ✅ 已完成(见 §7) | 明细见 `reports/NEX阶段4-7实施-2026-11-07.md` |
| 阶段 4 交付项 | 六态表面(首屏骨架 / 抽屉正文骨架 / Forbidden / NotFound)已落地,`visualcheck` 名单 14 → 15 | ✅ 已完成(见 §7) | 明细见 `reports/NEX阶段4-7实施-2026-11-07.md` |
| 阶段 1–3 交付项 | 阶段 1(截断兜底 + 探针)、阶段 2(3 处热区可键盘化)、阶段 3(`LAYER` 层级表 + 两处真实遮挡修复)均已落地;N14 拖拽键盘替代除外 | ✅ 已完成(见 §7 三行记录) | 明细见 `reports/NEX阶段0-3实施-2026-11-07.md` |
@ -295,7 +297,8 @@ cd frontend/src && grep -roh -- '--nex-[a-z0-9-]*' . | sort | uniq -c | sort -rn
| 2026-11-07 | 阶段 0 建档:逐条判定 NEX 0.1.1 全文、登记例外 E1–E10、建立别名表、收敛反向清单 N1–N15 | Codex(阶段 0) |
| 2026-11-07 | 阶段 1 落地截断兜底:`visualcheck.py` 新增 `tagtitle` 探针、`ui/Status.tsx` 组件级 `title` 兜底、分镜卡状态标签与顶栏流水线台收口;`UI规范.md` §2.1/§15.2 补「信息标签可截断但必须有兜底」口径;登记缺陷 **D16**(见 §6) | Codex(阶段 1) |
| 2026-11-07 | 阶段 2 三处非语义热区可键盘化:分镜卡 `<article>` 加 `tabIndex/aria-label/aria-current` + Enter/Space (守卫 `ev.target === ev.currentTarget`,不套 `role=button` 以免抹掉卡内控件);`ui/Rows.tsx::LogRow` 加 `clickable` 分支(role/tabIndex/onKeyDown,保留 `title` 语义与逐字颜色);`AppHeader.tsx` 品牌区由 `onClick + navigate` 改为真实 `<Link>`,头像与平台名合并为**一个**焦点站点(1440 下块宽 138px 与合并前一致)。登记缺陷 **D17**(见 §6) | Codex(阶段 2) |
| 2026-11-07 | 阶段 4 补齐六态表面:新增 `ui/Panel.tsx::SkeletonBlock`(antd `Skeleton` + `role=status` + `sr-only` + `.nex-skeleton` 闸门落点,不传 `label` 时整块 `aria-hidden` 以免一屏播两句进度)与两页兜底 `pages/Forbidden.tsx`(`AuthGate` 拦住非管理员时就地解释,权限规则未变)、`pages/NotFound.tsx`(`router.tsx` 的 `path:'*'` 不再静默 `Navigate` 回首页);`Drawer` 新增 `loading` 并接入 `ProjectBriefDrawer`;三处首屏 `<Loading>` 换成骨架后旧导出连同其 antd `Spin` import 一并删除;`UI规范.md` 新增 §13.8 六态表面 + §10 抽屉骨架口径 + §15.2 名单 14→15;`visualcheck.py` 增加 `/not-a-page` 探针(不入 `NAV_ROUTES`)与「页面不存在」文案断言 | Codex(阶段 4) |
| 2026-11-07 | 阶段 4 补齐六态表面:新增 `ui/Panel.tsx::SkeletonBlock`(阶段 6 起在 `ui/State.tsx`)(antd `Skeleton` + `role=status` + `sr-only` + `.nex-skeleton` 闸门落点,不传 `label` 时整块 `aria-hidden` 以免一屏播两句进度)与两页兜底 `pages/Forbidden.tsx`(`AuthGate` 拦住非管理员时就地解释,权限规则未变)、`pages/NotFound.tsx`(`router.tsx` 的 `path:'*'` 不再静默 `Navigate` 回首页);`Drawer` 新增 `loading` 并接入 `ProjectBriefDrawer`;三处首屏 `<Loading>` 换成骨架后旧导出连同其 antd `Spin` import 一并删除;`UI规范.md` 新增 §13.8 六态表面 + §10 抽屉骨架口径 + §15.2 名单 14→15;`visualcheck.py` 增加 `/not-a-page` 探针(不入 `NAV_ROUTES`)与「页面不存在」文案断言 | Codex(阶段 4) |
| 2026-11-07 | 阶段 6 拆 kit 与清死代码:`ui/Panel.tsx` 拆出 `ui/State.tsx`(ProgressBar/Empty/SkeletonBlock/Spinner/Notice)与 `ui/Info.tsx`(Value/LineHint/Mono/ExtLink/Info/Count),`ui/Controls.tsx` 拆成 `ui/Ctlbar.tsx` 与 `ui/Fields.tsx` 后删除原文件,`ROW_STEPS` 移进 `grid.tsx`;`components/ui/index.ts` 出口扩到 5 个模块,业务页 0 改动;删 7 个 0 调用导出与 2 个死 hook 文件;R8 承认 `app/` 为外壳层(解本文件 §6 第一条漂移),`UI规范.md`/`工程规范.md`/`app.css`/`App.tsx`/`Status.tsx` 五处实现路径同步 |
| 2026-11-07 | 阶段 5 定反馈预算(N10):`UI规范.md` §13.3 新增 ⑤「一次操作的反馈预算」(实测三页 notify 计数 + 每操作链颗数、两条预算、判据「吐司说成了,页面说成什么样」);`pages/ModelCenter.tsx` 的 `patchRow` 补一颗结果吐司(启用/停用/设为默认此前零反馈),`save`/`remove` 的页头 `Notice` 改 `notify({title,desc})` 并删除 `notice` state(页内 `Notice` 只留 `error` 与故障注入两处持续状态);`pages/project/Library.tsx` 5 处裸 `confirm()` → `await confirmAction({title,desc,tone,confirmIcon})`,`onRecord` / `recordGenerationReference` 经新增的 `speak`/`joinLines` 合成一颗;`lib/versions.ts::keepOrRestoreCurrent` 新增第三形参 `sink`(默认 `notify`,平台资产库两个调用点未改);`scripts/ui/classaudit.mjs` 第 6 闸正则从只匹配 `window.confirm(` 放宽为 `/(?<![\w.$])(?:window\.)?(?:confirm|alert)\s*\(/` 并写入十一例自查(阶段 5 曾把可选前缀写在 lookbehind 之前,导致 `window.confirm(` 反向漏检);`pages/Dashboard.tsx` 统计卡 `steps={[{at:'lg',cols:2}]}` 只改 xs 一档 | Codex(阶段 5) |
| 2026-11-07 | 阶段 3 建立层级表:新增 `lib/layers.ts::LAYER`(header 20 / toolbar 40 / scrim 55 / sheet 60 / antd 1000 / preview 1020 / recorder 1030 / confirm 1190 / toast 1200),7 处浮层改为引用 `LAYER.*`(AppHeader 顶栏 / Page 粘性工具条 / Overlay 遮罩 / Storyboard 检查器 / MediaLightbox 灯箱 / RecordAudio 录音面板 / Confirm 确认框,`Overlay::Modal` 并新增可选 `zIndex` 形参),另有 2 条必须贴在 antd 节点上的 CSS 值(`app.css` 1100 / 1200)保持原数并加注释指回层级表;修掉两条**实测存在**的遮挡(抽屉里点开灯箱看不见、声线抽屉里录音面板点不着),并给确认框第一次显式层级以免灯箱抬升后压不住;`UI规范.md` §10 重写(层级表 + 修正过时的「挂载点」口径 + 两条「不进表」例外) | Codex(阶段 3) |

View File

@ -34,7 +34,7 @@
| R5 | **筛选项准入**:① 对应后端真实参数 ② 有可达的非默认值 ③ 与页面顶部大分类一致;三者缺一就删(清单见 §12) | 「每页」属于分页条,不属于筛选栏 |
| R6 | **控件一律来自 antd**(经 `components/{ui,forms}` 封装):`pages/` 与 `app/` 里裸 `<input>` `<select>` `<textarea>` `<button>` `input[type=checkbox]` `input[type=range]` 全站清零,也不许在原生控件上贴 CSS 补丁 | 130+ 个原生 input 打补丁这条路已被证明走不完 |
| R7 | **同一个容器只用一种字段形态**:`<Field inline>`(标签在左,只属于控件栏 / 筛选条)与 `<Field>` / `<FieldBlock>`(标签在上,只属于表单 / 抽屉,后者就是前者加 `width="full"`)不许混排——两者控件左缘天生差一个标签列宽;窄列(< 240px)一律竖排 | `/review` 同一列量出三种控件左缘,最大右移 47.3px |
| R8 | **`import 'antd'` 只允许出现在**:`theme/`、`app/providers.tsx`、`components/ui/`、`components/forms/`,外加 `app/layout/`(外壳四件套 AppHeader/AppSider/UserMenu/PipelineConsole 直接铺 `Layout.*`,是有意为之:外壳没有第二个实现,包一层只会多一个名字)。`pages/` 一律只认 kit 给出的名字。**这条由 `classaudit.mjs` 第 5 道闸逐行扫,不靠自觉** | 页面直接 import 组件库 = 主题与档位再也收不口 |
| R8 | **`import 'antd'` 只允许出现在**:`theme/`、`app/providers.tsx`、`components/ui/`、`components/forms/`,外加 **`app/` 整个外壳层**(`app/layout/` 四件套 AppHeader/AppSider/UserMenu/PipelineConsole 直接铺 `Layout.*`,`app/App.tsx` 铺 `Layout` 与首屏骨架,`app/ErrorBoundary.tsx` 用 `Result` 兜分包失败。有意为之:外壳只有这一份、不往页面扩散,包一层只会多一个名字。探针第 5 闸放行的就是这个范围,本条与 §15.1 自阶段 6 起同一口径)。`pages/` 一律只认 kit 给出的名字。**这条由 `classaudit.mjs` 第 5 道闸逐行扫,不靠自觉** | 页面直接 import 组件库 = 主题与档位再也收不口 |
| R9 | **不写私档数字**:`bg-[#...]`、`text-[13px]`、`rounded-[7px]`、`leading-[1.9]`、`w-[3px]`、自造断点一律禁止;颜色/字号/圆角/间距只准用转发到 `--ant-*` 的语义名,或者 Tailwind 的 4px 栅格(`gap-3` = 12 = `marginSM`)。响应式宽度 `w-[min(...)]` 与贴在内容上的尺寸 prop 例外 | 任意值是「第二把尺子」的入口,一旦允许就会长回手写规范 |
| R10 | **ref 契约**:kit 一律 `forwardRef`,ref 只交 DOM 节点,组件库句柄不外泄(折法唯一,见 `lib/ref.ts`) | `ref?:` 写在 props 里 tsc 照过、运行时只 warn,功能静默没了 |
| R11 | **图标只用 `@ant-design/icons`,且只在 `components/icons/index.ts` 一处 import**。自绘 `Icon.tsx`/`glyphs.ts` 已删,目录只剩这张语义登记表;页面写的是语义名(`IconGrid`/`IconWarn`),字形名只出现在表里。纯图标按钮必须带 `title` + `aria-label`(`<IconButton>` 把 label 同时喂给两者) | 收口前有 32 个文件散着 import 73 只图标,「同一个意思该长什么样」全站无一处可查;40 个手绘 glyph 更是同一只「会亮的方块」长出五种长相的根源 |
@ -58,7 +58,7 @@
| **主题覆盖** | `theme/antd.ts` 的 `buildAntdTheme(mode)`(全站唯一 `ThemeConfig`) | **只改两类**:① 表面色(layout/container/elevated/描边/外壳三段)② 少量结构性 ComponentToken(Menu 密度与选中态、Table 表头与分割线、Layout、Drawer 等)。**品牌色不改**:`SEED` 里没有 `colorPrimary`,主色就是 antd 出厂蓝(light `#1677ff` / dark `#1668dc`) | 尺寸档位、圆角、字号、主色与它的整条派生梯度——**一个都不覆盖** |
| **变量落地** | `theme/antd.ts::applyRootVars()`(`stores/theme.ts` 在切主题时调用) | 把 antd 落不下来的 token 手写到 `<html>` 上:`color*`、`borderRadius*`、`boxShadow*`、`fontFamily/Size/Weight`、`lineHeight*`、`controlHeight*`、`margin*`、`padding*`、`screen*`;末尾追加派生变量 `--nex-bar` | 新增私有数字(它只做转发) |
| **布局** | `styles/app.css`(`.nex-*` / `.nf-*` 语义类)+ Tailwind utility | 字段栅格、控件栏、chip 行、标签组、抽屉三段、滚动区、浮层层级;**全站唯一允许出现 `.ant-*` 选择器的地方** | 控件本体 |
| **语义** | `components/ui/` `components/forms/` | `Field` `FormRow` `Select` `Check` `Slider` `Button` `Menu` `Drawer` `Modal` `Table` `Tag` `Status`… 这些页面认识的名字(导出名与旧版一致,473 处 import 没动) | 直接 `import 'antd'`(R8) |
| **语义** | `components/ui/` `components/forms/`(`ui/` 内部按职责分文件——容器 `Panel` · 状态 `State` · 回显 `Info` · 控件栏 `Ctlbar` · 字段 `Fields`,页面只认 `ui/index.ts` 这一个出口) | `Field` `FormRow` `Select` `Check` `Slider` `Button` `Menu` `Drawer` `Modal` `Table` `Tag` `Status`… 这些页面认识的名字(导出名与旧版一致,473 处 import 没动) | 直接 `import 'antd'`(R8) |
### 1.1 层叠:Tailwind v4 的 `@layer` 会把布局 utility 吃掉(R13 的来龙去脉)
@ -546,7 +546,7 @@ items = [
## 7. 控件栏(工具条 / 筛选条 / 搜索条 / 卡片动作行)
唯一实现是 `<Ctlbar>`(`components/ui/Controls.tsx`)。历史写法
唯一实现是 `<Ctlbar>`(`components/ui/Ctlbar.tsx`)。历史写法
`toolbar / filters / searchbar / lib-tools / sb-tools / card-actions / cardfoot / usage-line /
event-filter / ai-bar / agent-options` 在 React 里都塌缩成同一个 `<Ctlbar>`。
弹层内部的条(灯箱头部、版本选择行、录音头部、批量操作条、分页条)保留各自外框,
@ -567,7 +567,7 @@ event-filter / ai-bar / agent-options` 在 React 里都塌缩成同一个 `<Ctlb
|---|---|---|
| 表单字段 / 主按钮高度 | 32 = `controlHeight` | antd 默认,页面不写高度 |
| 工具条 / 筛选条 / 卡片动作行 / chip / 分段开关 / 分页条 | 24 = `controlHeightSM` | 容器内层 `<Dense>` 下发 `componentSize="small"` |
| 控件横向间隔 | 自然排列 8 = `marginXS`;`Ctlbar cols` 栅格档 12×8 = `marginSM`×`marginXS` | `Controls.tsx` 的 `Ctlbar`:不写 `cols` 是 `<Flex gap={8}>`,写了是 `<Row gutter={[12,8]}>`。**`app.css` 里没有 `.nex-ctlbar-inner` 这条规则**(第 15 轮核对:`gap` 在组件 props 上) |
| 控件横向间隔 | 自然排列 8 = `marginXS`;`Ctlbar cols` 栅格档 12×8 = `marginSM`×`marginXS` | `Ctlbar.tsx` 的 `Ctlbar`:不写 `cols` 是 `<Flex gap={8}>`,写了是 `<Row gutter={[12,8]}>`。**`app.css` 里没有 `.nex-ctlbar-inner` 这条规则**(第 15 轮核对:`gap` 在组件 props 上) |
| 标签与控件 | 8 = `paddingXS` | 竖排:antd 标签自带的 `padding-block-end:8`(8 在标签盒 padding 里,量盒间距得 0);`inline`:`app.css:129` 标签列 `margin-inline-end:8`。两档实测都是 **8** |
| 字段行间距 | **纵向 24** = antd `Form.Item` 默认 `margin-bottom`(`tight` 压到 8 = `marginXS`);**横向 16** = `margin` = `FormRow` 的 `gutter`(`tight` 12,纵向 gutter 恒为 0) | `Form.Item` 自身 / `.nex-form-row` 的 `Row gutter` / `app.css:105` 的 `.nf-tight`。⚠ 上一版写「上下 12 = `marginSM`」与代码不符:theme 只设过 `itemMarginInline:8`,从没碰 `margin-bottom`(第 15 轮在 /users /account /timeline 三页实测 `margin-bottom:24px`) |
| 控件栏与下一块内容 | 12 = `marginSM` | `.nex-ctlbar{margin-block-end:var(--ant-margin-sm)}` |
@ -589,12 +589,12 @@ event-filter / ai-bar / agent-options` 在 React 里都塌缩成同一个 `<Ctlb
`width="narrow"|"wide"` 在 inline 下写成 CSS 变量 `--nex-ctl-w` 交给**控件列**,字段盒子按内容定尺;
宽度还给盒子时,窄档会把整条工具条捅出视口(`app.css` 那行旁边写了实测数)。
- `Field width`:`default`(不给尺寸)/ `narrow` **128** / `wide` **240** / `grow`(搜索框 `flex:1 1 220px` + `min-width:150`)/
`full`(`width:100%`,`FieldBlock` 就是它的别名)。实现是 `Controls.tsx` 的 `WIDTHS` 内联 style,不是类名。
`full`(`width:100%`,`FieldBlock` 就是它的别名)。实现是 `Fields.tsx` 的 `WIDTHS` 内联 style,不是类名。
**竖排字段把尺寸给字段盒子,`inline` 字段把同一个数交给控件列**(`INLINE_CTL_W` → `--nex-ctl-w`);
列边界只有 `FormRow` 的 `Row`/`Col` 一个来源(§9.1),字段进 `Ctlbar cols` 时 `--nex-ctl-w` 只是上限,
列宽一到就让位(`app.css:254`)。
- `Check` / `RadioGroup` / `Chip` 本身就是行内元素,不要包进 `Field`。
- **「同一概念的几颗按钮」用 `<ActionGroup>` 包住**(`components/ui/Controls.tsx`):
- **「同一概念的几颗按钮」用 `<ActionGroup>` 包住**(`components/ui/Ctlbar.tsx`):
症状是 Dispatch 右侧卡里的三颗异常处理按钮折成 **2 + 1**(尾行孤零零一颗),
素材卡底部 `[上传][录制]` 和 `[引入项目][删除]` 混在一排里乱跨行。量出来的宽度是根因——
`Layout` 默认 spans `[15,9]`,1440 下侧栏卡内容只有 **378px**,三颗按钮 natural width 合计 480,
@ -685,7 +685,7 @@ event-filter / ai-bar / agent-options` 在 React 里都塌缩成同一个 `<Ctlb
**`cols` 之后末尾那格如果是 `<BarRight>`,它不再占一格,而是伸缩到行尾。**
固定 span 只能贴**列**边界:块数除不尽列数时,贴右缘的动作会停在半空中——分镜页筛选条
(4 列 7 块)的「导出」实测落在整条的 75% 处,读者以为它掉在了中间。
实现是 `Controls.tsx` 的 `tailRight()` 把最后一格换成 `grid.tsx` 的 `FILL_AT`
实现是 `Ctlbar.tsx` 的 `tailRight()` 把最后一格换成 `grid.tsx` 的 `FILL_AT`
(`flex:1 1 auto` + `.nex-ctlbar-tail{justify-content:flex-end}`):同一行前面的格子都是固定百分比,
剩下的宽度全归它,所以窄档降列之后右缘照样贴着容器。**只认 `BarRight`**——
末尾是普通字段时它就该老实占一格,不许被拉宽。
@ -877,9 +877,9 @@ antd 的 `Tag.CheckableTag` 未选中态是**完全透明**的。铺进等宽格
### 9.1 栅格:列边界只有 antd `Row`/`Col` 一个来源
- `<FormRow cols={2|3|4|6}>` 把这一行等分成 `cols` 格;降列节奏写在 `components/ui/Controls.tsx`
的 `ROW_STEPS`,档位名就是 antd Grid 的断点(`sm` / `md` / `lg` / `xl` / `2xl`,语义是「宽度
≤ 该档下界时改几列」,换算在 `ui/grid.tsx`)。**页面不写 `@media` 改列数**,
- `<FormRow cols={2|3|4|6}>` 把这一行等分成 `cols` 格;降列节奏写在 `components/ui/grid.tsx`
的 `ROW_STEPS`(阶段 6 起这张表由 `Ctlbar` 的等分格与 `FormRow` 共读一份),档位名就是 antd Grid 的断点
(`sm` / `md` / `lg` / `xl` / `2xl`,语义是「宽度 ≤ 该档下界时改几列」,换算同在 `grid.tsx`)。**页面不写 `@media` 改列数**,
站内也不再有 900 / 1100 这种私有宽度。
- **`<FormRow>` 自己带 `.nex-form`(第 14 轮)**:控件撑满列宽那条 glue ① 的作用域,过去靠调用点
手包 `<FormGrid>`,站内因此有 **6 处漏包**(资产库编辑抽屉、用户管理两处、审核台、分镜检视器、
@ -955,7 +955,7 @@ antd 的 `Tag.CheckableTag` 未选中态是**完全透明**的。铺进等宽格
「状态 全部状态」够(93px)、「排序 按更新时间」不够(107px),能不能看全成了巧合。
`nf-w-*` / `.nf-ctl` / `--label-w` 那一层已经随私有 CSS 一起删了(`app.css:85`),现在的口径是:
① 字段宽度是字段自己的属性(`<Field width>`),inline 字段把同一个数交给控件列
(`--nex-ctl-w`,见 `Controls.tsx` 的 `INLINE_CTL_W`);
(`--nex-ctl-w`,见 `Fields.tsx` 的 `INLINE_CTL_W`);
② 一旦进 `<Ctlbar cols>` 栅格,列边界归 `Col`,`app.css` 的
`.nex-ctlbar-grid .nex-field-inline .ant-form-item-control{flex:1 1 auto}` 让 `--nex-ctl-w`
当场让位给列宽——同一行的控件右缘因此必然对齐;
@ -1142,7 +1142,7 @@ antd 的 `Tag.CheckableTag` 未选中态是**完全透明**的。铺进等宽格
## 11. 分页条
`Pager`(`ui/Controls.tsx`)是页大小(`page_size`)唯一的家:
`Pager`(`ui/Ctlbar.tsx`)是页大小(`page_size`)唯一的家:
- 整条包在 `<Dense>` 里 = sm 档;页码本体是 antd `Pagination simple`,页面不再手搓「← 上一页 / 下一页 →」。
- **单页(`pages === 1`)也显示「每页」**,否则用户不知道为啥看不到分页。
@ -1253,7 +1253,7 @@ antd 的 `Tag.CheckableTag` 未选中态是**完全透明**的。铺进等宽格
短属性合并进同一个 label(`语言 / 性别 / 版本`)——响应式断点量的是视口,窄卡会以为自己在宽屏,把值挤成竖排。
- **进卡片加 `nex-info-in-card`**:卡本身已有描边,表格再描一圈就是双层框,这个类只去外框、保留内部网格线。
- **标签不许裸放进值列**:一组 `Tag` 直接进 `<td>` 会挤成一坨,一律包 `TagGroup`(组内 4px、组下 12px 由它管)。
- **计数一律 `Count`**(`ui/Panel.tsx`,`<Count n={q.queued} unit="条" tone="warn" />`):等宽数字 +
- **计数一律 `Count`**(`ui/Info.tsx`,`<Count n={q.queued} unit="条" tone="warn" />`):等宽数字 +
小一档的灰单位,**非零才按 `tone` 上语义色,0 一律降成 `text-text-tertiary`**——0 表示「没有要处理的」,
不该和 8 抢注意力。这套口径原先散在各页的局部函数里(调度中心的 `cnt`),
质检页要做同一个块只能再抄一遍;现在只有组件这一份,页面别再自己写「非零才上色」。
@ -1576,7 +1576,7 @@ URL 没变,effect 不再触发。
| 状态 | 唯一表面 | 用在哪 | 不许用 |
|---|---|---|---|
| **载入(首屏)** | `SkeletonBlock`(`components/ui/Panel.tsx`,antd `Skeleton` + `role=status` + `sr-only` 文案 + `.nex-skeleton` 标记类) | **只有三类落点**:① 路由级 `Suspense` 兜底 `app/App.tsx::PageLoading`;② 页面内部自己拉的整块首屏(`Dashboard` 项目列表 / `Storyboard` 镜头墙 / `ProjectDetail` 工作台壳);③ 抽屉正文 `Drawer loading`(`ProjectBriefDrawer`) | 面板头、按钮里、字段刷新——那些是**局部**等待,用 `Spinner`,拿骨架去闪等于整屏抖动 |
| **载入(首屏)** | `SkeletonBlock`(`components/ui/State.tsx`,antd `Skeleton` + `role=status` + `sr-only` 文案 + `.nex-skeleton` 标记类) | **只有三类落点**:① 路由级 `Suspense` 兜底 `app/App.tsx::PageLoading`;② 页面内部自己拉的整块首屏(`Dashboard` 项目列表 / `Storyboard` 镜头墙 / `ProjectDetail` 工作台壳);③ 抽屉正文 `Drawer loading`(`ProjectBriefDrawer`) | 面板头、按钮里、字段刷新——那些是**局部**等待,用 `Spinner`,拿骨架去闪等于整屏抖动 |
| **载入(局部)** | `Spinner`(面板头 / 按钮内 12px 转圈) | 已有内容之上的刷新、按钮进行中 | 整块首屏退回收一颗转圈 |
| **空** | `Empty`,三分类口径见 §15.2 | 「这块本来该有数据」 | 拿空态冒充 404 / 权限不足 |
| **错误** | 行内 `ErrorText` → 页内 `Notice` → 整页 `ErrorBoundary`(R19) | 按 §13.3 分级 | 页面里裸 `<Alert>` |

View File

@ -55,7 +55,8 @@ api/ → app/ → pages/ → components/{ui,forms,media}/ → theme/ · lib/ ·
| `api/` | 唯一的 `fetch` 出口(信封拆包、`detail`→`Error`、401 跳登录) | 业务分支、组件状态 |
| `app/` | 外壳:`router.tsx` 路由表 · `App.tsx` 布局与守卫 · `ErrorBoundary.tsx` 分包失败兜底 · `layout/` 顶栏侧栏与 `nav.tsx` 导航表(两级菜单的唯一来源) | 任何业务接口调用 |
| `pages/` | 一屏一文件;页面私有小组件与类名常量在文件底部 | 页面之间的互相 import |
| `components/ui/` | 控件出口 + 版式原语:对 antd 的唯一封装层(`Button` `Input` `Checkbox` `Menu` `Status` `Overlay`…)与自绘版式件(`Field` `Ctlbar` `FormGrid` `Table` `Steps` `Pager` `Rows` `Tabs`);页面只从这里取组件 | 业务字段名、接口路径、绕过 `theme/antd.ts` 直接改 antd 皮肤 |
| `components/ui/` | 控件出口 + 版式原语:对 antd 的唯一封装层(`Button` `Input` `Checkbox` `Menu` `Status` `Overlay`…)与自绘版式件(`Field` `Ctlbar` `FormGrid` `Table` `Steps` `Pager` `Rows` `Tabs`);页面只从这里取组件。
文件按职责分(阶段 6):`Panel` 容器与栅格 · `State` 六态表面 · `Info` 只读回显 · `Ctlbar` 控件栏与胶囊 · `Fields` 字段 · `Overlay` 浮层 · `Table` `Tabs` `Steps` `Rows` 列表族 · `grid.tsx` 铺列换算 · `tone.tsx` 反馈语义表;**出口只有 `index.ts` 一个**,页面从不 import 具体文件 | 业务字段名、接口路径、绕过 `theme/antd.ts` 直接改 antd 皮肤 |
| `theme/` | 只有 `antd.ts` 一个文件:`buildAntdTheme(mode)`(本站对 antd 的**唯一**改动清单——品牌色、表面色、少量结构性 ComponentToken)· `applyRootVars(mode)`(`createRoot` 之前把 antd 算出的 token 以 `--ant-*` 铺到 `:root`)· `HEADER_HEIGHT`(外壳顶栏高度,全站唯一自留尺寸) | 任何 JSX、任何页面语义;`metrics.ts` `palette.ts` `css-vars.ts` 那三把自造尺子别再建回来 |
| `components/forms/` | 选择器族(`Select` `MultiSelect` `SecretInput` + `toOptions`) | 页面专属选项 |
| `components/media/` | 带全局状态的媒体件(`MediaThumb` `AudioPlay` `MediaLightbox` `VersionPanel` `WorkflowBar`) | 纯展示(那些进 `ui/`) |
@ -69,7 +70,7 @@ api/ → app/ → pages/ → components/{ui,forms,media}/ → theme/ · lib/ ·
|---|---|---|
| 加一类平台母版 | `pages/AssetLibrary.tsx:TYPE_META` 加一项 | 内部页签(§6.4 的 `<Tabs>`)、卡片、抽屉标题、生成台全部从这张表取标签/图标/提示 |
| 加一个项目环节 | `app/layout/nav.tsx:projectModules` 加一行 + `app/router.tsx` 加子路由(带 `handle` 标题) | 侧栏两级菜单与文档标题分别由这两处派生,无需注册第三处;新页自动获得懒加载分包与 `ErrorBoundary` 兜底 |
| 改某页每页条数档位 | `Pager` 的 `sizes`(页面里传 `PAGE_SIZES`,`0` = 全部) | 默认档位和「全部」语义在 `Controls.tsx` 一处实现 |
| 改某页每页条数档位 | `Pager` 的 `sizes`(页面里传 `PAGE_SIZES`,`0` = 全部) | 默认档位和「全部」语义在 `Ctlbar.tsx` 一处实现 |
| 抽屉想要别的宽度 | `Drawer` 的 `width`(antd 的宽度值) | 默认值只在 `Overlay.tsx` 写一次,页面按屏宽传变体 |
| 新增弹窗/表单 | `Modal` `Drawer` `Field` `FormRow` 组合 | 高度、间距、页脚按钮排布由原语与容器 `<Dense>` 下发的 antd 档位兜住(口径见 UI规范 §4、§10、R14) |
| 加一类控件(tooltip / 日期选择 / 命令面板…) | `components/ui/` 新加一个文件包 antd 组件 → `ui/index.ts` 出口 → 需要定尺子就进 `theme/antd.ts` 的 ComponentToken → 登记进 UI规范 §1 的四层分工 | 页面那层永远只见到一个业务组件名;antd 没有合适的(比如整卡热区按钮)才自绘,自绘件登记进 UI规范 §5.2 的「自定义表面族」白名单(探针第 3 道闸逐文件对账) |

View File

@ -70,7 +70,7 @@ function AuthGate({ admin, children }: { admin?: boolean; children: ReactNode })
* 为什么保留 text:<PageLoading text="正在确认登录状态"> 那两处要把话说清楚,
* 读屏靠它播报;正文骨架由第二段带 label,第一段是装饰,不重复播报。
* 为什么不再用 <Spin>:转圈留在按钮和面板头里(局部刷新的成熟形态),
* 整页级的等待一律给形状,见 `ui/Panel.tsx::SkeletonBlock` 的口径。
* 整页级的等待一律给形状,见 `ui/State.tsx::SkeletonBlock` 的口径。
*/
function PageLoading({ text = '页面加载中' }: { text?: string }) {
return (

View File

@ -60,21 +60,3 @@ export function projectIdOf(pathname: string): string {
/** 菜单项的 key 就是路径:这样 selectedKeys 与 navigate 同一个值,不用再维护第二份 id */
export const pathOf = (item: NavItem, projectId: string): string =>
typeof item.to === 'string' ? item.to : projectId ? item.to(projectId) : ''
/**
* 路由 → 菜单项(页头用它反查图标,见 components/ui/Page.tsx 的 PageHead)。
*
* 症状(2026-11 第十二轮 · 用户第 1 条「标题前一个和左侧菜单一致的图标」):
* 页头如果要显示图形,就得在页面里再 import 一次图标——同一个位置两份登记,
* 换菜单图形时页头必然忘(上一版眉标那枚图标就是这么和侧栏对不上号的)。
* 做法:反查这张导航表本身。菜单和页头读同一个 ReactNode,物理上不可能不一致。
* 不在菜单里的路由(/account、/admin/users、/help)返回 null,页面自己传 icon。
*/
export function navItemAt(pathname: string): NavItem | null {
const clean = pathname.replace(/\/+$/, '') || '/'
const hit = globalNav.find((m) => m.to === clean)
if (hit) return hit
const pid = projectIdOf(clean)
if (!pid) return null
return projectModules.find((m) => pathOf(m, pid) === clean) ?? null
}

View File

@ -83,8 +83,3 @@ export function Select({
/>
)
}
/** 页面偶尔要直接给选项数组(options 已经带 label/value):保持类型可用 */
export function SelectOptionList({ options }: { options: OptionLike[] }) {
return <>{toOptions(options).map((o) => o.label).join('、')}</>
}

View File

@ -33,10 +33,3 @@ export function sameValue(a: any, b: any): boolean {
if (a === null || a === undefined || b === null || b === undefined) return false
return String(a) === String(b)
}
/** 触发器上那一行回显:太长就退化成「首项 等 N 项」,避免把整行控件撑高 */
export function summaryOf(labels: string[], emptyText = ''): string {
if (!labels.length) return emptyText
const joined = labels.join('、')
return joined.length <= 30 ? joined : `${labels[0]} 等 ${labels.length} 项`
}

View File

@ -1,32 +1,17 @@
/**
* 布局层:表单、工具条、筛选行(Ant Design Form·Row·Col·Flex·Tag 的唯一封装)。
*
* 症状(2026-11 第二轮重写的对象):第一轮只换了原子控件,**字段与排布仍是自绘**——
* `.nex-field` 用 CSS Grid 把标签摆到控件左边,标签列宽靠私有变量 `--label-w`,
* `FormGrid`/`FormRow` 又各自一套 12 等分轨道。结果是资产库抽屉里
* 「标签在左」的三列字段和「标签在上」的长字段混排:列边界参差、
* 只有一个字段的行把输入框缩成一小截、`TEXTAREA_TALL` 把 rows=2 撑到 150px。
* 用户说的「布局还是不对」,病根全在这三个文件级的自绘栅格里。
* 做法:**字段就是 antd Form.Item,标签一律在上(layout="vertical")**。
* 已验证 antd 5.29 会为一个孤立的 `Form.Item layout="vertical"` 生成
* `.ant-form-item-vertical` 的完整样式(不需要外层 `<Form>`),
* 所以全站只有一种字段形态,抽屉、对话框、工具条共用同一条标签基线,
* 「对齐」这件事交还给 antd 的表单栅格,私有变量整层删除。
* <Ctlbar> 含字段的横条 = Dense + Flex(align=end, wrap)
* <FormGrid> 表单作用域(只管标记类名,间距由 Form.Item 自己给)
* <FormRow> 表单里的一行 = Row + Col(断点沿用 antd Grid,见 grid.tsx)
* <ChipBar> 可点筛选行 = Flex + Tag.CheckableTag
* <Pager> 分页条(page_size 唯一的家)
* 高度不写在控件上:紧凑容器只做一件事——`<ConfigProvider componentSize="small">`
* 下发 antd 第二档;自绘的那几处读同一个 `--ant-control-height[-sm]`,两条路同一个数。
* 控件栏体系(阶段 6 自 `Controls.tsx` 拆出,实现原样搬移):
* 「一行控件怎么排、动作怎么分组、筛选怎么放」的容器与胶囊——
* Dense / Ctlbar / OptionGrid / CardActions / Actions / ActionGroup / BarRight
* / ChipBar / Chip / TagChip / Pager。
* 字段本身(Field / FieldBlock / FormGrid / FormRow / Check / RadioGroup / FilePick)在 `Fields.tsx`。
* 出口不变:`components/ui/index.ts` 把两个文件一起再导出,业务页 0 改动。
*/
import { cloneElement, isValidElement, useLayoutEffect, useRef, useState, type CSSProperties, type MouseEvent, type ReactElement, type ReactNode } from 'react'
import { ConfigProvider, Checkbox as AntCheckbox, Flex, Form, Pagination, Radio as AntRadio, Row, Tag, Typography } from 'antd'
import { cloneElement, isValidElement, useLayoutEffect, useRef, useState, type MouseEvent, type ReactElement, type ReactNode } from 'react'
import { ConfigProvider, Flex, Pagination, Row, Tag, Typography } from 'antd'
import { cn } from '../../lib/cn'
import { Button } from './Button'
import { Select } from '../forms/Select'
import { IconClose } from '../icons'
import { colSpans, toCols, FILL_AT, type GridStep } from './grid'
import { Select } from '../forms/Select'
import { ROW_STEPS, colSpans, toCols, FILL_AT } from './grid'
/** 分组说明(ChipBar / TagGroup 行首那句「筛选:」):全站只此一种小标签字 */
export const GROUP_LABEL_CLS = 'text-xs text-text-tertiary'
@ -291,133 +276,6 @@ export function BarRight({ children, className }: { children: ReactNode; classNa
)
}
type FieldWidth = 'default' | 'grow' | 'narrow' | 'wide' | 'full'
/**
* 字段宽度:宽度是**字段自己的属性**,列边界由 Row/Col 给(FormRow)。
* 旧的 `nf-w-*` 五条类名靠 `--label-w` 间接生效,改成 inline style 后
* 「这一格多宽」在 DOM 上直接看得见,工具条里的窄字段也不必再猜轨道宽度。
*/
const WIDTHS: Record<FieldWidth, CSSProperties> = {
default: {},
grow: { flex: '1 1 220px', minWidth: 150 },
narrow: { width: 128 },
wide: { width: 240 },
full: { width: '100%' }
}
/* 症状(visualcheck 430 档 dispatch):narrow/wide 把宽度写在**字段盒子**上,
而 inline 字段的标签是 nowrap、控件列 flex:none,两者自然宽度合计大于盒子时,
控件直接捅出工具条——「单次派发上限 / 排空等待」溢出 54px。
做法:inline 字段把同一个数交给控件列(--nex-ctl-w),盒子按内容定尺,
工具条的 flex-wrap 于是量得到真实宽度,放不下就整条换行(窄屏允许折行、不允许改竖排)。
为什么只改 inline:抽屉/表单里的字段坐在栅格里,盒子宽度就是列宽,那是对的。 */
const INLINE_CTL_W: Partial<Record<FieldWidth, number>> = { narrow: 128, wide: 240 }
/**
* 字段 = antd `Form.Item`。默认标签在上(抽屉 / 对话框 / 表单);
* `inline` 给筛选条这种「标签和控件必须同一行」的字段(horizontal 布局)。
*
* 已验证:孤立使用(外层没有 `<Form>`)时 antd 仍然渲染完整的
* `.ant-form-item-vertical` 结构与样式,所以字段不需要表单外壳也能独立成立;
* `FormGrid` 只提供一个作用域类名,用来给整片字段统一上间距与控件撑满规则。
* `title` 挂在标签文字上:版面里不放整段解释(规范 §2 G2),说明走悬浮。
*/
export function Field({ label, required, children, width = 'default', className, style, hint, title, inline }: {
label?: ReactNode; required?: boolean; children: ReactNode; width?: FieldWidth
className?: string; style?: CSSProperties; hint?: ReactNode; title?: string
/** 标签与控件同一行(筛选条 / 工具条);不写就是标签在上(表单 / 抽屉) */
inline?: boolean
}) {
return (
<Form.Item
layout={inline ? 'horizontal' : 'vertical'}
required={required}
label={label === undefined ? undefined : <span title={title}>{label}</span>}
extra={hint}
className={cn('nex-field min-w-0', inline && 'nex-field-inline', width !== 'default' && 'nex-field-fill', className)}
style={{ ...(inline && INLINE_CTL_W[width]
? { ['--nex-ctl-w' as string]: `${INLINE_CTL_W[width]}px` }
: WIDTHS[width]), ...style }}
>
{children}
</Form.Item>
)
}
/** 必填星号:交还给 antd(Form.Item 的 required 自己画 `*`),这里只留旧名字的占位实现 */
export function Req() {
return <b className="nex-req">*</b>
}
/**
* 长字段(旧「标签在上」专用形态):现在和 Field 完全同一种形态,只是默认撑满整行。
* 保留这个名字是因为 54 处调用写着它,删名字要动 12 个页面而得不到任何东西。
*/
export function FieldBlock({ label, required, children, className, style, title, hint }: {
label?: ReactNode; required?: boolean; children: ReactNode; className?: string
style?: CSSProperties
/** 标签的含义/后果说明:分镜检查器里几乎每个长字段都要一句 */
title?: string; hint?: ReactNode
}) {
return (
<Field label={label} required={required} children={children} width="full"
className={className} style={style} title={title} hint={hint} />
)
}
/**
* 表单作用域:只落下 `.nex-form` 这个标记类(app.css 表单 glue ①=控件撑满列宽)。
*
* 旧版本在这里定义 12 等分轨道和 `--label-w`(「标题与控件对齐」的唯一机制)。
* 标签改到控件上方之后,对齐由 antd 表单栅格负责,这两套私有尺子整体退场——
* 列边界从此只有 Row/Col 一个来源(见 grid.tsx),不会再出现两行字段错开 110px。
*
* **`<FormRow>` 自己就带这一层**(见下面的 FormRow):一行字段本来就是表单,
* 作用域不该靠调用点记得再包一层。这一改之前站内有 6 处 FormRow 漏包,
* 症状都一样:同一格里下拉铺满、数字框按 antd 的默认 90px 缩成一截,
* 右边界参差不齐(时间线「混音与字幕设置」实测 214 的格子摆 90 的输入框)。
* 还要用它的场合只剩一个:抽屉里**竖排**的 FieldBlock 串(不排成栅格的那堆字段)。
*/
export function FormGrid({ children, className }: { children: ReactNode; className?: string }) {
return <div className={cn('nex-form min-w-0', className)}>{children}</div>
}
/* 每行 N 个字段时的降列节奏:档位名就是 antd Grid 的断点,站内不再有 900/1100 这种私有宽度。
⚠ 档位按**正文宽**取,不是按视口宽:侧栏占 224(≤md 折叠成 64)+ 内容内边距 32,
768 视口的正文只有 512。原先 5 等分在 md 档给到 3 列,实测每格 158——
「素材类型」的标签 69 之后只剩 69 给下拉,选中值「全部类型」77px 被省略号裁成 53px
(visualcheck 768 档 /assets 三条红灯)。整体降一档后 ≤1600 四列、≤1200 三列、
≤992 两列、≤576 单列,最窄的一格也有 231px。 */
const ROW_STEPS: Record<number, GridStep[]> = {
2: [{ at: 'sm', cols: 1 }],
5: [{ at: '2xl', cols: 4 }, { at: 'xl', cols: 3 }, { at: 'lg', cols: 2 }, { at: 'sm', cols: 1 }],
3: [{ at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
4: [{ at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
6: [{ at: 'xl', cols: 4 }, { at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }]
}
/**
* 表单里的一行 = antd Row + Col(cols = 这一行放几个字段)。
*
* 纵向间距不在 gutter 上:Form.Item 自带 24px 下边距,Row 再给纵向 gutter 就是 48。
* `tight` 是给「一行里全是窄字段」的场合(时间线/分镜的批量设置),
* 把下边距压到 8,见 app.css 的 `.nf-tight`。
*/
export function FormRow({ children, cols = 3, className, tight, gap = 16 }: {
children: ReactNode
/** 这一行放几个字段(窄屏按 ROW_STEPS 自动降列) */
cols?: 2 | 3 | 4 | 6
className?: string
tight?: boolean
/** 列间距:默认 16(antd 表单列间),窄屏由 Col 折行接管 */
gap?: number
}) {
return (
<Row gutter={[tight ? 12 : gap, 0]}
className={cn('nex-form nex-form-row min-w-0', tight && 'nf-tight', className)}>
{toCols(children, colSpans(cols, undefined, ROW_STEPS[cols] || []), 'min-w-0')}
</Row>
)
}
/** 可点的筛选胶囊行(与下方内容强制呼吸 12px);只读回显一律走 TagGroup */
export function ChipBar({ children, label, className, top }: {
@ -517,55 +375,3 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra,
</Dense>
)
}
/** 复选(勾选框 + 文案整块可点):本体是 antd Checkbox,尺寸走 token */
export function Check({ checked, onChange, children, disabled, className, title }: {
checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean
className?: string; title?: string
}) {
return (
<AntCheckbox checked={checked} disabled={disabled} title={title} className={cn('nex-check', className)}
onChange={(e) => onChange(e.target.checked)}>
{children}
</AntCheckbox>
)
}
/** 单选组(互斥选项):antd Radio.Group;分段切换请用 Segmented */
export function RadioGroup({ value, onChange, options, className, disabled }: {
value: any; onChange: (next: any) => void; options: { value: any; label: ReactNode; disabled?: boolean }[]
className?: string; disabled?: boolean
}) {
return (
<Form.Item layout="vertical" className={cn('nex-field min-w-0 !mb-0', className)}>
<AntRadio.Group value={value} disabled={disabled}
onChange={(e) => onChange(e.target.value)}
options={options.map((o) => ({ label: o.label, value: o.value, disabled: o.disabled }))} />
</Form.Item>
)
}
/**
* 文件选择:整块按钮就是热区,点哪里都开文件对话框。
* 选完把 input 清空:否则连着两次选同一个文件 value 没变,onChange 不再触发
* (分镜导入要反复试同一份脚本)。
*/
export function FilePick({ label, icon, accept, multiple, onFiles, className, title, disabled }: {
label: ReactNode; accept?: string; multiple?: boolean; onFiles: (files: File[]) => void; className?: string
/** 悬浮说明「选出来的文件会落到哪里」:一页里上传点越多越需要这句话 */
title?: string; disabled?: boolean
/** 图标走 antd Button 的 icon 槽,不写进 label —— 否则间距由 label 里的空格决定 */
icon?: ReactNode
}) {
return (
<Button className={className} title={title} disabled={disabled} icon={icon}>
<span className="contents">{label}</span>
<input type="file" className="nex-file-input" accept={accept} multiple={multiple} title={undefined}
onChange={(e) => {
const files = Array.from(e.currentTarget.files || [])
e.currentTarget.value = ''
onFiles(files)
}} />
</Button>
)
}

View File

@ -0,0 +1,172 @@
/**
* 字段体系(阶段 6 自 `Controls.tsx` 拆出,实现原样搬移):
* 表单里「一个标签 + 一个控件 + 一句校验」的唯一写法——
* Field / FieldBlock / FormGrid / FormRow / Check / RadioGroup / FilePick。
* 控件栏与胶囊在 `Ctlbar.tsx`;两类的度量都来自 `theme/antd.ts` 那把尺子,不另开档位。
*/
import { type ReactNode, type CSSProperties } from 'react'
import { Checkbox as AntCheckbox, Form, Radio as AntRadio, Row } from 'antd'
import { cn } from '../../lib/cn'
import { Button } from './Button'
import { ROW_STEPS, colSpans, toCols } from './grid'
type FieldWidth = 'default' | 'grow' | 'narrow' | 'wide' | 'full'
/**
* 字段宽度:宽度是**字段自己的属性**,列边界由 Row/Col 给(FormRow)。
* 旧的 `nf-w-*` 五条类名靠 `--label-w` 间接生效,改成 inline style 后
* 「这一格多宽」在 DOM 上直接看得见,工具条里的窄字段也不必再猜轨道宽度。
*/
const WIDTHS: Record<FieldWidth, CSSProperties> = {
default: {},
grow: { flex: '1 1 220px', minWidth: 150 },
narrow: { width: 128 },
wide: { width: 240 },
full: { width: '100%' }
}
/* 症状(visualcheck 430 档 dispatch):narrow/wide 把宽度写在**字段盒子**上,
而 inline 字段的标签是 nowrap、控件列 flex:none,两者自然宽度合计大于盒子时,
控件直接捅出工具条——「单次派发上限 / 排空等待」溢出 54px。
做法:inline 字段把同一个数交给控件列(--nex-ctl-w),盒子按内容定尺,
工具条的 flex-wrap 于是量得到真实宽度,放不下就整条换行(窄屏允许折行、不允许改竖排)。
为什么只改 inline:抽屉/表单里的字段坐在栅格里,盒子宽度就是列宽,那是对的。 */
const INLINE_CTL_W: Partial<Record<FieldWidth, number>> = { narrow: 128, wide: 240 }
/**
* 字段 = antd `Form.Item`。默认标签在上(抽屉 / 对话框 / 表单);
* `inline` 给筛选条这种「标签和控件必须同一行」的字段(horizontal 布局)。
*
* 已验证:孤立使用(外层没有 `<Form>`)时 antd 仍然渲染完整的
* `.ant-form-item-vertical` 结构与样式,所以字段不需要表单外壳也能独立成立;
* `FormGrid` 只提供一个作用域类名,用来给整片字段统一上间距与控件撑满规则。
* `title` 挂在标签文字上:版面里不放整段解释(规范 §2 G2),说明走悬浮。
*/
export function Field({ label, required, children, width = 'default', className, style, hint, title, inline }: {
label?: ReactNode; required?: boolean; children: ReactNode; width?: FieldWidth
className?: string; style?: CSSProperties; hint?: ReactNode; title?: string
/** 标签与控件同一行(筛选条 / 工具条);不写就是标签在上(表单 / 抽屉) */
inline?: boolean
}) {
return (
<Form.Item
layout={inline ? 'horizontal' : 'vertical'}
required={required}
label={label === undefined ? undefined : <span title={title}>{label}</span>}
extra={hint}
className={cn('nex-field min-w-0', inline && 'nex-field-inline', width !== 'default' && 'nex-field-fill', className)}
style={{ ...(inline && INLINE_CTL_W[width]
? { ['--nex-ctl-w' as string]: `${INLINE_CTL_W[width]}px` }
: WIDTHS[width]), ...style }}
>
{children}
</Form.Item>
)
}
/**
* 长字段(旧「标签在上」专用形态):现在和 Field 完全同一种形态,只是默认撑满整行。
* 保留这个名字是因为 54 处调用写着它,删名字要动 12 个页面而得不到任何东西。
*/
export function FieldBlock({ label, required, children, className, style, title, hint }: {
label?: ReactNode; required?: boolean; children: ReactNode; className?: string
style?: CSSProperties
/** 标签的含义/后果说明:分镜检查器里几乎每个长字段都要一句 */
title?: string; hint?: ReactNode
}) {
return (
<Field label={label} required={required} children={children} width="full"
className={className} style={style} title={title} hint={hint} />
)
}
/**
* 表单作用域:只落下 `.nex-form` 这个标记类(app.css 表单 glue ①=控件撑满列宽)。
*
* 旧版本在这里定义 12 等分轨道和 `--label-w`(「标题与控件对齐」的唯一机制)。
* 标签改到控件上方之后,对齐由 antd 表单栅格负责,这两套私有尺子整体退场——
* 列边界从此只有 Row/Col 一个来源(见 grid.tsx),不会再出现两行字段错开 110px。
*
* **`<FormRow>` 自己就带这一层**(见下面的 FormRow):一行字段本来就是表单,
* 作用域不该靠调用点记得再包一层。这一改之前站内有 6 处 FormRow 漏包,
* 症状都一样:同一格里下拉铺满、数字框按 antd 的默认 90px 缩成一截,
* 右边界参差不齐(时间线「混音与字幕设置」实测 214 的格子摆 90 的输入框)。
* 还要用它的场合只剩一个:抽屉里**竖排**的 FieldBlock 串(不排成栅格的那堆字段)。
*/
export function FormGrid({ children, className }: { children: ReactNode; className?: string }) {
return <div className={cn('nex-form min-w-0', className)}>{children}</div>
}
/**
* 表单里的一行 = antd Row + Col(cols = 这一行放几个字段)。
*
* 纵向间距不在 gutter 上:Form.Item 自带 24px 下边距,Row 再给纵向 gutter 就是 48。
* `tight` 是给「一行里全是窄字段」的场合(时间线/分镜的批量设置),
* 把下边距压到 8,见 app.css 的 `.nf-tight`。
*/
export function FormRow({ children, cols = 3, className, tight, gap = 16 }: {
children: ReactNode
/** 这一行放几个字段(窄屏按 ROW_STEPS 自动降列) */
cols?: 2 | 3 | 4 | 6
className?: string
tight?: boolean
/** 列间距:默认 16(antd 表单列间),窄屏由 Col 折行接管 */
gap?: number
}) {
return (
<Row gutter={[tight ? 12 : gap, 0]}
className={cn('nex-form nex-form-row min-w-0', tight && 'nf-tight', className)}>
{toCols(children, colSpans(cols, undefined, ROW_STEPS[cols] || []), 'min-w-0')}
</Row>
)
}
/** 复选(勾选框 + 文案整块可点):本体是 antd Checkbox,尺寸走 token */
export function Check({ checked, onChange, children, disabled, className, title }: {
checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean
className?: string; title?: string
}) {
return (
<AntCheckbox checked={checked} disabled={disabled} title={title} className={cn('nex-check', className)}
onChange={(e) => onChange(e.target.checked)}>
{children}
</AntCheckbox>
)
}
/** 单选组(互斥选项):antd Radio.Group;分段切换请用 Segmented */
export function RadioGroup({ value, onChange, options, className, disabled }: {
value: any; onChange: (next: any) => void; options: { value: any; label: ReactNode; disabled?: boolean }[]
className?: string; disabled?: boolean
}) {
return (
<Form.Item layout="vertical" className={cn('nex-field min-w-0 !mb-0', className)}>
<AntRadio.Group value={value} disabled={disabled}
onChange={(e) => onChange(e.target.value)}
options={options.map((o) => ({ label: o.label, value: o.value, disabled: o.disabled }))} />
</Form.Item>
)
}
/**
* 文件选择:整块按钮就是热区,点哪里都开文件对话框。
* 选完把 input 清空:否则连着两次选同一个文件 value 没变,onChange 不再触发
* (分镜导入要反复试同一份脚本)。
*/
export function FilePick({ label, icon, accept, multiple, onFiles, className, title, disabled }: {
label: ReactNode; accept?: string; multiple?: boolean; onFiles: (files: File[]) => void; className?: string
/** 悬浮说明「选出来的文件会落到哪里」:一页里上传点越多越需要这句话 */
title?: string; disabled?: boolean
/** 图标走 antd Button 的 icon 槽,不写进 label —— 否则间距由 label 里的空格决定 */
icon?: ReactNode
}) {
return (
<Button className={className} title={title} disabled={disabled} icon={icon}>
<span className="contents">{label}</span>
<input type="file" className="nex-file-input" accept={accept} multiple={multiple} title={undefined}
onChange={(e) => {
const files = Array.from(e.currentTarget.files || [])
e.currentTarget.value = ''
onFiles(files)
}} />
</Button>
)
}

View File

@ -0,0 +1,145 @@
/**
* 只读回显(阶段 6 自 `Panel.tsx` 拆出,实现原样搬移):
* 「这条记录长什么样」的原子件——值、等宽小字、条件告警、外链、回显表、带语义的数字。
*
* 口径:属性回显一律走 Info(antd Descriptions),不许再写「灰盒 + 标签在上」的假输入框;
* 版面不放成段解释文字(§7 G2),第二层说明挂在 title 上悬浮给读者。
*/
import { type ReactNode } from 'react'
import { Descriptions, Flex, Typography } from 'antd'
import { cn } from '../../lib/cn'
import { IconExternal } from '../icons'
/** 数据回显(.val)与条件告警(.linehint):规范 §7 G2 —— 版面不放成段解释文字 */
export function Value({ children, muted, className, title }: {
children: ReactNode; muted?: boolean; className?: string
/** 悬浮说明:口径 / 数据来源这种「不该占版面但读者会问」的第二层,走原生 title(G2) */
title?: string
}) {
return (
<Typography.Text title={title}
className={cn('!text-xs leading-relaxed wrap-anywhere', muted ? '!text-text-quaternary' : '!text-text-tertiary', className)}
type={muted ? undefined : 'secondary'}>{children}</Typography.Text>
)
}
export function LineHint({ children, className }: { children: ReactNode; className?: string }) {
return (
<Flex align="baseline" gap={6} wrap className={cn('mt-2 text-xs leading-normal text-warning', className)}>
{children}
</Flex>
)
}
/** 等宽小字(路径 / id / 枚举码) */
export function Mono({ children, className, title }: { children: ReactNode; className?: string; title?: string }) {
return <Typography.Text className={cn('font-mono !text-xs', className)} title={title} copyable={false}>{children}</Typography.Text>
}
/** 文字链(.link):导航用 <Link>,这里只给「打开外部资源 / 下载」 */
export function ExtLink({ href, children, className, download }: {
href: string; children: ReactNode; className?: string; download?: boolean | string
}) {
return (
<Typography.Link href={href} download={download} target="_blank" rel="noreferrer"
className={cn('!inline-flex !items-center gap-1 !text-xs', className)}>
{children}<IconExternal className="text-xs" />
</Typography.Link>
)
}
/**
* 只读回显(.nex-info)= antd Descriptions:**站内所有「这条记录长什么样」的
* 属性回显只有这一种写法**(规范 R16.3)。
*
* 症状(用户截图指的那类块,原话「这种设计都是有问题的」):回显写成
* `Block tone=default vertical` 的灰盒——label 在上、值在下、四周描边,
* 和它旁边真正的输入框长得一模一样;用户去找可点的框,框里却没有可改的东西。
* 同一屏里另一批回显写成「label:值」的裸文本行,两种读法各占一半。
* 做法:一律 Descriptions(bordered + size=small + colon=false):
* label 列由 antd 上 colorFillAlter 底纹(底纹来自语义色,不新增色值),
* 值列左对齐长值折行,多属性并排走 column 分栏——一屏放得下的绝不多占一行。
* 为什么不用灰盒:灰盒在 antd 语言里是「输入区的底色」,回显用它是借错了语义;
* Descriptions 就是 antd 为「详情回显」准备的组件,明暗两档、圆角、分隔线
* 全都跟主题走,不需要再养一套私有皮肤(度量集中在 app.css `.nex-info`)。
*/
export type InfoItem = {
key?: string
label: ReactNode
value: ReactNode
/** 等宽回显(路径 / id / 枚举码 / 密钥),走 kit 的 Mono */
mono?: boolean
/** 跨几列(与 antd Descriptions 的 span 同名同义):长地址、一段说明用 span 顶满 */
span?: number
}
/** 分栏数:固定几列,或按断点降列(窄屏/抽屉里 3 列会挤成竖排,交给 antd 自己降) */
export type InfoColumns = number | Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number>>
const INFO_BP: ('xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl')[] = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']
/**
* 档位向上补齐:写到的那一档=它右边所有档的值。
*
* 症状:antd Descriptions 内部把 column 与内置 {xs:1,sm:2,md:3,lg:3,xl:3,xxl:3} 合并,
* 再由宽到窄取第一个命中的档位。于是只写 `{ xs: 2, sm: 3, lg: 5 }` 的回显,
* 1440 命中的是内置的 xl=3——**声明的 5 列在桌面上永远不生效**;
* 卡片里的 `{ xs: 1, sm: 2 }` 同理,宽屏变成没声明过的 3 列,挤成竖排。
* 做法:把没写的右档填成最近一次声明的值,页面只需要写「从哪一档开始降到几列」。
* 为什么在容器补:12 个页面写的都是「窄屏少列、宽屏多列」这一个意图,
* 让每个页面记住 antd 的默认表并要求它写满六档,是规范在给自己找麻烦。
*/
export function fillInfoColumns(column: InfoColumns): InfoColumns {
if (typeof column === 'number') return column
const out: Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number>> = { ...column }
let last: number | undefined
INFO_BP.forEach((bp) => {
if (out[bp] !== undefined) last = out[bp]
else if (last !== undefined) out[bp] = last
})
return out
}
export function Info({ items, column = 1, className, title, extra }: {
items: (InfoItem | null | undefined | false)[]
column?: InfoColumns
className?: string
/** 这一组回显的标题(antd Descriptions 的 title,走主题字号,不用页面自己写 h4) */
title?: ReactNode
/** 标题行右端动作(antd 5.29 Descriptions.extra):与标题同一行,不再另起一排 */
extra?: ReactNode
}) {
const real = items.filter(Boolean) as InfoItem[]
if (!real.length) return null
return (
<Descriptions className={cn('nex-info', className)} size="small" bordered colon={false}
column={fillInfoColumns(column)} title={title} extra={extra}
items={real.map((it, i) => ({
key: it.key ?? String(i), label: it.label, span: it.span,
children: it.mono ? <Mono className="wrap-anywhere">{it.value}</Mono> : it.value
}))} />
)
}
/**
* Info 里的计数值(.nex-info 的 number 档):等宽数字 + 可选单位。
*
* 症状:回显表里的 0 和 3 一样粗一样亮,一屏八个数字读不出哪个要管;
* 这套「非零才上语义色」的口径原先写在调度中心页面里(局部函数 cnt),
* 质检页要做同一个块只能再抄一遍——规范 §13.1 要求口径只有一份。
* 做法:0 一律降到 colorTextTertiary(「没有要处理的」),非零才按 tone 上
* success / warning / error;单位(条 / 次)比数字小一档、跟着降灰。
* 为什么是组件不是常量函数:它出现在 12 个页面的 items 里,JSX 写法与 Info 一致。
*/
const COUNT_TONE: Record<'ok' | 'warn' | 'bad', string> = { ok: 'text-success', warn: 'text-warning', bad: 'text-error' }
export function Count({ n, unit, tone }: { n?: number; unit?: string; tone?: 'ok' | 'warn' | 'bad' }) {
const num = Number(n) || 0
return (
<span className={`font-mono text-xs font-semibold ${num ? (tone ? COUNT_TONE[tone] : '') : 'text-text-tertiary'}`}>
{num}
{unit ? <span className="ml-0.5 text-xs font-normal text-text-tertiary">{unit}</span> : null}
</span>
)
}

View File

@ -3,8 +3,8 @@ import { Drawer as AntDrawer, Modal as AntModal } from 'antd'
import { cn } from '../../lib/cn'
import { LAYER } from '../../lib/layers'
import { Button } from './Button'
import { SkeletonBlock } from './Panel'
import { ActionGroup } from './Controls'
import { SkeletonBlock } from './State'
import { ActionGroup } from './Ctlbar'
import { IconClose } from '../icons'
/**
* 浮层:Ant Design 5 Drawer / Modal 的唯一封装。

View File

@ -22,7 +22,7 @@ import { useNavigate } from 'react-router-dom'
import { Avatar, Breadcrumb as AntBreadcrumb, Col as AntCol, Divider, Flex, Row as AntRow, Typography } from 'antd'
import { cn } from '../../lib/cn'
import { LAYER } from '../../lib/layers'
import { ActionGroup } from './Controls'
import { ActionGroup } from './Ctlbar'
import { Clamp } from './Table'
import { Panel } from './Panel'
import { splitSpans, type GridCollapse } from './grid'

View File

@ -1,5 +1,5 @@
/**
* 卡片体系:Ant Design 5 Card / Statistic / Row·Col / Empty / Progress 的唯一封装。
* 卡片体系:Ant Design 5 Card / Statistic / Row·Col / Divider 的唯一封装。
*
* 症状(2026-11 第二轮重写的对象):第一轮只把**原子控件**换成了 antd,
* 「有边框的内容块」仍然是自绘 <section> + Tailwind 类,标题行、指标卡、
@ -7,29 +7,23 @@
* 卡头没有分隔线、指标卡数字与 antd 的 Statistic 差 6px、栅格按私有断点降列。
* 做法:**布局也交给 antd**。Panel=Card(卡头用 Card 自己的 title/extra)、
* Stat=Card+Statistic、Grid/StatGrid=Row+Col(断点用 antd Grid 的 xs…xxl)、
* Info=Descriptions(只读回显:标签列 + 值列,替代「灰盒 + 标签在上」那种假输入框)、
* Notice 与 Block 共用 R16.3 那把语义底纹尺子(2026-11 第十三轮起不再借 antd Alert 的皮肤)、
* Empty=Empty、ProgressBar=Progress、Divider=Divider。
* Block=卡内语义底纹小块(R16.3 那把尺子)、CardRow=列表里重复项的统一骨架。
* 页面继续写 <Panel><PanelHead …/>正文</Panel>:Panel 会把作为第一个子节点的
* PanelHead **吞进 Card 的 title/extra**,所以 52 处调用一行不用改,
* 卡头却已经是真正的 antd 卡头(分隔线、15px 标题、右端 extra)。
* 为什么把吞并做在 Panel 里而不是让页面改写:<PanelHead> 这个形状已经写了 42 遍,
* 改名成 Card 的 title/extra 属性要动 12 个页面 42 处,而它表达的语义
* (这一块是什么 + 右端动作)完全一致;语义不变、实现换掉,就是这一轮的全部工作。
*
* 阶段 6 拆分(只搬文件,实现一行未改):本文件只留「容器与栅格」。
* 状态表面(ProgressBar / Empty / SkeletonBlock / Spinner / Notice)→ `State.tsx`;
* 只读回显(Value / LineHint / Mono / ExtLink / Info / Count)→ `Info.tsx`。
* 出口不变:`components/ui/index.ts` 把三个文件一起再导出,业务页 0 改动。
*/
import { Children, isValidElement, type CSSProperties, type ReactNode } from 'react'
import {
Card, Descriptions, Divider as AntDivider, Empty as AntEmpty, Flex,
/* 本文件下方自己 export 了一个 <Grid>(栅格封装)——antd 的 Grid 必须起别名:
同名声明会顶掉 import 绑定,AntGrid.useBreakpoint() 静默变成 undefined,
整页撞进 ErrorBoundary。(Divider / Empty 起别名是同一个原因)*/
Grid as AntGrid, Progress, Row, Skeleton, Statistic, Typography
} from 'antd'
import { Card, Divider as AntDivider, Flex, Grid as AntGrid, Row, Statistic, Typography } from 'antd'
import { cn } from '../../lib/cn'
import { IconClose, IconExternal, IconLoading } from '../icons'
import { Button } from './Button'
import { Dense } from './Controls'
import { NOTICE_TONE, TONE_ICON, TONE_TINT } from './tone'
import { Dense } from './Ctlbar'
import { colSpans, toCols, type GridCollapse, type GridStep, type StatStep } from './grid'
/** Panel 认得出的 PanelHead 形状(Panel 用它拼 Card 的 title/extra) */
@ -297,14 +291,6 @@ export function StatGrid({ children, cols, steps, className, gap = 12 }: {
)
}
/** 进度条:antd Progress(站内只有这一条;bad=异常态用 antd 的 exception 色) */
export function ProgressBar({ value, bad, className }: { value: number; bad?: boolean; className?: string }) {
const pct = Math.max(0, Math.min(100, Number(value) || 0))
return (
<Progress percent={pct} showInfo={false} status={bad ? 'exception' : 'normal'}
size="small" className={cn('nex-progress min-w-[60px]', className)} />
)
}
/**
* 分隔线:antd Divider。
@ -321,143 +307,6 @@ export function Divider({ className, dashed, text }: { className?: string; dashe
return <AntDivider className={className} dashed={dashed} orientation={text ? 'left' : undefined}>{text}</AntDivider>
}
/** 空态:antd Empty(简单图,站内不放插画——卡片里那块地方给不起) */
export function Empty({ children = '暂无数据', className }: { children?: ReactNode; className?: string }) {
return <AntEmpty className={cn('my-2', className)} image={AntEmpty.PRESENTED_IMAGE_SIMPLE} description={children} />
}
/* 「读取中:一块居中的 Spin」这个导出(旧 <Loading>)在阶段 4 删掉了:
它全站只有三处调用,三处都是**首屏**,而首屏的正确表面是下面的 <SkeletonBlock>。
留着它等于给后来人留一把会退回「空白 + 转圈」的尺子——局部刷新请用 <Spinner>,
整块等待请用 <SkeletonBlock>,两者都够用。(审计报告 D6 / V6 · UI规范 §15.3) */
/**
* 首屏骨架 = antd Skeleton(阶段 4 · 补 NEX 06 §7 的 loading 态)。
*
* 症状:全站 0 处骨架。首屏是「一块空白 + 一颗转圈」——路由分包在拉、项目在拉,
* 内容区只有一枚居中 Spin(实测 240px 高的空盒子)。读者既不知道这里将出现
* 什么形状的东西,也分不清「在加载」和「加载完什么都没有」。
* 做法:骨架只用在**首屏**两处——① 路由级 Suspense 兜底(`app/App.tsx::PageLoading`),
* ② 抽屉正文(`ui/Overlay.tsx::Drawer` 的 `loading`)。
* 面板头 / 字段级的刷新维持内联 `Spinner`,那是成熟设计,不要拿骨架去闪。
* 为什么只有 rows / title 两个参数:站内首屏只有两种形状——「一摞段落」与
* 「一行标题 + 一摞段落」,都在 antd Skeleton 自己的档位里;开更多参数
* 等于给页面发第二把尺子(想要别的形状说明那一处不是首屏)。
* `nex-skeleton` 是闸门落点:像素检查要能认出「这一屏此刻是骨架」,
* 才不会把骨架当成空白内容误判成 empty 态。
* `label` 决定这摞骨架对读屏说不说话:一屏只该有一句进度播报,
* 所以纯装饰的那一段(页头形状)不传 label,它整块 `aria-hidden`。
*/
export function SkeletonBlock({ rows = 3, title = true, label, className, style }: {
/** 段落行数(antd 默认 3 行,这里对齐成站内首屏的常见高度) */
rows?: number
/** 要不要那一行标题占位:页头形状用 true,正文里续段用 false */
title?: boolean
/** 读屏与低视力用户看到的进度说明;只挂 sr-only,不占版面。不传 = 这摞纯装饰 */
label?: string
className?: string
style?: CSSProperties
}) {
return (
<div className={cn('nex-skeleton min-w-0', className)} style={style}
role={label ? 'status' : undefined} aria-busy="true"
aria-hidden={label ? undefined : true}>
<Skeleton active title={title} paragraph={{ rows }} avatar={false} />
{label ? <span className="sr-only">{label}</span> : null}
</div>
)
}
/** 行内小转圈(按钮、状态条里那颗) */
export function Spinner({ className }: { className?: string }) {
return <IconLoading spin aria-hidden className={cn('align-[-1px] text-xs', className)} />
}
/**
* 提示条:自绘表面,**不用 antd `Alert`**(2026-11 第十三轮)。
*
* 症状(用户原话「整体修改系统中所有提示窗、完成后的反馈 tips 等。不要使用默认组件」):
* 这一层原来是 antd Alert 的直封装,于是站内同时存在两套「信息块长相」——
* 同一页里 <Block> 系列有语义描边 + 语义底纹 + 圆角 + 内边距档位,
* 而 Alert 是 antd 自带的那套(浅色档还带着它自己的 closable 图标位置),
* 并且它**没有 action 位**:App.tsx 那条「后端连接异常」要挂「重试」按钮,
* 只能绕过 kit 直接 import antd 的 Alert。
* 做法:读 R16.3 那把唯一的尺子 `BLOCK_TONE`(语义底纹 + 语义描边),
* 左侧色块用色块族(20px 档,与概况抽屉的七站行同一尺寸),
* 两行文案 = `children`(一句人话)+ `description`(明细 / 善后),
* 右侧新增 `action` 位(重试、去设置这种善后按钮),`onClose` 走标准图标按钮。
* props 与原来完全一致(含 antd 词汇的 `type`),30 处调用点零改动。
* 为什么保留 antd 的 type 词汇:`type="success" | "error"` 这套名字已经写在 30 处调用点里,
* 它是**语义**而不是皮肤;`NOTICE_TONE` 把它翻成站内语气,皮肤换多少轮都不用碰页面。
*/
export function Notice({ children, description, danger, className, onClose, type, action }: {
children: ReactNode; danger?: boolean; className?: string; onClose?: () => void
/**
* 第二层说明(与 antd Alert 同名):`children` 是「一句人话」的标题,
* 多条明细 / 善后按钮属于正文,塞进 children 会让整块只有一层粗体、
* 明细和按钮跟着一起加粗,于是页面又自己写 <b> + <p> 造第二层。
*/
description?: ReactNode
/** Alert 的四档语义;`danger` 是站内先写下的 error 简写,两者等价 */
type?: 'info' | 'success' | 'warning' | 'error'
/** 右侧善后动作(重试 / 去设置);一颗 Button 或一组按钮,不放正文 */
action?: ReactNode
}) {
if (!children) return null
const tone = NOTICE_TONE[type ?? (danger ? 'error' : 'info')]
return (
<Flex align="start" gap={10} role={tone === 'bad' || tone === 'warn' ? 'alert' : undefined}
className={cn('nex-notice mb-4', BLOCK_TONE[tone], className)}>
<span className="nex-notice-mark" aria-hidden
style={{ ['--nex-mark-tint' as string]: TONE_TINT[tone] }}>{TONE_ICON[tone]}</span>
<div className="min-w-0 flex-1">
<div className="nex-notice-title">{children}</div>
{description && <div className="nex-notice-desc">{description}</div>}
</div>
{action && <div className="nex-notice-action flex flex-wrap items-center gap-2">{action}</div>}
{onClose && <Button type="text" size="sm" className="nex-notice-close" aria-label="关闭提示"
title="关闭提示" icon={<IconClose />} onClick={onClose} />}
</Flex>
)
}
/** 数据回显(.val)与条件告警(.linehint):规范 §7 G2 —— 版面不放成段解释文字 */
export function Value({ children, muted, className, title }: {
children: ReactNode; muted?: boolean; className?: string
/** 悬浮说明:口径 / 数据来源这种「不该占版面但读者会问」的第二层,走原生 title(G2) */
title?: string
}) {
return (
<Typography.Text title={title}
className={cn('!text-xs leading-relaxed wrap-anywhere', muted ? '!text-text-quaternary' : '!text-text-tertiary', className)}
type={muted ? undefined : 'secondary'}>{children}</Typography.Text>
)
}
export function LineHint({ children, className }: { children: ReactNode; className?: string }) {
return (
<Flex align="baseline" gap={6} wrap className={cn('mt-2 text-xs leading-normal text-warning', className)}>
{children}
</Flex>
)
}
/** 等宽小字(路径 / id / 枚举码) */
export function Mono({ children, className, title }: { children: ReactNode; className?: string; title?: string }) {
return <Typography.Text className={cn('font-mono !text-xs', className)} title={title} copyable={false}>{children}</Typography.Text>
}
/** 文字链(.link):导航用 <Link>,这里只给「打开外部资源 / 下载」 */
export function ExtLink({ href, children, className, download }: {
href: string; children: ReactNode; className?: string; download?: boolean | string
}) {
return (
<Typography.Link href={href} download={download} target="_blank" rel="noreferrer"
className={cn('!inline-flex !items-center gap-1 !text-xs', className)}>
{children}<IconExternal className="text-xs" />
</Typography.Link>
)
}
/**
* 小块(.block):卡内 / 页面里那些「比一行文字重、比一张卡轻」的自绘信息块统一骨架。
@ -506,100 +355,6 @@ export function Block({ children, tone = 'default', align = 'center', vertical,
)
}
/**
* 只读回显(.nex-info)= antd Descriptions:**站内所有「这条记录长什么样」的
* 属性回显只有这一种写法**(规范 R16.3)。
*
* 症状(用户截图指的那类块,原话「这种设计都是有问题的」):回显写成
* `Block tone=default vertical` 的灰盒——label 在上、值在下、四周描边,
* 和它旁边真正的输入框长得一模一样;用户去找可点的框,框里却没有可改的东西。
* 同一屏里另一批回显写成「label:值」的裸文本行,两种读法各占一半。
* 做法:一律 Descriptions(bordered + size=small + colon=false):
* label 列由 antd 上 colorFillAlter 底纹(底纹来自语义色,不新增色值),
* 值列左对齐长值折行,多属性并排走 column 分栏——一屏放得下的绝不多占一行。
* 为什么不用灰盒:灰盒在 antd 语言里是「输入区的底色」,回显用它是借错了语义;
* Descriptions 就是 antd 为「详情回显」准备的组件,明暗两档、圆角、分隔线
* 全都跟主题走,不需要再养一套私有皮肤(度量集中在 app.css `.nex-info`)。
*/
export type InfoItem = {
key?: string
label: ReactNode
value: ReactNode
/** 等宽回显(路径 / id / 枚举码 / 密钥),走 kit 的 Mono */
mono?: boolean
/** 跨几列(与 antd Descriptions 的 span 同名同义):长地址、一段说明用 span 顶满 */
span?: number
}
/** 分栏数:固定几列,或按断点降列(窄屏/抽屉里 3 列会挤成竖排,交给 antd 自己降) */
export type InfoColumns = number | Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number>>
const INFO_BP: ('xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl')[] = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl']
/**
* 档位向上补齐:写到的那一档=它右边所有档的值。
*
* 症状:antd Descriptions 内部把 column 与内置 {xs:1,sm:2,md:3,lg:3,xl:3,xxl:3} 合并,
* 再由宽到窄取第一个命中的档位。于是只写 `{ xs: 2, sm: 3, lg: 5 }` 的回显,
* 1440 命中的是内置的 xl=3——**声明的 5 列在桌面上永远不生效**;
* 卡片里的 `{ xs: 1, sm: 2 }` 同理,宽屏变成没声明过的 3 列,挤成竖排。
* 做法:把没写的右档填成最近一次声明的值,页面只需要写「从哪一档开始降到几列」。
* 为什么在容器补:12 个页面写的都是「窄屏少列、宽屏多列」这一个意图,
* 让每个页面记住 antd 的默认表并要求它写满六档,是规范在给自己找麻烦。
*/
export function fillInfoColumns(column: InfoColumns): InfoColumns {
if (typeof column === 'number') return column
const out: Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl', number>> = { ...column }
let last: number | undefined
INFO_BP.forEach((bp) => {
if (out[bp] !== undefined) last = out[bp]
else if (last !== undefined) out[bp] = last
})
return out
}
export function Info({ items, column = 1, className, title, extra }: {
items: (InfoItem | null | undefined | false)[]
column?: InfoColumns
className?: string
/** 这一组回显的标题(antd Descriptions 的 title,走主题字号,不用页面自己写 h4) */
title?: ReactNode
/** 标题行右端动作(antd 5.29 Descriptions.extra):与标题同一行,不再另起一排 */
extra?: ReactNode
}) {
const real = items.filter(Boolean) as InfoItem[]
if (!real.length) return null
return (
<Descriptions className={cn('nex-info', className)} size="small" bordered colon={false}
column={fillInfoColumns(column)} title={title} extra={extra}
items={real.map((it, i) => ({
key: it.key ?? String(i), label: it.label, span: it.span,
children: it.mono ? <Mono className="wrap-anywhere">{it.value}</Mono> : it.value
}))} />
)
}
/**
* Info 里的计数值(.nex-info 的 number 档):等宽数字 + 可选单位。
*
* 症状:回显表里的 0 和 3 一样粗一样亮,一屏八个数字读不出哪个要管;
* 这套「非零才上语义色」的口径原先写在调度中心页面里(局部函数 cnt),
* 质检页要做同一个块只能再抄一遍——规范 §13.1 要求口径只有一份。
* 做法:0 一律降到 colorTextTertiary(「没有要处理的」),非零才按 tone 上
* success / warning / error;单位(条 / 次)比数字小一档、跟着降灰。
* 为什么是组件不是常量函数:它出现在 12 个页面的 items 里,JSX 写法与 Info 一致。
*/
const COUNT_TONE: Record<'ok' | 'warn' | 'bad', string> = { ok: 'text-success', warn: 'text-warning', bad: 'text-error' }
export function Count({ n, unit, tone }: { n?: number; unit?: string; tone?: 'ok' | 'warn' | 'bad' }) {
const num = Number(n) || 0
return (
<span className={`font-mono text-xs font-semibold ${num ? (tone ? COUNT_TONE[tone] : '') : 'text-text-tertiary'}`}>
{num}
{unit ? <span className="ml-0.5 text-xs font-normal text-text-tertiary">{unit}</span> : null}
</span>
)
}
/**
* 卡片行(.cardrow):标题 + 说明 + 右侧动作,列表里重复项的统一骨架。
@ -624,11 +379,3 @@ export function CardRow({ title, children, right, className, tone = 'border' }:
</div>
)
}
/** 元信息一行(.meta) */
export function Meta({ children, className }: { children: ReactNode; className?: string }) {
return <Flex gap={8} align="center" wrap className={cn('min-w-0 text-xs text-text-tertiary', className)}>{children}</Flex>
}
/** 行内动作组(.actions):唯一实现在 Controls.CardActions,这里只转发旧名字 */
export { Actions } from './Controls'

View File

@ -0,0 +1,128 @@
/**
* 状态表面(阶段 6 自 `Panel.tsx` 拆出,实现原样搬移):
* 「这一块正在发生什么 / 什么都没有 / 出了什么错」只有这五个名字,
* 对应 NEX 06 §7 的 loading · empty · error。
*
* 口径(不要在这里长出第六把尺子):
* · 首屏等待 = <SkeletonBlock>(形状可预期),局部刷新 = <Spinner>(不打断阅读);
* · 什么都没有 = <Empty>,文案按三分类写(还没生成 / 筛完没有 / 出错后为空);
* · 贴在内容块上方的结果说明 = <Notice>,它是 R19 反馈四级的第二级
* (第一级贴在控件旁:ErrorText / LineHint;第三、四级在 Toast.tsx 与 Confirm.tsx)。
*/
import { type CSSProperties, type ReactNode } from 'react'
import { Empty as AntEmpty, Flex, Progress, Skeleton } from 'antd'
import { cn } from '../../lib/cn'
import { IconClose, IconLoading } from '../icons'
import { Button } from './Button'
import { BLOCK_TONE } from './Panel'
import { NOTICE_TONE, TONE_ICON, TONE_TINT } from './tone'
/** 进度条:antd Progress(站内只有这一条;bad=异常态用 antd 的 exception 色) */
export function ProgressBar({ value, bad, className }: { value: number; bad?: boolean; className?: string }) {
const pct = Math.max(0, Math.min(100, Number(value) || 0))
return (
<Progress percent={pct} showInfo={false} status={bad ? 'exception' : 'normal'}
size="small" className={cn('nex-progress min-w-[60px]', className)} />
)
}
/** 空态:antd Empty(简单图,站内不放插画——卡片里那块地方给不起) */
export function Empty({ children = '暂无数据', className }: { children?: ReactNode; className?: string }) {
return <AntEmpty className={cn('my-2', className)} image={AntEmpty.PRESENTED_IMAGE_SIMPLE} description={children} />
}
/* 「读取中:一块居中的 Spin」这个导出(旧 <Loading>)在阶段 4 删掉了:
它全站只有三处调用,三处都是**首屏**,而首屏的正确表面是下面的 <SkeletonBlock>。
留着它等于给后来人留一把会退回「空白 + 转圈」的尺子——局部刷新请用 <Spinner>,
整块等待请用 <SkeletonBlock>,两者都够用。(审计报告 D6 / V6 · UI规范 §15.3) */
/**
* 首屏骨架 = antd Skeleton(阶段 4 · 补 NEX 06 §7 的 loading 态)。
*
* 症状:全站 0 处骨架。首屏是「一块空白 + 一颗转圈」——路由分包在拉、项目在拉,
* 内容区只有一枚居中 Spin(实测 240px 高的空盒子)。读者既不知道这里将出现
* 什么形状的东西,也分不清「在加载」和「加载完什么都没有」。
* 做法:骨架只用在**首屏**两处——① 路由级 Suspense 兜底(`app/App.tsx::PageLoading`),
* ② 抽屉正文(`ui/Overlay.tsx::Drawer` 的 `loading`)。
* 面板头 / 字段级的刷新维持内联 `Spinner`,那是成熟设计,不要拿骨架去闪。
* 为什么只有 rows / title 两个参数:站内首屏只有两种形状——「一摞段落」与
* 「一行标题 + 一摞段落」,都在 antd Skeleton 自己的档位里;开更多参数
* 等于给页面发第二把尺子(想要别的形状说明那一处不是首屏)。
* `nex-skeleton` 是闸门落点:像素检查要能认出「这一屏此刻是骨架」,
* 才不会把骨架当成空白内容误判成 empty 态。
* `label` 决定这摞骨架对读屏说不说话:一屏只该有一句进度播报,
* 所以纯装饰的那一段(页头形状)不传 label,它整块 `aria-hidden`。
*/
export function SkeletonBlock({ rows = 3, title = true, label, className, style }: {
/** 段落行数(antd 默认 3 行,这里对齐成站内首屏的常见高度) */
rows?: number
/** 要不要那一行标题占位:页头形状用 true,正文里续段用 false */
title?: boolean
/** 读屏与低视力用户看到的进度说明;只挂 sr-only,不占版面。不传 = 这摞纯装饰 */
label?: string
className?: string
style?: CSSProperties
}) {
return (
<div className={cn('nex-skeleton min-w-0', className)} style={style}
role={label ? 'status' : undefined} aria-busy="true"
aria-hidden={label ? undefined : true}>
<Skeleton active title={title} paragraph={{ rows }} avatar={false} />
{label ? <span className="sr-only">{label}</span> : null}
</div>
)
}
/** 行内小转圈(按钮、状态条里那颗) */
export function Spinner({ className }: { className?: string }) {
return <IconLoading spin aria-hidden className={cn('align-[-1px] text-xs', className)} />
}
/**
* 提示条:自绘表面,**不用 antd `Alert`**(2026-11 第十三轮)。
*
* 症状(用户原话「整体修改系统中所有提示窗、完成后的反馈 tips 等。不要使用默认组件」):
* 这一层原来是 antd Alert 的直封装,于是站内同时存在两套「信息块长相」——
* 同一页里 <Block> 系列有语义描边 + 语义底纹 + 圆角 + 内边距档位,
* 而 Alert 是 antd 自带的那套(浅色档还带着它自己的 closable 图标位置),
* 并且它**没有 action 位**:App.tsx 那条「后端连接异常」要挂「重试」按钮,
* 只能绕过 kit 直接 import antd 的 Alert。
* 做法:读 R16.3 那把唯一的尺子 `BLOCK_TONE`(语义底纹 + 语义描边),
* 左侧色块用色块族(20px 档,与概况抽屉的七站行同一尺寸),
* 两行文案 = `children`(一句人话)+ `description`(明细 / 善后),
* 右侧新增 `action` 位(重试、去设置这种善后按钮),`onClose` 走标准图标按钮。
* props 与原来完全一致(含 antd 词汇的 `type`),30 处调用点零改动。
* 为什么保留 antd 的 type 词汇:`type="success" | "error"` 这套名字已经写在 30 处调用点里,
* 它是**语义**而不是皮肤;`NOTICE_TONE` 把它翻成站内语气,皮肤换多少轮都不用碰页面。
*/
export function Notice({ children, description, danger, className, onClose, type, action }: {
children: ReactNode; danger?: boolean; className?: string; onClose?: () => void
/**
* 第二层说明(与 antd Alert 同名):`children` 是「一句人话」的标题,
* 多条明细 / 善后按钮属于正文,塞进 children 会让整块只有一层粗体、
* 明细和按钮跟着一起加粗,于是页面又自己写 <b> + <p> 造第二层。
*/
description?: ReactNode
/** Alert 的四档语义;`danger` 是站内先写下的 error 简写,两者等价 */
type?: 'info' | 'success' | 'warning' | 'error'
/** 右侧善后动作(重试 / 去设置);一颗 Button 或一组按钮,不放正文 */
action?: ReactNode
}) {
if (!children) return null
const tone = NOTICE_TONE[type ?? (danger ? 'error' : 'info')]
return (
<Flex align="start" gap={10} role={tone === 'bad' || tone === 'warn' ? 'alert' : undefined}
className={cn('nex-notice mb-4', BLOCK_TONE[tone], className)}>
<span className="nex-notice-mark" aria-hidden
style={{ ['--nex-mark-tint' as string]: TONE_TINT[tone] }}>{TONE_ICON[tone]}</span>
<div className="min-w-0 flex-1">
<div className="nex-notice-title">{children}</div>
{description && <div className="nex-notice-desc">{description}</div>}
</div>
{action && <div className="nex-notice-action flex flex-wrap items-center gap-2">{action}</div>}
{onClose && <Button type="text" size="sm" className="nex-notice-close" aria-label="关闭提示"
title="关闭提示" icon={<IconClose />} onClick={onClose} />}
</Flex>
)
}

View File

@ -7,13 +7,13 @@
* Tag 只读名词标签——「竖屏」「已锁定」这类「它是什么」
* Status 只读状态标签——后端状态枚举经 statusTone() 映射成色调
* Badge 数字气泡——计数,挂在标题右侧
* Chip 可点的筛选 / 开关胶囊(ui/Controls.tsx)
* Chip 可点的筛选 / 开关胶囊(ui/Ctlbar.tsx)
*/
import type { ReactElement, ReactNode } from 'react'
import { Badge as AntBadge, Tag as AntTag } from 'antd'
import { cn } from '../../lib/cn'
import { statusLabel, statusTone } from '../../lib/format'
import { GROUP_LABEL_CLS } from './Controls'
import { GROUP_LABEL_CLS } from './Ctlbar'
export type TagSize = 'sm' | 'md'
/** 密集档:挂在容器上(表格单元格、TagGroup size="sm"),整片标签一起降 */

View File

@ -7,8 +7,8 @@
* 1100px 上下会同时出现两种列数——这正是用户说的「布局还是不对」的一部分。
* 做法:只保留 antd 的六个断点。旧语义 max-xl:grid-cols-2 = 「宽度 ≤1200 时两列」
* = antd 的 lg 及以下,所以档位名按**断点下界**解释:命中所有下界更小的断点。
* 为什么单独一个文件:Panel(Grid/StatGrid)、Page(Layout/Stack)、Controls
* (FormRow)都要铺列,共用一份换算才不会三处三种降列节奏。
* 为什么单独一个文件:Panel(Grid/StatGrid)、Page(Layout/Stack)、Ctlbar(等分控件栏)、
* Fields(FormRow)都要铺列,共用一份换算与同一张降列表,才不会四处四种降列节奏。
*/
import { Children, Fragment, isValidElement, type ReactNode } from 'react'
import { Col } from 'antd'
@ -101,3 +101,17 @@ export function splitSpans(main: number, aside: number, oneAt: GridCollapse = 'x
}
return { main: build(main, 24), aside: build(aside, 24) }
}
/* 每行 N 个块时的降列节奏(Ctlbar/OptionGrid 铺等分格、Fields 的 FormRow 都读这一张)::档位名就是 antd Grid 的断点,站内不再有 900/1100 这种私有宽度。
⚠ 档位按**正文宽**取,不是按视口宽:侧栏占 224(≤md 折叠成 64)+ 内容内边距 32,
768 视口的正文只有 512。原先 5 等分在 md 档给到 3 列,实测每格 158——
「素材类型」的标签 69 之后只剩 69 给下拉,选中值「全部类型」77px 被省略号裁成 53px
(visualcheck 768 档 /assets 三条红灯)。整体降一档后 ≤1600 四列、≤1200 三列、
≤992 两列、≤576 单列,最窄的一格也有 231px。 */
export const ROW_STEPS: Record<number, GridStep[]> = {
2: [{ at: 'sm', cols: 1 }],
5: [{ at: '2xl', cols: 4 }, { at: 'xl', cols: 3 }, { at: 'lg', cols: 2 }, { at: 'sm', cols: 1 }],
3: [{ at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
4: [{ at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }],
6: [{ at: 'xl', cols: 4 }, { at: 'lg', cols: 3 }, { at: 'md', cols: 2 }, { at: 'sm', cols: 1 }]
}

View File

@ -3,8 +3,11 @@ export * from './Input'
export * from './Checkbox'
export * from './Status'
export * from './Panel'
export * from './State'
export * from './Info'
export * from './Page'
export * from './Controls'
export * from './Ctlbar'
export * from './Fields'
export * from './Table'
export * from './Overlay'
export * from './Menu'
@ -15,7 +18,7 @@ export * from './IconText'
export * from './Tile'
export * from './Slider'
export * from './grid'
/* 反馈四级表面(R19):语义表 → 提示条(Panel 里的 Notice)→ 吐司 → 确认框 */
/* 反馈四级表面(R19):语义表 tone → 提示条 State 里的 Notice → 吐司 Toast → 确认框 Confirm */
export * from './tone'
export * from './Toast'
export * from './Confirm'

View File

@ -1,5 +1,3 @@
export * from './use-async'
export * from './use-polling'
export * from './use-local-storage'
export * from './use-auto-refresh'
export * from './use-refresh-on-activity'

View File

@ -1,54 +0,0 @@
/**
* 一次「读接口 → 渲染」的标准生命周期。
*
* 页面里 90% 的数据获取都是同一个形状:进页面拉一次、点按钮重新拉、
* 失败就把 detail 显示出来。写成 Hook 后每个页面少了六行样板,
* 更重要的是「组件卸载后不再 setState」这件事只在这里处理一次。
*/
import { useCallback, useEffect, useRef, useState } from 'react'
export type UseAsyncOptions = {
/** 默认 true:挂载即执行。纯手动触发(表单提交)时传 false */
immediate?: boolean
/** 首帧占位值,避免 `data?.map` 之类到处判空 */
initial?: any
}
export function useAsync<T = any>(fn: () => Promise<T>, options: UseAsyncOptions = {}) {
const { immediate = true, initial = null } = options
const [data, setData] = useState<T | null>(initial)
const [loading, setLoading] = useState(immediate)
const [error, setError] = useState('')
const alive = useRef(true)
const latest = useRef(fn)
latest.current = fn
useEffect(() => {
alive.current = true
return () => { alive.current = false }
}, [])
const run = useCallback(async (): Promise<T | null> => {
setLoading(true)
setError('')
try {
const result = await latest.current()
if (!alive.current) return null
setData(result)
return result
} catch (exc: any) {
if (alive.current) setError(exc?.message || String(exc))
return null
} finally {
if (alive.current) setLoading(false)
}
}, [])
useEffect(() => {
if (immediate) void run()
// 只在挂载时跑一次:依赖变化后的重拉由调用方显式 run()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
return { data, setData, loading, error, setError, run }
}

View File

@ -1,23 +0,0 @@
/**
* 轮询:把「setInterval + 最新回调 + 暂停条件」收在一处。
*
* paused 是这里的关键参数:弹窗打开、正有人在录音时暂停,
* 否则刷新一重建列表,抽屉里刚填一半的表单会被连根拔掉。
*/
import { useEffect, useRef } from 'react'
import { useActivityStore } from '../stores/activity'
export function usePolling(tick: () => void, intervalMs = 6000, paused = false, enabled = true) {
const latest = useRef(tick)
latest.current = tick
/* 与 useAutoRefresh 共用顶栏那个全站开关:语义都是「页面自己重拉数据」 */
const autoRefresh = useActivityStore((s) => s.autoRefresh)
useEffect(() => {
if (!enabled || !autoRefresh || intervalMs <= 0) return
const timer = window.setInterval(() => {
if (!paused && document.visibilityState === 'visible') latest.current()
}, intervalMs)
return () => window.clearInterval(timer)
}, [intervalMs, paused, enabled, autoRefresh])
}

View File

@ -130,7 +130,7 @@ textarea) { width: 100%; min-width: 0 }
antd 的 horizontal 布局本身就是标签在左,只是它为表单场景把标签**右对齐**
并留了 8px 标签内边距;横扫读的筛选条要左起、且标签不许把控件顶歪,
所以标签列 flex:none + 左对齐,控件列也不参与挤压(工具条里的控件宽度
由字段自己的 width / grow 决定,见 Controls.tsx 的 WIDTHS)。 */
由字段自己的 width / grow 决定,见 Fields.tsx 的 WIDTHS)。 */
.nex-field-inline { margin-block-end: 0 }
.nex-field-inline .ant-form-item-row { flex-wrap: nowrap; align-items: center }
.nex-field-inline .ant-form-item-label { flex: none; text-align: start; padding: 0; margin-inline-end: var(--ant-margin-xs) }

View File

@ -191,7 +191,7 @@ console.log(`${stray.length} 处绕过登记表的图标 import(只许 ${path.
/* ── 第 3 条:裸 <button> 收口到自定义表面族 ──────────────────────────────
每条都要写清「为什么不是 antd Button」;新增文件先进这张表,别先写裸按钮。
Controls.tsx 曾在表里:Chip / TagChip 后来全部改由 antd `Tag` /
Controls.tsx(阶段 6 已拆成 Ctlbar.tsx + Fields.tsx)曾在表里:Chip / TagChip 后来全部改由 antd `Tag` /
`Tag.CheckableTag` / `Typography.Link` 承担,裸 <button> 命中数归零,条目已删。 */
const CUSTOM_SURFACES = {
'src/components/ui/Overlay.tsx': 'Scrim:整屏遮罩,点空白关闭;不是按钮,是命中区',
@ -413,7 +413,8 @@ console.log(`${antdStray.length} 处越界的 import 'antd'(R8:只许 theme/
为什么用正则不用 AST:这些都是**函数名 / 组件名**层面的口径,
正则命中的就是要禁的那几个名字,AST 反而要多写一层解析;
漏报的代价是全站又长出第五套皮肤,误报的代价只是往白名单加一行。
白名单是实现本体:吐司 / 确认框 / 提示条三个组件 + 两个 store。
白名单是实现本体:吐司 / 确认框 / 提示条三个组件 + 两个 store
(提示条 `Notice` 自阶段 6 起住在 `components/ui/State.tsx`,白名单同步跟上)。
2026-11-07(阶段 5):正则原本只匹配字面 `window.confirm(`,浏览器里裸调用
`confirm(...)` 是**同一个**原生对话框,Library.tsx 因此漏过 5 处。
放宽后的口径 = 「前面不是 . / $ / 词字符,可带 window. 前缀」:
@ -423,7 +424,7 @@ console.log(`${antdStray.length} 处越界的 import 'antd'(R8:只许 theme/
放行 6 —— confirmAction( / Modal.confirm( / lib.confirm( / notconfirm( / myalert( / x.window.confirm(
(`(?<![\w.$])` 放在**可选前缀之前**:写成 `(?:\bwindow\.)?(?<![\w.$])` 会让
前缀吃掉 `window.` 之后回头看那个点,把 window.confirm( 整个漏掉——阶段 5 先踩过一次。) */
const FB_IMPL = /^components\/ui\/(Toast|Confirm|Panel|Button|tone)\.tsx$|^stores\/(notice|confirm)\.ts$/
const FB_IMPL = /^components\/ui\/(Toast|Confirm|State|Panel|Button|tone)\.tsx$|^stores\/(notice|confirm)\.ts$/
const FB_RULES = [
[/(?<![\w.$])(?:window\.)?(?:confirm|alert)\s*\(/, '浏览器原生 confirm / alert(含省略 window. 的裸调用)'],
[/\bModal\.confirm\s*\(/, 'antd Modal.confirm 默认问话框'],