前端统一到 React 18 + Ant Design 5 + Vite + Zustand + React Router 6:控件不再在原生件上缝皮,Radix 那一层整体换成 antd 标准件 + 一层自有 kit,并把「谁定义控件」收口成词汇表。
用户连着三轮指出「字段标题、控件不对齐」「下拉控件的样式不对」,最后点名技术栈。真正的病不在
antd 还是 Radix,而在同一件事有三千种写法:左导航内边距一页 11px 一页 12px,白名单要从页面
className 上抄切片才能命中。上一轮 Radix 只外包了行为,皮肤仍由 30 多个页面自己拼,且没有任何
机制阻止分叉长回来。这一轮改的是词汇表:页面只准说业务,控件怎么长由 kit 层 + 一份令牌说了算。
底座(读数见报告 26.2):react 19.3.1→18.3.1、react-router-dom 7.18.5→6.30.6(点名为 18/6,是
降级,代价见 26.6)、新增 antd 5.29.3 + @ant-design/icons 6.3.4,@radix-ui/* 5 包与
class-variance-authority 清零;zustand/vite/tailwindcss 4.3.3 不变,Tailwind 留作皮肤 utility。
删 components/primitives/(11 文件 1133 行)与 styles/{base,tokens}.css;净 +488 行不是「少一千行」,
是同样面积的代码从三十个页面挪进两个目录——省的不是字节,是分叉次数。
新增:
- app/providers.tsx:ConfigProvider + <App> 唯一入口(主题、zh_CN、button.autoInsertSpace:false、cssVar),
命令式 message/notification/modal 挂 antdApi 供 stores/ 使用;React Router 的 v7 future flag 一处收口。
- theme/{palette,antd,css-vars,metrics}.ts:数字只有一个来源 metrics.ts → 同时喂 antd ThemeConfig 与
--ctl-h-*/--radius-*/--text-*,antd 控件与自绘区读同一把尺子,结构上长不歪了。
- components/ui/{Input,Checkbox,Menu,Rail,Tile,Overlay,field-labels};lib/layers.ts(Esc 先看有没有 antd
浮层压着,否则分镜检查器里关一个下拉整层抽屉一起没)、lib/ref.ts、hooks/use-narrow.ts(触摸档必须
同时喂给 antd 的 JS 数字,否则 560/430 一屏混着 31/38 与 36/40 两把尺子——首跑量出的 61 项就这么来的)。
- styles/app.css 接替 base+tokens,只留元素默认值与三处必须靠 CSS 的 antd 集成。
- scripts/ui/ 三件套首次入库:audit.py 七项机器判据 × 14 视图、vocab.py 六条源码词汇表闸、metrics.py。
修掉四个探针全绿也看不见的静默 bug:
1) 探针会假绿:浮层用例找不到抽屉时兜底 scope=main 把页面重量一遍,分镜「检查器」29 字段/57 输入
/35 按钮(在 main 外面的 aside 里)一条都没测过。
2) Select 选中 null 回显成灰色 placeholder:antd 把 null 当无值,而「不绑定/无台词/未指定」的真实值
就是 null(接口收 null,10 处)。kit 内折哨兵 nex-null,出入口各折一次,页面 API 一字未改。
3) JSX 子节点上的 /* */ 不是注释而是文本,挂在应用外壳之上把整站下推约 30px;移到 JSX 外并立词汇表规则 6。
4) 抽屉可以整块开在屏幕外面:Overlay 用 getContainer={false} 让 antd 就地渲染,rootStyle 的 absolute
于是相对文档定位——入口按钮在折叠线以下时抽屉 y=-scrollY(1440 lib_edit 只剩 201px,430 assets_gen
完全不可见,用户点了「AI 生成」像没反应)。改 fixed 后四档 10 个浮层全部 y=0 完整可见。为此给 audit
加第 7 项判据 surface(浮层完整落在视口内 + 中心点 elementFromPoint 命中自己),反向验证:改回
absolute 后 430 下 4 红 exit=1;判据取「有交集」太松(42px 也算过),收紧为「完整在视口内」才对。
验收(复跑读数):audit --only page 1440/1280/900 × 明暗 6 组 84 行视图全 0、exit=0;--only overlay
1440/900/560/430 × 明暗 8 组 exit=0,surface 80/80 绿,72 个下拉样本 popW==trigW、inViewport、
optClipped=false、popOnTop=false 计 0;vocab 85 文件/皮肤常量 79(账实相符)exit=0;
npm run build(tsc+vite)exit=0(ui chunk 881.94 kB / gzip 278.63);probe_nullopt CLEAN、probe_secretref PASS。
文档同步:UI规范 §8 判据清单五项→七项(补 surface)、§1.3 新增「抽屉可以整块开在屏幕外面」;
工程规范 §1.1 体检器职责改为 10 浮层 × 4 宽度 × 七项;README 六项→七项判据;报告补第二十六章
26.1–26.9(选型换向、版本读数、四条根因、改法、逐项验收、降级代价、注释泄漏、仍未做、抽屉开在屏外)。
main
parent
83d262a199
commit
4521c9f926
68
README.md
68
README.md
|
|
@ -11,7 +11,7 @@
|
|||
> 目录职责、`scripts/` 准入规则、测试规范、改动后的最低验收三连,以及服务器上「什么该搬、什么不该搬」。
|
||||
|
||||
```
|
||||
┌──────────────────────── Browser (React + Vite + Tailwind CSS) ─────────────────────────┐
|
||||
┌─────────── Browser (React 18 + Ant Design 5 + Vite + Zustand + Router 6) ─────────────┐
|
||||
│ 项目总览 │ 资产库 │ 分镜与脚本 │ 调度中心 │ 质检与审核 │ 时间线合成 │ 导出与成本 │
|
||||
└─────────────────────────────────────┬───────────────────────────────────────────────────┘
|
||||
│ REST / JSON + multipart (vite proxy 或 nginx)
|
||||
|
|
@ -35,7 +35,8 @@
|
|||
|
||||
```text
|
||||
backend/ FastAPI 应用:app/api 路由 · app/services 编排 · app/providers 模型适配 · tests 回归用例
|
||||
frontend/ React 19 + Vite + Tailwind CSS v4 工作台(图文手册 = src/pages/Help.tsx,截图在 public/help/)
|
||||
frontend/ React 18 + Ant Design 5 + Vite + Zustand + React Router 6 工作台
|
||||
(图文手册 = src/pages/Help.tsx,截图在 public/help/)
|
||||
scripts/ 只放启动 / 部署 / 运维脚本(下表);一次性验证探针不进这个目录
|
||||
docs/ UI 规范、工程规范、H3 性能诊断记录
|
||||
media/ 产物库(MEDIA_ROOT) models/ whisper 词级对齐权重 reports/ 阶段验收证据
|
||||
|
|
@ -49,26 +50,55 @@ media/ 产物库(MEDIA_ROOT) models/ whisper 词级对齐权重 r
|
|||
api/ 唯一的 fetch 出口:信封自动拆包、detail 统一成 Error、401 跳登录
|
||||
app/ 应用外壳:router.tsx 路由表(唯一一份)· layout/ 顶栏侧栏鉴权闸门
|
||||
pages/ 页面与项目页签,一屏一文件;页面私有的类名常量/子组件留在文件底部
|
||||
components/ 无业务语义的原语,四个目录按职责分:
|
||||
ui/ 版式与控件(Button/Field/Ctlbar/Table/Modal/Drawer/Tag…)
|
||||
forms/ 选择器族(Select/MultiSelect/SecretInput + toOptions)
|
||||
media/ 带全局状态的媒体件(MediaThumb/AudioPlay/MediaLightbox/WorkflowBar…)
|
||||
primitives/ 控件行为层(Radix primitives + CVA 皮肤:Popup/Dialog/Menu/Checkbox/Slider)
|
||||
stores/ zustand 切片:auth · theme · notice · project · models · system · audio · preview
|
||||
hooks/ use-async / use-polling / use-auto-refresh / use-outside-click / use-local-storage
|
||||
lib/ 纯函数与适配器:cn · format · media · pipeline · recorder · versions
|
||||
styles/ tokens.css(设计令牌 = 唯一尺子来源)· base.css(元素级基线)
|
||||
components/ 页面只从这里取组件,三个目录按职责分:
|
||||
ui/ antd 的唯一封装层 + 自绘版式件(Button/Input/Checkbox/Menu/Overlay/Status
|
||||
+ Field/Ctlbar/FormGrid/Table/Steps/Tabs/Pager/Rows…)
|
||||
forms/ 选择器族(Select/MultiSelect/SecretInput + toOptions,本体是 antd Select)
|
||||
media/ 带全局状态的媒体件(MediaThumb/AudioPlay/RecordAudio/MediaLightbox/VersionPanel…)
|
||||
theme/ 尺子与皮肤:metrics.ts 档位数值 · antd.ts 33 个 ComponentToken
|
||||
· css-vars.ts 启动时注入 --ctl-h*/--tag-*/--radius-*/--fs-* · palette.ts 明暗色板
|
||||
stores/ zustand 切片:auth · theme · notice · project · models · system · audio · preview · recording
|
||||
hooks/ use-async / use-polling / use-auto-refresh / use-local-storage(浮层外点关闭交给 antd,不再自己实现)
|
||||
lib/ 纯函数与适配器:cn · format · media · pipeline · recorder · versions · layers
|
||||
styles/ index.css(Tailwind @theme:语义名 → 变量,零像素)· app.css(语义布局类 +
|
||||
全站唯一允许写 .ant-* 的地方)
|
||||
```
|
||||
|
||||
新增页面只做三件事:在 `pages/` 落文件 → 在 `app/router.tsx` 注册 → 复用 `components/*` 原语,
|
||||
缺原语就补进 `components/`(不要复制粘贴样式)。加一类新母版/新页签同理:改表不改逻辑(见 `docs/工程规范.md` §1.1)。
|
||||
|
||||
**控件不引成套组件库**(antd / MUI / Arco 都否掉了):行为层统一用 **Radix UI Primitives**,
|
||||
皮肤层是自己的一套令牌(`styles/tokens.css` + CVA),即 shadcn/ui 的架构、但不带第三方皮肤——
|
||||
组件源码在 `components/primitives/` 里可直接改,深浅两套 studio 视觉不用跟组件库的默认 token 抢方向盘。
|
||||
因此 `package.json` 只有 5 个 `@radix-ui/*`(popover / dialog / dropdown-menu / checkbox / slider),
|
||||
且每一个都有 import;页面里不许出现裸 `<select>`、原生 `checkbox`/`range`,也不许直接 `import '@radix-ui/*'`。
|
||||
选型理由、分层规矩与两个 Tailwind 陷阱见 `docs/UI规范.md` §0.6。
|
||||
**控件统一用 Ant Design 5**(2026-11-02 定案,此前「Radix primitives + 自有皮肤」那一版已废弃):
|
||||
浮层定位、翻边避让、焦点圈定与归还、键盘、Esc 分层、锁滚动这些行为不再自己实现——
|
||||
自己实现时「字段标题与控件不对齐」「下拉面板该翻不翻被压成 35px」这类问题修不完,
|
||||
而每一项都是组件库早就解决过的。**尺子和皮肤仍然是自己的**:`theme/metrics.ts` 出数值、
|
||||
`theme/antd.ts` 把它写成 33 组 ComponentToken、`theme/css-vars.ts` 在 `createRoot` 之前注入
|
||||
同源的 CSS 变量,Tailwind 类与 antd token 读同一份 TS,不可能漂成两套。
|
||||
硬边界:全仓库只有 `theme/` · `app/providers.tsx` · `components/{ui,forms,media}` 可以
|
||||
`import 'antd'`;`.ant-*` 选择器只准出现在 `styles/app.css`;`pages/` 与 `app/` 里
|
||||
**一个原生 `<button>` / `<input>` / `<select>` / `<textarea>` 都没有**(最后 17 个 `<button>`
|
||||
在 2026-11-02 那轮收进 kit:整块热区 `Tile` / `DisclosureRow`、工具按钮 `ToolButton`、
|
||||
图标位 `IconSpot`、菜单行 `MenuRow`、遮罩 `Scrim`、媒体角标 `MediaRemove` / `MediaPick`),
|
||||
也不许给控件拼 `bg-`/`border-`/`rounded-`。
|
||||
自绘区只剩三块并已在规范里登记边界:`Table`、`Steps`、媒体区(缩略图 / 播放条 / 录音 / 灯箱 / 时间线)。
|
||||
再加一条 **ref 契约(R10)**:kit 组件一律 `forwardRef`,交给页面的 ref 只能是真实 DOM 节点,
|
||||
antd 的 `InputRef` / `TextAreaRef` 在 kit 内部折掉(`lib/ref.ts`)——React 18 的函数组件收不到 ref,
|
||||
`tsc` 不报错、像素不变,四处「点了不聚焦」就是这么静默死掉的(报告 26.6)。
|
||||
这些边界都不靠自觉:`scripts/ui/vocab.py` 逐文件比对源码用词(antd 落点 / 页面禁原生控件 /
|
||||
只读胶囊 / 私有皮肤棘轮 / ref 契约 / JSX 子节点上的注释,共六条),渲染结果由 `scripts/ui/audit.py` 量
|
||||
(七项判据:裸控件、字段错位、高度档位、横向溢出、下拉、**console 报错**、**浮层是否真的在视口内**)。选型理由(三条实测依据)、
|
||||
四层分工、四个咬过人的陷阱见 `docs/UI规范.md` §0.6,两道闸的口径见 §1.3 / §1.4。
|
||||
|
||||
改过控件、表单或主题,提交前跑一遍 UI 体检(前端 5173 与后端 8000 需在跑):
|
||||
|
||||
```bash
|
||||
cd frontend && npm run typecheck && npm run build
|
||||
.venv/bin/python scripts/ui/vocab.py # 词汇表 lint(不用起服务)
|
||||
.venv/bin/python -u scripts/ui/audit.py --width 1440 1280 900 --theme both --only page # 渲染结果体检
|
||||
.venv/bin/python -u scripts/ui/audit.py --width 1440 900 560 430 --theme both --only overlay
|
||||
```
|
||||
|
||||
体检默认量 dev server(5173):**`console` 那一项只能在 dev 上量**——React 与 antd 的告警是
|
||||
DEV-only,拿 `NEX_UI_BASE=:4173` 量构建产物时它恒为 0,别把那份绿当证据。
|
||||
|
||||
| 脚本 | 干什么 | 在哪儿跑 |
|
||||
| --- | --- | --- |
|
||||
|
|
@ -544,7 +574,9 @@ blackdetect / freezedetect / font`。当 `subtitle_burn=false`(本机 ffmpeg
|
|||
```bash
|
||||
cd backend && ../.venv/bin/python -m pytest -q # 全量回归,约 3 分钟,必须全绿
|
||||
bash -n scripts/*.sh # 脚本语法(shellcheck 没装也别跳过这条)
|
||||
cd frontend && npm run build # 类型与打包
|
||||
cd frontend && npm run build # 类型与打包(tsc --noEmit && vite build)
|
||||
.venv/bin/python scripts/ui/vocab.py # 前端词汇表 lint(源码用词,秒级)
|
||||
.venv/bin/python -u scripts/ui/audit.py --width 1440 1280 900 --theme both --only page # UI 体检
|
||||
```
|
||||
|
||||
碰到派发 / 合成 / 部署链路的改动,再补一次 §6.2 的端到端自检——pytest 用 TestClient
|
||||
|
|
|
|||
964
docs/UI规范.md
964
docs/UI规范.md
File diff suppressed because it is too large
Load Diff
64
docs/工程规范.md
64
docs/工程规范.md
|
|
@ -13,8 +13,8 @@
|
|||
|---|---|---|
|
||||
| `backend/app/` | 业务代码:`api/` 路由 · `services/` 领域逻辑 · `providers/` 模型适配 · `models/` 表定义 · `schemas/` 契约 | 一次性修数脚本、探针、临时数据 |
|
||||
| `backend/tests/` | 全部自动化用例(契约、回归、真实模型 mock 演练) | 需要人手喂参数的调试脚本 |
|
||||
| `frontend/src/` | React 19 + TypeScript 源码,分层见 §1.1 | 构建产物(`dist/` 是生成物,随时可删重出);页面私有的类名常量不该爬进 `components/` |
|
||||
| `scripts/` | **只有四类**:启动、部署、运维、自检入口(见 §2) | 一次性脚本、验收残渣、临时 patch |
|
||||
| `frontend/src/` | React 18 + TypeScript 源码,分层见 §1.1 | 构建产物(`dist/` 是生成物,随时可删重出);页面私有的类名常量不该爬进 `components/` |
|
||||
| `scripts/` | **只有四类**:启动、部署、运维、自检入口(见 §2)。UI 体检在 `scripts/ui/` | 一次性脚本、验收残渣、临时 patch |
|
||||
| `docs/` | 长期有效的设计/规范/方案文档 | 单次调试的日志粘贴 |
|
||||
| `reports/` | 验收报告 `*.md`(结论 + 证据引用) | 报告本体之外的东西别混进来 |
|
||||
| `.local/` | 本机运行痕迹:`run/` pid、`logs/` 日志、`verify/`、`acceptance*/` 证据 | 任何需要跨机共享的数据 |
|
||||
|
|
@ -24,16 +24,24 @@
|
|||
|
||||
### 1.1 `frontend/src` 分层与扩展点
|
||||
|
||||
前端从 Vue 换成 React + Tailwind 后,目录职责按「**依赖只允许自上而下**」执行:
|
||||
技术栈是 **React 18 + Ant Design 5 + Vite + Zustand + React Router 6**(React 19 从未在本仓库跑过,
|
||||
Tailwind-only + 自研 primitives 那一版已废弃)。目录职责按「**依赖只允许自上而下**」执行:
|
||||
|
||||
```text
|
||||
api/ → app/ → pages/ → components/{ui,forms,media}/ → components/primitives/ → hooks/ · lib/ → styles/
|
||||
api/ → app/ → pages/ → components/{ui,forms,media}/ → theme/ · lib/ · hooks/ → styles/
|
||||
↑ 只有这一层可以 import 'antd'
|
||||
```
|
||||
|
||||
`components/primitives/` 是**行为层**,站在皮肤层下面一层:Radix 负责浮层定位、翻边避让、焦点圈定与归还、
|
||||
键盘、Esc 分层、锁滚动,`primitives/layers.ts` 用 CVA + `tokens.css` 令牌给它套皮肤。
|
||||
`ui/` `forms/` 只认 primitives 给出的业务名字(`Popup` `Dialog` `Menu` `Checkbox` `Slider`),
|
||||
**页面和 `ui/` 都不许直接 `import '@radix-ui/*'`**——换行为库时改动面就是这一个目录。
|
||||
**控件的行为与皮肤全部来自 antd 5**:浮层定位、翻边避让、焦点圈定与归还、键盘、Esc 分层、锁滚动、
|
||||
虚拟滚动、日期/下拉/抽屉/弹窗,都不再自己实现。`theme/` 是唯一给它定尺子的地方——
|
||||
`theme/antd.ts` 写 ComponentToken(402 行 / 33 个组件),`theme/metrics.ts` 写档位数值,
|
||||
`theme/css-vars.ts` 在 `createRoot` 之前把同一份数值注入成 `--ctl-h*` / `--tag-*` / `--radius-*` / `--fs-*`,
|
||||
`theme/palette.ts` 管明暗两套色板。于是 Tailwind 类和 antd token 用的是同一把尺子,漂不到两处去。
|
||||
|
||||
`components/ui/` `forms/` 只认业务名字(`Button` `Input` `Select` `Menu` `Checkbox` `Overlay` `Pager`…),
|
||||
**全仓库只有 `theme/`、`app/providers.tsx`、`components/ui/`、`components/forms/` 四个目录可以
|
||||
`import 'antd'`**(验收:`grep -rn "from 'antd'" frontend/src` 只命中这四目录)——
|
||||
将来换控件库,改动面就是这三个目录 + 主题。页面里出现 `ant-` 类名一样算违规。
|
||||
选型理由与规矩见 [UI规范.md](UI规范.md) §0.6。
|
||||
|
||||
| 目录 | 放什么 | **不**放什么 |
|
||||
|
|
@ -41,13 +49,13 @@ api/ → app/ → pages/ → components/{ui,forms,media}/ → components
|
|||
| `api/` | 唯一的 `fetch` 出口(信封拆包、`detail`→`Error`、401 跳登录) | 业务分支、组件状态 |
|
||||
| `app/` | 外壳:`router.tsx` 路由表 · `App.tsx` 布局与守卫 · `ErrorBoundary.tsx` 分包失败兜底 · `layout/` 顶栏侧栏与 `nav.ts` 页签表 | 任何业务接口调用 |
|
||||
| `pages/` | 一屏一文件;页面私有小组件与类名常量在文件底部 | 页面之间的互相 import |
|
||||
| `components/ui/` | 版式与控件原语(`Button` `Field` `Ctlbar` `Table` `Modal` `Drawer` `Tag` `Pager`…) | 业务字段名、接口路径、直接 import `@radix-ui/*` |
|
||||
| `components/primitives/` | 控件**行为层**:Radix Root + `layers.ts`(CVA 档位)+ `use-listbox`;`Popup` `Dialog` `Menu` `Checkbox` `Slider` | 业务语义、写死的 px(尺寸只能来自 `tokens.css` 变量) |
|
||||
| `components/ui/` | 控件出口 + 版式原语:对 antd 的唯一封装层(`Button` `Input` `Checkbox` `Menu` `Status` `Overlay`…)与自绘版式件(`Field` `Ctlbar` `FormGrid` `Table` `Steps` `Pager` `Rows` `Tabs`);页面只从这里取组件 | 业务字段名、接口路径、绕过 `theme/antd.ts` 直接改 antd 皮肤 |
|
||||
| `theme/` | `metrics.ts` 档位数值 · `antd.ts` ComponentToken · `css-vars.ts` 注入 CSS 变量 · `palette.ts` 明暗色板 | 任何 JSX、任何页面语义 |
|
||||
| `components/forms/` | 选择器族(`Select` `MultiSelect` `SecretInput` + `toOptions`) | 页面专属选项 |
|
||||
| `components/media/` | 带全局状态的媒体件(`MediaThumb` `AudioPlay` `MediaLightbox` `VersionPanel` `WorkflowBar`) | 纯展示(那些进 `ui/`) |
|
||||
| `stores/` | zustand 切片(auth · theme · notice · project · models · system · audio · preview)+ 少量全站静态字典 | 组件本地 state |
|
||||
| `hooks/` `lib/` | 可复用的 effect 与纯函数 | 带 JSX 的东西(那是 `components/`) |
|
||||
| `styles/` | `tokens.css` 设计令牌(唯一尺子来源)· `base.css` 元素基线 | 页面级样式 |
|
||||
| `styles/` | `index.css` = Tailwind `@theme`「语义名 → 变量」转发(不含一个像素)· `app.css` = 语义布局类 + 全站**唯一**允许出现 `.ant-*` 的地方(372 行) | 页面级样式、写死的数值 |
|
||||
|
||||
**扩展点(改表不改逻辑,全部已落地验证)**:
|
||||
|
||||
|
|
@ -56,10 +64,10 @@ api/ → app/ → pages/ → components/{ui,forms,media}/ → components
|
|||
| 加一类平台母版 | `pages/AssetLibrary.tsx:TYPE_META` 加一项 | 左栏、卡片、抽屉标题、生成台全部从这张表取标签/图标/提示 |
|
||||
| 加一个项目页签 | `app/layout/nav.ts` 加一行 + `app/router.tsx` 加子路由(带 `handle` 标题) | 侧栏与文档标题分别由这两处派生,无需注册第三处;新页签自动获得懒加载分包与 `ErrorBoundary` 兜底 |
|
||||
| 改某页每页条数档位 | `Pager` 的 `sizes`(页面里传 `PAGE_SIZES`,`0` = 全部) | 默认档位和「全部」语义在 `Controls.tsx` 一处实现 |
|
||||
| 抽屉想要别的宽度 | `Drawer` 的 `width` 收一个 Tailwind 宽度类 | 默认值只在 `Overlay.tsx` 写一次,页面按屏宽传变体 |
|
||||
| 抽屉想要别的宽度 | `Drawer` 的 `width`(antd 的宽度值) | 默认值只在 `Overlay.tsx` 写一次,页面按屏宽传变体 |
|
||||
| 新增弹窗/表单 | `Modal` `Drawer` `Field` `FormRow` 组合 | 高度、间距、页脚按钮排布由原语和容器 `--ctl-h` 档位兜住 |
|
||||
| 加一类控件行为(tooltip / 命令面板 / 日期选择…) | `primitives/` 新加一个文件(Radix Root + `layers.ts` 档位)→ `ui/` 给业务名字 → 登记进 UI规范 §0.5 与 §0.6 | 行为与皮肤分层,页面那层永远只见到一个组件名;Radix 没提供的(combobox)用 `Popup` + `use-listbox` 拼 |
|
||||
| 控件档外的高度 | 容器上写 `[--ctl-h:var(--ctl-h-md)]` | 控件一律 `h-(--ctl-h)`,禁止单个控件写死像素 |
|
||||
| 加一类控件(tooltip / 日期选择 / 命令面板…) | `components/ui/` 新加一个文件包 antd 组件 → `ui/index.ts` 出口 → 需要定尺子就进 `theme/antd.ts` 的 ComponentToken → 登记进 UI规范 §0.5 | 页面那层永远只见到一个业务组件名;antd 没有合适的(比如整卡热区按钮)才自绘,自绘件登记进 §6 的「自绘区边界」 |
|
||||
| 控件档外的高度 | 容器上挂 `<Dense>`(31px)或写 `[--ctl-h:var(--ctl-h-md)]`;档位数值只有 `metrics.ts` 的 `controlHeight` 31/38/44 | 控件高度由 antd `componentSize` + token 下发,禁止单个控件写死像素 |
|
||||
|
||||
**根目录只允许**:`README.md`、`docker-compose.yml`、`.env`、`.env.example`、`.gitignore`
|
||||
和上面这些目录。历史上漂在根上的 `.schema shots`、`backend/nex_animation.db`(0 字节空库)
|
||||
|
|
@ -77,6 +85,9 @@ api/ → app/ → pages/ → components/{ui,forms,media}/ → components
|
|||
| `seed.py` | 导出与导入「部署数据」(模型配置 + 主密钥 + 管理员) |
|
||||
| `e2e_selfcheck.py` | 对着真实运行的服务跑一遍 12 节点全流程 |
|
||||
| `evidence_prune.py` | 整理验收台账 `.local/acceptance/evidence.jsonl` |
|
||||
| `ui/audit.py` | **前端 UI 体检**:14 视图(含未登录的登录页)× 3 宽度 × 明暗 + 10 个浮层 × 4 宽度 × 明暗,七项判据(裸控件 / 字段错位 / 溢出 / 档位 / 下拉 / console 报错 / **浮层是否真的在视口内**),退出码非 0 就是没过。改过任何控件、表单、主题都要跑(口径见 UI规范 §1.3) |
|
||||
| `ui/vocab.py` | **前端词汇表 lint**:不启动浏览器,只读 `frontend/src`,查「antd 越界 import / 页面里的原生控件 / 点不动的 `<Chip>` / 页面私有皮肤常量棘轮」四条。`audit.py` 量渲染结果,它量源码用词——1px 级别的皮肤分叉只有这里看得见(口径见 UI规范 §1.4) |
|
||||
| `ui/metrics.py` | 体检的取数层:只管从 DOM 读计算样式与几何,不判对错。新增判据先加这里,别在 `audit.py` 里现写选择器 |
|
||||
|
||||
**准入四条**:
|
||||
|
||||
|
|
@ -127,19 +138,26 @@ api/ → app/ → pages/ → components/{ui,forms,media}/ → components
|
|||
文案,而不是 `ValueError: bad input`。
|
||||
- **相对路径必须锚定仓库根**(`app/config.py:get_settings`):media、SQLite、
|
||||
`models/asr/*.bin` 都是相对路径,不锚定就会出现「换个目录启动,历史镜头全 404」。
|
||||
- Python 3.11+(用了 `X | None` 语法);前端 React 19 函数组件 + TS 严格模式
|
||||
- Python 3.11+(用了 `X | None` 语法);前端 React 18 函数组件 + TS 严格模式
|
||||
(`tsconfig` 开了 `noUnusedLocals`:留个没用过的变量就算脏,`npm run build` 直接失败)。
|
||||
- **前端只有 Tailwind 一种样式语言**:尺寸/颜色一律走 `styles/tokens.css` 的令牌
|
||||
(`text-ui` `rounded-control` `bg-sunken` `border-line-strong`…),页面里不写 `style=`、
|
||||
不建 `.css`、不写 `@media`——窄屏行为用断点变体(`max-mid:` `max-narrow:` `max-short:`)写在类上。
|
||||
- **样式语言只有两种,对号入座不混用**:
|
||||
**控件**(按钮 / 输入 / 下拉 / 表格 / 抽屉 / 标签 / 分页 / 提示…)= antd 5,皮肤只来自
|
||||
`theme/antd.ts`,页面**不许**给控件拼 `bg-` `border-` `rounded-`;
|
||||
**布局与自绘区**(flex / grid / 间距 / 断点 + 素材墙、时间线、灯箱、流程条)= Tailwind 工具类,
|
||||
颜色字号只用 `styles/index.css` 的语义名(`text-ui` `rounded-control` `bg-sunken` `border-line-strong`…)。
|
||||
页面里不写 `style=`、不建 `.css`、不写 `@media`——窄屏行为用断点变体
|
||||
(`max-mid:` `max-narrow:` `max-short:`)写在类上;`.ant-*` 选择器只准出现在 `styles/app.css`。
|
||||
- **一页一文件**,页面专属的类名常量与两行就够的小组件留在页面文件底部,
|
||||
被第二个页面用到才提进 `components/`;反向也要提,别让两个页面各养一份皮肤。
|
||||
唯一的例外是 `components/primitives/`:**行为层原语一个用户就进**,因为它换掉的是
|
||||
「谁来实现浮层」这件事的整个成本,不该等第二个用户。
|
||||
唯一的例外是 `components/ui/` 里对 antd 的封装:**一个用户就提**,因为它换掉的是
|
||||
「谁来实现这件控件」的整个成本,不该等第二个用户。
|
||||
- **依赖清单必须等于实际 import**:`package.json` 里装了没人 import 的包要卸载。
|
||||
2026-11-02 清掉 8 个装了没用的 `@radix-ui/*`(tabs / tooltip / label / separator / progress /
|
||||
radio-group / switch / visually-hidden),顺带删掉唯一消费死包链的 `ui/Toggle.tsx`(0 个用户)。
|
||||
判据一条命令:`grep -rho "@radix-ui/[a-z-]*" frontend/src | sort -u` 对 `package.json` 的 dependencies。
|
||||
同一天前端控件层整体换成 **antd 5**,Radix 依赖清零、`components/primitives/` 整目录删除——
|
||||
反向判据同理:`grep -rln "from 'antd'" frontend/src` 命中 `theme/` · `app/providers.tsx` ·
|
||||
`components/ui/` · `components/forms/` 之外的任何文件,就是把控件库漏到了页面里。
|
||||
|
||||
## 5. 部署:数据边界与流程
|
||||
|
||||
|
|
@ -232,7 +250,11 @@ sudo ./scripts/server.sh systemd > /etc/systemd/system/nex-animation.service #
|
|||
cd backend && ../.venv/bin/python -m pytest -q # 494 passed, 1 skipped(约 3 分钟)
|
||||
bash -n scripts/*.sh # 改过脚本就必须过,shell 没有编译器兜底
|
||||
# 改过 .gitignore:跑 ./scripts/deploy.sh --check,第 3 条不变量会验它没吃掉代码
|
||||
cd frontend && npm run build # 前端类型与打包
|
||||
cd frontend && npm run build # 前端类型与打包(= tsc --noEmit + vite build)
|
||||
.venv/bin/python scripts/ui/vocab.py # 前端词汇表 lint(只读源码,不用起服务)
|
||||
# 改过控件 / 表单 / 主题:再跑 UI 体检(前端 :5173 与后端 :8000 必须在跑)
|
||||
.venv/bin/python -u scripts/ui/audit.py --width 1440 1280 900 --theme both --only page
|
||||
.venv/bin/python -u scripts/ui/audit.py --width 1440 900 --theme both --only overlay
|
||||
./scripts/dev.sh restart && ./scripts/dev.sh status # 本机起服务 + 看默认模型/ComfyUI
|
||||
NEX_BASE=http://127.0.0.1:8000 .venv/bin/python scripts/e2e_selfcheck.py # 全流程
|
||||
```
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -10,26 +10,22 @@
|
|||
"preview": "vite preview --host 0.0.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-checkbox": "^1.4.1",
|
||||
"@radix-ui/react-dialog": "^1.3.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.2.1",
|
||||
"@radix-ui/react-popover": "^1.3.1",
|
||||
"@radix-ui/react-slider": "^1.6.1",
|
||||
"@ant-design/icons": "^6.3.4",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@vitejs/plugin-react": "^5.2.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"antd": "^5.29.3",
|
||||
"clsx": "^2.1.1",
|
||||
"react": "^19.3.1",
|
||||
"react-dom": "^19.3.1",
|
||||
"react-router-dom": "^7.18.5",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router-dom": "^6.30.6",
|
||||
"tailwind-merge": "^3.7.0",
|
||||
"tailwindcss": "^4.3.3",
|
||||
"vite": "latest",
|
||||
"zustand": "^5.0.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
"@types/react": "^18.3.31",
|
||||
"@types/react-dom": "^18.3.7",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,12 @@
|
|||
* 低于抽屉(100)、灯箱(220)、下拉弹层(400),不打断真正的模态。
|
||||
*/
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { ToolButton } from '../../components/ui'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { toggleTheme, useAppliedTheme } from '../../stores/theme'
|
||||
import PipelineConsole from './PipelineConsole'
|
||||
import UserMenu from './UserMenu'
|
||||
|
||||
/** 顶栏控件(手册 / 主题 / 胶囊)统一高度取 --nex-ctl,即规范主尺寸 */
|
||||
const TOOL = 'group flex h-(--nex-ctl) flex-none items-center gap-1.5 rounded-[8px] border border-line bg-transparent px-[9px] text-body font-semibold text-ink-3 whitespace-nowrap no-underline hover:border-line-bright hover:bg-hover hover:text-ink max-nav:justify-center max-nav:w-(--nex-ctl) max-nav:px-0 max-nav:[&>span]:hidden'
|
||||
|
||||
export function AppBar({ projectId }: { projectId: string }) {
|
||||
const isLight = useAppliedTheme() === 'light'
|
||||
|
||||
|
|
@ -29,24 +27,26 @@ export function AppBar({ projectId }: { projectId: string }) {
|
|||
<header className="sticky top-0 z-66 flex min-h-(--nex-bar) w-full flex-none basis-full flex-nowrap items-center gap-2.5 border-b border-emphasis bg-shell px-4 py-[7px]">
|
||||
<NavLink to="/" title="长视频编导平台 · 返回项目总览"
|
||||
className="flex flex-[1_1_0] min-w-max items-center justify-start gap-[9px] text-body tracking-[.6px] text-ink no-underline">
|
||||
<b aria-hidden="true" className="grid h-[31px] w-[31px] place-items-center rounded-tile bg-accent-fill text-[17px] text-on-accent">N</b>
|
||||
<b aria-hidden="true" className="grid h-[31px] w-[31px] place-items-center rounded-tile bg-accent-fill text-h2 text-on-accent">N</b>
|
||||
<span className="max-nav:hidden">长视频编导平台</span>
|
||||
</NavLink>
|
||||
|
||||
{projectId && <PipelineConsole projectId={projectId} />}
|
||||
|
||||
<div className="flex flex-[1_1_0] items-center justify-end gap-[7px]">
|
||||
<a className={cn(TOOL)} href="/help" target="_blank" rel="noopener" title="使用手册 · 全流程操作截图(新窗口打开)">
|
||||
{/* 皮肤在 ui/Button.tsx 的 ToolButton 里:顶栏这几颗以前是本文件的一条私有常量,
|
||||
登录页想要同一颗按钮时只能再抄一遍类名 */}
|
||||
<ToolButton href="/help" target="_blank" title="使用手册 · 全流程操作截图(新窗口打开)">
|
||||
<i aria-hidden="true" className="text-ui not-italic text-muted group-hover:text-accent">🛈</i><span>手册</span>
|
||||
</a>
|
||||
<button type="button" className={cn(TOOL, 'cursor-pointer')} onClick={toggleTheme}
|
||||
</ToolButton>
|
||||
<ToolButton onClick={toggleTheme}
|
||||
aria-label={'切换明暗主题,当前为' + (isLight ? '浅色' : '深色')}
|
||||
title={'显示模式:' + (isLight ? '浅色' : '深色') + '(⌘/Ctrl+Shift+L 切换)'}>
|
||||
<i aria-hidden="true"
|
||||
className={cn('grid h-[17px] w-[17px] place-items-center rounded-[6px] bg-accent-fill text-tiny text-on-accent transition-transform duration-[180ms]',
|
||||
className={cn('grid h-[17px] w-[17px] place-items-center rounded-control bg-accent-fill text-tiny text-on-accent transition-transform duration-[180ms]',
|
||||
isLight && 'rotate-[-18deg]')}>{isLight ? '☀' : '☾'}</i>
|
||||
<span>{isLight ? '浅色' : '深色'}</span>
|
||||
</button>
|
||||
</ToolButton>
|
||||
<UserMenu />
|
||||
</div>
|
||||
</header>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
* 旧版的 notify() 把文字写进项目共享状态,只有项目详情页顶部会显示,
|
||||
* 资产库 / 模型中心里点完按钮悄无声息。现在挂在 App 外壳上,
|
||||
* 右下堆叠、6 秒自动消失,任何模块调 notify() 都看得见。
|
||||
* 皮肤复用 ui/Panel 的 <Notice>:同一句提示在页面里和浮在角落时必须是同一个东西。
|
||||
*/
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Notice } from '../../components/ui'
|
||||
import { useNoticeStore } from '../../stores/notice'
|
||||
|
||||
export function NoticeToast() {
|
||||
|
|
@ -14,16 +15,13 @@ export function NoticeToast() {
|
|||
if (!items.length) return null
|
||||
return (
|
||||
<div className="pointer-events-none fixed bottom-4 right-4 z-240 flex w-[min(420px,calc(100vw-32px))] flex-col gap-2">
|
||||
{/* 提示条的皮肤与页面内联 <Notice> 是同一只组件:底色、描边、✕ 都不再各写一份,
|
||||
这里只加「浮在右下角、可点、进场淡入」这三条属于浮层的规则 */}
|
||||
{items.map((n) => (
|
||||
<div key={n.id}
|
||||
className={cn('pointer-events-auto flex items-start gap-2 rounded-[8px] border px-3 py-[11px] text-body shadow-pop animate-fade-in',
|
||||
n.tone === 'bad'
|
||||
? 'border-danger-line bg-danger-tint text-danger-bright'
|
||||
: 'border-accent-line bg-accent-tint-2 text-accent-bright')}>
|
||||
<span className="min-w-0 grow [overflow-wrap:anywhere]">{n.text}</span>
|
||||
<button type="button" onClick={() => dismiss(n.id)} title="关闭提示"
|
||||
className="shrink-0 border-0 bg-transparent p-0 text-caption text-inherit opacity-60 hover:opacity-100">✕</button>
|
||||
</div>
|
||||
<Notice key={n.id} danger={n.tone === 'bad'} onClose={() => dismiss(n.id)}
|
||||
className="pointer-events-auto mb-0 text-body shadow-pop animate-fade-in">
|
||||
{n.text}
|
||||
</Notice>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ const PIPE_TINT: Record<string, string> = {
|
|||
}
|
||||
const NODE_STATE: Record<string, string> = {
|
||||
done: 'bg-success opacity-100',
|
||||
active: 'bg-accent opacity-100 h-[13px] rounded-[3px] animate-pulse-soft',
|
||||
failed: 'bg-danger opacity-100 h-[13px] rounded-[3px] animate-pulse-soft',
|
||||
active: 'bg-accent opacity-100 h-[13px] rounded-chip animate-pulse-soft',
|
||||
failed: 'bg-danger opacity-100 h-[13px] rounded-chip animate-pulse-soft',
|
||||
pending: 'bg-faint opacity-34'
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ export function PipelineConsole({ projectId }: { projectId: string }) {
|
|||
<span className="absolute inset-y-0 left-0 w-[3px] bg-[var(--pipe)]" aria-hidden="true"></span>
|
||||
|
||||
<span className="flex h-[17px] min-w-0 items-center gap-[7px]">
|
||||
<b className="min-w-0 truncate text-[12.5px] font-bold leading-[17px] tracking-[.2px]">{projectTitle}</b>
|
||||
<b className="min-w-0 truncate text-body font-bold leading-[17px] tracking-[.2px]">{projectTitle}</b>
|
||||
{proj?.status && (
|
||||
<em className={cn('flex-none rounded-pill border px-[7px] text-tiny font-bold not-italic',
|
||||
muted ? 'border-line bg-hover text-ink-2' : 'border-[var(--pipe-line)] bg-[var(--pipe-tint)] text-[var(--pipe)] max-tiny:hidden')}>
|
||||
|
|
@ -122,14 +122,14 @@ export function PipelineConsole({ projectId }: { projectId: string }) {
|
|||
<span className="flex h-2 w-[210px] flex-none items-center gap-[3px] max-mid:w-[176px] max-nav:w-[150px] max-tiny:w-[110px] max-tiny:gap-0.5 max-narrow:w-[78px]" aria-hidden="true">
|
||||
{pipeRail.map((n) => (
|
||||
<i key={n.key} title={n.label ? n.label + ':' + (n.detail || PIPE_STATE[n.state] || n.state) : undefined}
|
||||
className={cn('h-2 min-w-[3px] flex-1 basis-0 rounded-[2px]', NODE_STATE[n.state] || NODE_STATE.pending,
|
||||
className={cn('h-2 min-w-[3px] flex-1 basis-0 rounded-chip', NODE_STATE[n.state] || NODE_STATE.pending,
|
||||
n.groupEnd && 'mr-[7px] last:mr-0 max-tiny:mr-[3px]')} />
|
||||
))}
|
||||
</span>
|
||||
<small className="flex-none text-tiny text-muted max-tiny:hidden">流程进度</small>
|
||||
<b className={cn('flex-none text-ui font-extrabold leading-4 tracking-[.3px]', muted && 'text-ink-2')} style={{ color: muted ? undefined : color }}>{pipePct}</b>
|
||||
{pipeCurrent && (
|
||||
<small className={cn('min-w-0 flex-[0_1_auto] truncate text-right leading-4 text-[10.5px] text-faint max-mid:hidden', allDone && 'text-[var(--pipe)]')}>
|
||||
<small className={cn('min-w-0 flex-[0_1_auto] truncate text-right leading-4 text-tiny text-faint max-mid:hidden', allDone && 'text-[var(--pipe)]')}>
|
||||
{pipeCurText}
|
||||
</small>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ import { modules } from './nav'
|
|||
import { useCurrentStageNote } from './PipelineConsole'
|
||||
|
||||
const NAV_ITEM = cn(
|
||||
'flex items-center gap-2.5 rounded-[8px] px-[9px] py-[10px] text-body font-medium text-ink-3 no-underline',
|
||||
'flex items-center gap-2.5 rounded-tile px-[9px] py-[10px] text-body font-medium text-ink-3 no-underline',
|
||||
'hover:bg-hover hover:text-ink max-nav:justify-center max-nav:gap-0 max-nav:min-h-[38px] max-nav:px-[2px] max-nav:py-[9px] max-nav:text-center'
|
||||
)
|
||||
const NAV_ICON = 'w-[18px] flex-none text-center text-ui text-muted max-nav:w-auto max-nav:text-[16px]'
|
||||
const NAV_ICON = 'w-[18px] flex-none text-center text-ui text-muted max-nav:w-auto max-nav:text-md'
|
||||
const NAV_LABEL = 'max-nav:hidden'
|
||||
|
||||
function NavItem({ to, icon, label, hint, chosen }: {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,25 @@
|
|||
/**
|
||||
* 顶栏账号胶囊:头像 + 角色 + 二级菜单(我的账号 / 用户管理 / 退出登录)。
|
||||
* 顶栏账号胶囊:头像 + 角色 + 下拉面板(我的账号 / 用户管理 / 退出登录)。
|
||||
*
|
||||
* 环境自检不再常驻一列文字,只在真的有问题时到菜单里冒出来一次。
|
||||
* 换页后菜单里的高亮项、角色都可能变,直接收起最省事。
|
||||
* 症状:菜单原来是 primitives/Menu(Radix)+ 自己拼的面板,页面里另一批菜单又是
|
||||
* div + useOutsideClick——同一种「点开一个浮层」有两套行为,Tab 会跑到菜单背后。
|
||||
* 做法:浮层交给 `ui/Menu`(antd Dropdown,焦点圈定、Esc、外点关闭、portal 到 body 都由它负责),
|
||||
* 面板里的行交给同一层的 MenuRow / MenuNote / MenuDivider(头像块、角色徽标是业务信息,
|
||||
* 但「一行菜单项长什么样」不是),触发胶囊交给 ui/Tile。
|
||||
* 皮肤来自 theme/antd.ts 的 Dropdown token,这里只写布局类。
|
||||
*
|
||||
* 菜单行为在 primitives/Menu(Radix DropdownMenu):焦点圈定、方向键/首字母走选项、
|
||||
* Esc 关闭并把焦点还给胶囊、点外面关闭——以前是 div + useOutsideClick 手写的,
|
||||
* 那份实现 Tab 会跑到菜单背后,且每个使用点都得自己记得挂 hook。
|
||||
* 面板还 portal 到 body,不再被顶栏的层叠上下文和 z-index 排挤。
|
||||
* 环境自检不常驻一列文字,只在真有问题时到面板里冒出来一次;换页后直接收起最省事。
|
||||
*/
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link, NavLink, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { Menu, MenuDivider, MenuNote, MenuRow, Tile } from '../../components/ui'
|
||||
import { cn } from '../../lib/cn'
|
||||
import {
|
||||
logout, roleLabel, useAuthStore, useCanEdit, useDisplayName, useIsAdmin
|
||||
} from '../../stores/auth'
|
||||
import { useSystemStore } from '../../stores/system'
|
||||
import { MENU_ICON, MenuItem, MenuNote, MenuRoot, MenuSeparator, MenuTrigger, MenuContent } from '../../components/primitives/Menu'
|
||||
|
||||
/** 环境自检结论:有问题才说,没问题时菜单里不占位置 */
|
||||
/** 环境自检结论:有问题才说,没问题时面板里不占位置 */
|
||||
function envIssueOf(health: any): string {
|
||||
if (!health) return ''
|
||||
if (health.executor === 'celery' && !health.daemon?.running) return '调度守护未运行:新任务会一直排在队列里'
|
||||
|
|
@ -38,7 +39,7 @@ export function UserMenu() {
|
|||
const [open, setOpen] = useState(false)
|
||||
const close = useCallback(() => setOpen(false), [])
|
||||
|
||||
/* 换页后菜单里的高亮项、角色都可能变,直接收起最省事 */
|
||||
/* 换页后面板里的高亮项、角色都可能变,直接收起最省事 */
|
||||
useEffect(close, [location.pathname, close])
|
||||
|
||||
if (!user) return null
|
||||
|
|
@ -52,77 +53,62 @@ export function UserMenu() {
|
|||
await navigate({ pathname: '/login', search: '?loggedOut=1' }, { replace: true })
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuRoot open={open} onOpenChange={setOpen}>
|
||||
<MenuTrigger asChild title={'账号菜单 · ' + displayName}>
|
||||
<button type="button"
|
||||
className={cn('relative flex h-(--nex-ctl) items-center gap-2 rounded-pill border bg-sunken pl-1 pr-2 text-left text-ink-2 hover:border-line-bright hover:bg-hover hover:text-ink',
|
||||
mustChangePassword ? 'border-warn-line' : 'border-line', open && 'border-line-bright bg-hover text-ink')}>
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid max-w-[132px] min-w-0 leading-[1.25] max-narrow:hidden [&_b]:truncate [&_small]:truncate">
|
||||
<b className="text-label">{displayName}</b>
|
||||
<small className="text-tiny text-faint">{roleLabel(user.role)}{user.login_count ? ` · 第 ${user.login_count} 次登录` : ''}</small>
|
||||
</span>
|
||||
<span aria-hidden="true" className="flex-none text-caption text-faint transition-transform duration-[180ms]" style={{ transform: open ? 'rotate(180deg)' : undefined }}>⌄</span>
|
||||
{/* 待改密码的提醒不能只藏在菜单里:胶囊上先挂一个角标。
|
||||
角标挂在胶囊而不是头像上——头像是 27px 的正圆,绝对定位的角标会把
|
||||
它自己的 scrollWidth 撑到 30px(内容没被裁,但等于凭空多出横向溢出)。 */}
|
||||
{mustChangePassword && (
|
||||
<span aria-hidden="true" className="absolute -right-0.5 -top-[3px] grid h-[14px] w-[14px] place-items-center rounded-pill bg-warn-fill text-tiny font-bold text-warn-ink">!</span>
|
||||
)}
|
||||
</button>
|
||||
</MenuTrigger>
|
||||
|
||||
<MenuContent label="账号菜单" className="w-[262px] p-[9px]">
|
||||
<div className="flex items-center gap-[9px] border-b border-line-soft px-1 pb-[9px] pt-[3px]">
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid min-w-0 gap-0.5">
|
||||
<b className="truncate text-[12.5px]">{displayName}</b>
|
||||
<small className="truncate text-tiny text-faint">{user.username}{user.email ? ` · ${user.email}` : ''}</small>
|
||||
</span>
|
||||
<em className="ml-auto flex-none rounded-pill bg-hover px-[6px] py-0.5 text-tiny not-italic text-ink-2">{roleLabel(user.role)}</em>
|
||||
</div>
|
||||
const panel = (
|
||||
<div className="w-[262px]">
|
||||
<div className="flex items-center gap-[9px] border-b border-line-soft px-1 pb-[9px] pt-[3px]">
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid min-w-0 gap-0.5">
|
||||
<b className="truncate text-body">{displayName}</b>
|
||||
<small className="truncate text-tiny text-faint">{user.username}{user.email ? ` · ${user.email}` : ''}</small>
|
||||
</span>
|
||||
<em className="ml-auto flex-none rounded-pill bg-hover px-[6px] py-0.5 text-tiny not-italic text-ink-2">{roleLabel(user.role)}</em>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-[3px] pt-[7px]">
|
||||
{mustChangePassword && (
|
||||
<MenuItem className="block" asChild>
|
||||
<Link to="/account?must=1" onClick={close} className="text-inherit">
|
||||
<span className="w-full rounded-[6px] bg-warn-tint px-[7px] py-[5px] text-left text-tiny leading-[1.5] text-warn-bright [overflow-wrap:anywhere]">
|
||||
初始密码尚未修改,点此设置新密码 →
|
||||
</span>
|
||||
</Link>
|
||||
</MenuItem>
|
||||
<MenuNote to="/account?must=1" onClick={close} className="mb-[3px] rounded-control bg-warn-tint py-[5px]">
|
||||
初始密码尚未修改,点此设置新密码 →
|
||||
</MenuNote>
|
||||
)}
|
||||
{!canEdit && <MenuNote className="my-[6px]">观摩角色:只读,写操作会被后端拒绝</MenuNote>}
|
||||
{!canEdit && <MenuNote>观摩角色:只读,写操作会被后端拒绝</MenuNote>}
|
||||
|
||||
<MenuSeparator />
|
||||
|
||||
<MenuItem asChild onSelect={close}>
|
||||
<NavLink to="/account" title="账号信息、修改密码与登录设备">
|
||||
<i className={MENU_ICON}>◍</i><span>我的账号</span>
|
||||
</NavLink>
|
||||
</MenuItem>
|
||||
{isAdmin && (
|
||||
<MenuItem asChild onSelect={close}>
|
||||
<NavLink to="/users" title="账号、角色与配额">
|
||||
<i className={MENU_ICON}>▤</i><span>用户管理</span>
|
||||
</NavLink>
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuRow to="/account" icon="◍" title="账号信息、修改密码与登录设备" onClick={close}>我的账号</MenuRow>
|
||||
{isAdmin && <MenuRow to="/users" icon="▤" title="账号、角色与配额" onClick={close}>用户管理</MenuRow>}
|
||||
|
||||
{envIssue && (
|
||||
<>
|
||||
<MenuSeparator />
|
||||
<MenuNote tone="warn" className="my-[6px]">{envIssue}</MenuNote>
|
||||
<MenuDivider />
|
||||
<MenuNote>{envIssue}</MenuNote>
|
||||
</>
|
||||
)}
|
||||
|
||||
<MenuSeparator />
|
||||
<MenuDivider />
|
||||
<MenuRow icon="⏻" danger title="退出当前会话" onClick={signOut}>退出登录</MenuRow>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
<MenuItem danger onSelect={signOut} title="退出当前会话">
|
||||
<i className={cn(MENU_ICON, 'text-danger')}>⏻</i><span>退出登录</span>
|
||||
</MenuItem>
|
||||
</MenuContent>
|
||||
</MenuRoot>
|
||||
return (
|
||||
<Menu open={open} onOpenChange={setOpen} trigger={['click']} placement="bottomRight"
|
||||
popupRender={() => panel} overlayClassName="nex-user-menu">
|
||||
{/* 开合动作由 antd Dropdown 注入到这颗触发器上,Tile 只负责形状与命中态 */}
|
||||
<Tile variant="pill" as="button" active={open} popup
|
||||
className={cn('relative', mustChangePassword && !open && 'border-warn-line')}
|
||||
title={'账号菜单 · ' + displayName}>
|
||||
<span aria-hidden="true" className="grid h-[27px] w-[27px] flex-none place-items-center rounded-pill bg-accent-fill text-body font-bold text-on-accent">{initial}</span>
|
||||
<span className="grid max-w-[132px] min-w-0 leading-[1.25] max-narrow:hidden [&_b]:truncate [&_small]:truncate">
|
||||
<b className="text-label">{displayName}</b>
|
||||
<small className="text-tiny text-faint">{roleLabel(user.role)}{user.login_count ? ` · 第 ${user.login_count} 次登录` : ''}</small>
|
||||
</span>
|
||||
<span aria-hidden="true" className="flex-none text-caption text-faint transition-transform duration-[180ms]" style={{ transform: open ? 'rotate(180deg)' : undefined }}>⌄</span>
|
||||
{/* 待改密码的提醒不能只藏在面板里:胶囊上先挂一个角标。
|
||||
角标挂在胶囊而不是头像上——头像是 27px 的正圆,绝对定位的角标会把
|
||||
它自己的 scrollWidth 撑到 30px(内容没被裁,但等于凭空多出横向溢出)。 */}
|
||||
{mustChangePassword && (
|
||||
<span aria-hidden="true" className="absolute -right-0.5 -top-[3px] grid h-[14px] w-[14px] place-items-center rounded-pill bg-warn-fill text-tiny font-bold text-warn-ink">!</span>
|
||||
)}
|
||||
</Tile>
|
||||
</Menu>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* 全局 Provider:Ant Design 5 的主题与命令式 API 的唯一入口。
|
||||
*
|
||||
* 三件事都在这里,别在页面里重复:
|
||||
* 1) ConfigProvider —— 读 theme store 的 applied(dark/light)切换 antd 算法,
|
||||
* 皮肤全部来自 src/theme/antd.ts,页面里不许出现第二个 ThemeConfig;
|
||||
* 2) <App> —— 提供 message / notification / modal 的 context 实例,
|
||||
* 这样它们也吃同一套主题(直接 import 的静态方法在 antd v5 里会丢主题);
|
||||
* 3) 把 context 实例挂到模块级,让 stores/notice.ts 这类非组件代码也能弹提示。
|
||||
*
|
||||
* cssVar 打开后 antd 会把 token 落成 --ant-* 变量,自绘区域(时间线、素材墙、灯箱)
|
||||
* 与 styles/app.css 直接读这些变量,和控件共用一把尺子。
|
||||
*/
|
||||
import { useEffect, type ReactNode } from 'react'
|
||||
import { App as AntdApp, ConfigProvider } from 'antd'
|
||||
import zhCN from 'antd/locale/zh_CN'
|
||||
import dayjs from 'dayjs'
|
||||
import 'dayjs/locale/zh-cn'
|
||||
import { buildAntdTheme } from '../theme/antd'
|
||||
import { useNarrow } from '../hooks/use-narrow'
|
||||
import { useThemeStore, type ThemeMode } from '../stores/theme'
|
||||
|
||||
dayjs.locale('zh-cn')
|
||||
|
||||
/** <App> 提供的命令式实例;组件外用 notify() / confirmAction() 走这两个对象 */
|
||||
let messageApi: any = null
|
||||
let notificationApi: any = null
|
||||
let modalApi: any = null
|
||||
|
||||
export const antdApi = {
|
||||
get message() { return messageApi },
|
||||
get notification() { return notificationApi },
|
||||
get modal() { return modalApi }
|
||||
}
|
||||
|
||||
function BindAntdApi() {
|
||||
const app = AntdApp.useApp()
|
||||
useEffect(() => {
|
||||
messageApi = app.message
|
||||
notificationApi = app.notification
|
||||
modalApi = app.modal
|
||||
}, [app])
|
||||
return null
|
||||
}
|
||||
|
||||
export function ThemeProviders({ children }: { children: ReactNode }) {
|
||||
const applied = useThemeStore((s) => s.applied) as ThemeMode
|
||||
/* 触摸档(≤560px)要连 antd 一起抬:自绘区域靠 css-vars 的 media query 自己切,
|
||||
antd 只认这里的 ThemeConfig 数字,不判就会一屏混着 31/38 和 36/40 两把尺子。 */
|
||||
const narrow = useNarrow()
|
||||
return (
|
||||
<ConfigProvider
|
||||
locale={zhCN}
|
||||
theme={buildAntdTheme(applied, { narrow })}
|
||||
/* antd 默认在按钮里两个中文字之间插一个空格(保 存)。我们的控件文字是 12px,
|
||||
这颗空格让按钮比同行 chip / tag 松一档,全站统一按原文渲染。 */
|
||||
/* 按钮里两个中文字之间不插空格(保 存):控件文字 12px 时那颗空格会让按钮
|
||||
比同行 chip / tag 松一档。写在 button 配置里——ConfigProvider 顶层那个
|
||||
同名 prop 在 antd 5.29 已废弃,会打 console error。 */
|
||||
button={{ autoInsertSpace: false }}
|
||||
/* 浮层默认挂到 body:抽屉/弹窗里的下拉需要它才能盖过容器溢出裁剪 */
|
||||
getPopupContainer={(node) => (node?.closest('.ant-drawer-body, .ant-modal-body') as HTMLElement) || document.body}
|
||||
>
|
||||
<AntdApp>
|
||||
<BindAntdApi />
|
||||
{children}
|
||||
</AntdApp>
|
||||
</ConfigProvider>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import { CARET_PATH, caretCls } from '../primitives'
|
||||
|
||||
/** 统一的下拉箭头(Select / MultiSelect 共用一份几何) */
|
||||
export function Caret({ open, className }: { open: boolean; className?: string }) {
|
||||
return (
|
||||
<svg className={caretCls(open) + (className ? ' ' + className : '')} viewBox="0 0 20 20" aria-hidden="true">
|
||||
<path d={CARET_PATH} fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,17 +1,14 @@
|
|||
import { useEffect, useId, useMemo, useRef, useState } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import {
|
||||
Popup, barLayer, chipButtonLayer, countBadgeLayer, emptyLayer, itemCls, listLayer,
|
||||
panelInputLayer, tickBoxLayer, triggerCls, useListbox
|
||||
} from '../primitives'
|
||||
import { sameValue, summaryOf, toOptions, type OptionLike } from './options'
|
||||
import { Caret } from './Caret'
|
||||
import { useMemo } from 'react'
|
||||
import { Select as AntSelect } from 'antd'
|
||||
import { sameValue, toOptions, type OptionLike } from './options'
|
||||
|
||||
/**
|
||||
* 全站统一「多选下拉」(替代原生 <select multiple> 的系统列表外观)。
|
||||
* 与 Select 共用 primitives:同一个 Popup、同一份键盘实现、同一套皮肤,
|
||||
* 差别只在「选了不关闭」和行首那个勾选框。
|
||||
* 回显超过 30 字退化成「首项 等 N 项」,否则触发器会被撑出整行。
|
||||
* 全站统一「多选下拉」:antd Select 的 multiple 模式。
|
||||
*
|
||||
* 症状:自绘版把已选项压成「首项 等 N 项」塞进触发器,看不见已经选了哪些,
|
||||
* 也删不掉;面板里的勾选框和行高与旁边的 antd 控件不同尺。
|
||||
* 做法:maxTagCount 让标签超出宽度时收成「+N」,展开后每个已选项都能就地叉掉;
|
||||
* 值仍然按 sameValue 反查,接口回来是 number 也不会丢选中态。
|
||||
*/
|
||||
export type MultiSelectProps = {
|
||||
value: any[] | null | undefined
|
||||
|
|
@ -23,149 +20,36 @@ export type MultiSelectProps = {
|
|||
size?: 'sm' | 'md'
|
||||
ariaLabel?: string
|
||||
className?: string
|
||||
/** 一个都不选等于「不限制」的下拉(筛选场景),保留「全部」语义提示 */
|
||||
title?: string
|
||||
}
|
||||
|
||||
export function MultiSelect({
|
||||
value, onChange, options, disabled, placeholder = '未选择', searchThreshold = 7,
|
||||
size = 'md', ariaLabel, className
|
||||
value, onChange, options, disabled, placeholder = '未选择', searchThreshold = 3,
|
||||
size, ariaLabel, className, title
|
||||
}: MultiSelectProps) {
|
||||
const picked = useMemo(() => (Array.isArray(value) ? value : []), [value])
|
||||
const opts = useMemo(() => toOptions(options), [options])
|
||||
const uid = useId()
|
||||
const listId = `${uid}-list`
|
||||
const boxRef = useRef<HTMLSpanElement | null>(null)
|
||||
const triggerRef = useRef<HTMLButtonElement | null>(null)
|
||||
const searchRef = useRef<HTMLInputElement | null>(null)
|
||||
const [open, setOpen] = useState(false)
|
||||
const [query, setQuery] = useState('')
|
||||
|
||||
const isSelected = (v: any) => picked.some((p) => sameValue(p, v))
|
||||
const labels = opts.filter((o) => isSelected(o.value)).map((o) => o.label)
|
||||
const shown = summaryOf(labels)
|
||||
const count = labels.length
|
||||
|
||||
const view = useMemo(() => {
|
||||
const q = query.trim().toLowerCase()
|
||||
return opts.map((_, i) => i).filter((i) => !q || opts[i].label.toLowerCase().includes(q))
|
||||
}, [opts, query])
|
||||
const selectableInView = view.filter((i) => !opts[i].disabled).length
|
||||
const searchable = searchThreshold > 0 && opts.length > searchThreshold
|
||||
|
||||
const lb = useListbox({
|
||||
view,
|
||||
isDisabled: (i) => !!opts[i]?.disabled,
|
||||
labelOf: (i) => opts[i]?.label ?? '',
|
||||
open,
|
||||
onPick: toggleIndex,
|
||||
onOpen: openList,
|
||||
onClose: closeList,
|
||||
initialActive: () => {
|
||||
const hit = view.findIndex((i) => isSelected(opts[i].value))
|
||||
return hit >= 0 ? hit : (view.find((i) => !opts[i].disabled) ?? -1)
|
||||
}
|
||||
const shown = picked.map((v) => {
|
||||
const hit = opts.find((o) => sameValue(o.value, v))
|
||||
return hit ? hit.value : v
|
||||
})
|
||||
|
||||
// 只盯 query:opts/view 每次渲染都是新引用,列进依赖会把高亮反复重置回第一行
|
||||
useEffect(() => {
|
||||
if (query) lb.setActive(view.find((i) => !opts[i]?.disabled) ?? -1)
|
||||
}, [query])
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
;(searchable ? searchRef : triggerRef).current?.focus({ preventScroll: true })
|
||||
}, [open, searchable])
|
||||
|
||||
function openList() {
|
||||
if (disabled) return
|
||||
setQuery('')
|
||||
setOpen(true)
|
||||
lb.prime()
|
||||
}
|
||||
|
||||
/** refocus=false:外点到页面上的别的控件时,别把焦点抢回来,否则点不动下一个字段 */
|
||||
function closeList(refocus = true) {
|
||||
setQuery('')
|
||||
setOpen(false)
|
||||
if (refocus) triggerRef.current?.focus({ preventScroll: true })
|
||||
}
|
||||
|
||||
function commit(next: any[]) {
|
||||
onChange(next)
|
||||
// 勾完一项后行高可能变化(长标签换行),等这一轮 DOM 落地再校准可见区
|
||||
if (open) queueMicrotask(() => lb.scrollActive())
|
||||
}
|
||||
|
||||
function toggleIndex(i: number) {
|
||||
const o = opts[i]
|
||||
if (!o || o.disabled) return
|
||||
commit(isSelected(o.value) ? picked.filter((p) => !sameValue(p, o.value)) : [...picked, o.value])
|
||||
}
|
||||
|
||||
function setInView(selected: boolean) {
|
||||
const inView = view.map((i) => opts[i].value)
|
||||
if (selected) {
|
||||
const next = [...picked]
|
||||
for (const v of inView) if (!picked.some((p) => sameValue(p, v))) next.push(v)
|
||||
commit(next)
|
||||
} else {
|
||||
commit(picked.filter((p) => !inView.some((v) => sameValue(v, p))))
|
||||
}
|
||||
}
|
||||
|
||||
const optId = (i: number) => `${uid}-o${i}`
|
||||
|
||||
return (
|
||||
<Popup open={open} onOpenChange={(next) => (next ? openList() : closeList(false))}
|
||||
anchorRef={boxRef} label={ariaLabel || undefined} onKeyDown={lb.onKeyDown}
|
||||
anchor={
|
||||
<span ref={boxRef} className={cn('relative inline-flex w-full min-w-0 align-middle', open && 'z-[401]', className)}>
|
||||
<button ref={triggerRef} type="button" role="combobox" disabled={disabled}
|
||||
aria-label={ariaLabel || undefined}
|
||||
aria-haspopup="listbox" aria-expanded={open}
|
||||
aria-controls={open ? listId : undefined}
|
||||
aria-activedescendant={open && lb.active >= 0 ? optId(lb.active) : undefined}
|
||||
className={triggerCls({ size, open })}
|
||||
onClick={() => (open ? closeList() : openList())} onKeyDown={lb.onKeyDown}>
|
||||
{!!count && <span className={countBadgeLayer}>{count}</span>}
|
||||
<span className={cn('flex-1 min-w-0 truncate whitespace-nowrap', !shown && 'text-faint')}>{shown || placeholder}</span>
|
||||
<Caret open={open} />
|
||||
</button>
|
||||
</span>
|
||||
}>
|
||||
<div className={barLayer}>
|
||||
{searchable && (
|
||||
<input ref={searchRef} type="search" value={query} placeholder="过滤选项…"
|
||||
aria-label={`${ariaLabel || '选项'}:过滤`}
|
||||
className={panelInputLayer}
|
||||
onChange={(e) => setQuery(e.target.value)} onKeyDown={lb.onInputKeyDown} />
|
||||
)}
|
||||
<span className="flex-none text-tiny text-faint">{count ? `已选 ${count} 项` : '未选择'}</span>
|
||||
<button type="button" className={chipButtonLayer}
|
||||
disabled={!selectableInView} onClick={() => setInView(true)}>全选</button>
|
||||
<button type="button" className={chipButtonLayer}
|
||||
disabled={!count} onClick={() => setInView(false)}>清空</button>
|
||||
</div>
|
||||
<div ref={lb.listRef} id={listId} role="listbox" aria-multiselectable aria-label={ariaLabel || undefined} className={listLayer}>
|
||||
{view.map((i) => {
|
||||
const o = opts[i]
|
||||
const on = isSelected(o.value)
|
||||
return (
|
||||
<div key={`${o.value}-${i}`} id={optId(i)} role="option" aria-selected={on}
|
||||
data-active={i === lb.active ? '1' : undefined}
|
||||
data-on={on ? '1' : undefined}
|
||||
data-off={o.disabled ? '1' : undefined}
|
||||
className={itemCls({ mode: 'multi' })}
|
||||
onMouseEnter={() => { if (!o.disabled) lb.setActive(i) }}
|
||||
onClick={() => toggleIndex(i)}>
|
||||
<span className={cn(tickBoxLayer, on ? 'bg-accent-fill border-accent-fill' : 'border-line-bright')} aria-hidden>
|
||||
{on && <svg viewBox="0 0 12 12" className="w-[11px] h-[11px]"><path d="M2.6 6.3 4.9 8.6 9.4 3.7" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" /></svg>}
|
||||
</span>
|
||||
<span className="min-w-0 break-anywhere">{o.label}</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{!view.length && <div className={emptyLayer}>{opts.length ? '没有匹配的选项' : '无可选项'}</div>}
|
||||
</div>
|
||||
</Popup>
|
||||
<AntSelect
|
||||
mode="multiple"
|
||||
title={title}
|
||||
aria-label={ariaLabel}
|
||||
className={className}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
size={size === 'sm' ? 'small' : size === 'md' ? 'middle' : undefined}
|
||||
value={shown}
|
||||
options={opts}
|
||||
popupMatchSelectWidth
|
||||
maxTagCount="responsive"
|
||||
showSearch={searchThreshold > 0 && opts.length > searchThreshold}
|
||||
optionFilterProp="label"
|
||||
onChange={(next: any[]) => onChange(next || [])}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import { useEffect, useState, type InputHTMLAttributes, type Ref } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { forwardRef, useEffect, useState, type InputHTMLAttributes } from 'react'
|
||||
import { Input } from 'antd'
|
||||
import * as api from '../../api/client'
|
||||
import { EyeIcon } from './EyeIcon'
|
||||
import { domInput, passRef } from '../../lib/ref'
|
||||
|
||||
/**
|
||||
* 全站统一的「密码 / 密钥」输入框。
|
||||
* 全站统一的「密码 / 密钥」输入框:Ant Design 5 Input.Password。
|
||||
*
|
||||
* 之前四套写法各不相同:登录页和模型管理是「显示 / 隐藏」文字按钮(看不出是开关)、
|
||||
* 我的账号三个密码框压根没有开关(只能盲打)、用户管理直接 type="text" 常显。
|
||||
* 规则统一:右侧眼睛图标切换密文/明文;按下图标不抢输入框焦点(onMouseDown.preventDefault),
|
||||
* 光标位置和已选文本都不丢。
|
||||
* 规则统一:眼睛图标由 antd 提供(与旁边表单控件同一档高度、同一套描边),
|
||||
* 按下图标不抢输入框焦点,光标位置和已选文本都不丢。
|
||||
* 传 revealUrl 时,编辑已保存的密钥(后端只回掩码、输入框是空的)点一下图标会向后端取回
|
||||
* 真实明文——解决「点了显示却什么都没有」。取回的明文只在「显示」期间留在输入框里:
|
||||
* 一旦切回隐藏且用户没改动就还原成空,保存时仍按「留空保持原密钥」的契约走。
|
||||
|
|
@ -27,14 +27,25 @@ export type SecretInputProps = {
|
|||
/** 取回明文的接口;不传就只做本地密文/明文切换 */
|
||||
revealUrl?: string
|
||||
className?: string
|
||||
/** React 19:ref 是普通 prop,跟着 rest 落到原生 input 上 */
|
||||
ref?: Ref<HTMLInputElement>
|
||||
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'id' | 'placeholder' | 'disabled' | 'className'>
|
||||
|
||||
export function SecretInput({
|
||||
/**
|
||||
* 注意:这里不能给输入框套一层 <span>。字段栅格的对齐靠 `.nf-ctl > .ant-input-affix-wrapper
|
||||
* { width: 100% }` 命中「直接子元素」,套一层 inline span 后选择器落空,
|
||||
* 密码框只有内容那么宽(实测 151px 而同行其它控件 359px),控件右边界就歪了。
|
||||
* 所以错误提示用 Fragment 平铺成第二个子元素,DOM 里控件始终是 .nf-ctl 的亲儿子。
|
||||
*
|
||||
* ref 契约(R10):页面要的是 <input> 本体,而 `Input.Password` 的 ref 是 antd 的 `InputRef`
|
||||
* (`{ nativeElement, focus(), blur(), select() … }`)。原先直接把 outerRef 转交给它,
|
||||
* 页面 `useRef<HTMLInputElement>` 收到的其实是句柄——`.focus()` 恰好同名所以「看着是好的」,
|
||||
* `.value` / `.setSelectionRange()` 却是 undefined,属于静默失效。现在在 kit 内部折成 DOM 节点。
|
||||
* 顺手记一句为什么 tsc 没拦:下面那个 `{...(rest as any)}` 一展开,
|
||||
* 这个开标签的属性检查(含 ref 类型)被整个吞掉了——读数与实验见报告 26.6。
|
||||
*/
|
||||
export const SecretInput = forwardRef<HTMLInputElement, Omit<SecretInputProps, 'ref'>>(function SecretInput({
|
||||
value = '', onChange, id, placeholder = '••••••••', autocomplete = 'current-password',
|
||||
maxLength = 200, disabled, hasSaved, revealUrl, className, ...rest
|
||||
}: SecretInputProps) {
|
||||
}, outerRef) {
|
||||
const [shown, setShown] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [stored, setStored] = useState('')
|
||||
|
|
@ -47,9 +58,9 @@ export function SecretInput({
|
|||
if (seeded && value !== stored) setSeeded(false)
|
||||
}, [value, stored, seeded])
|
||||
|
||||
async function reveal() {
|
||||
async function toggle(next: boolean) {
|
||||
if (loading) return
|
||||
if (shown) {
|
||||
if (!next) {
|
||||
if (seeded && value === stored) onChange?.('')
|
||||
setSeeded(false)
|
||||
setShown(false)
|
||||
|
|
@ -78,21 +89,23 @@ export function SecretInput({
|
|||
: (revealUrl && hasSaved && !value ? '显示密码:读取已保存的明文' : '显示密码')
|
||||
|
||||
return (
|
||||
<span className={cn('relative block w-full min-w-0', className)}>
|
||||
<input id={id} value={value} type={shown ? 'text' : 'password'} placeholder={placeholder}
|
||||
autoComplete={autocomplete} maxLength={maxLength} disabled={disabled}
|
||||
aria-describedby={failed ? `${id || 'secret'}-hint` : undefined}
|
||||
className="pr-[34px]"
|
||||
onChange={(e) => onChange?.(e.target.value)} {...rest} />
|
||||
<button type="button" aria-label={hint} aria-pressed={shown} title={hint} disabled={disabled}
|
||||
onMouseDown={(e) => e.preventDefault()}
|
||||
onClick={reveal}
|
||||
className={cn('absolute right-[6px] top-1/2 -translate-y-1/2 w-[22px] h-[22px] p-0 grid place-items-center',
|
||||
'border rounded-[6px] bg-raise text-ink-3 border-line hover:text-ink hover:border-line-strong',
|
||||
shown && 'text-accent-bright border-accent-line bg-accent-tint-2')}>
|
||||
<EyeIcon shown={shown} loading={loading} />
|
||||
</button>
|
||||
<>
|
||||
<Input.Password
|
||||
className={className}
|
||||
ref={(h) => passRef(outerRef, domInput(h))}
|
||||
id={id}
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
autoComplete={autocomplete}
|
||||
maxLength={maxLength}
|
||||
disabled={disabled}
|
||||
visibilityToggle={{ visible: shown, onVisibleChange: (next: boolean) => void toggle(next) }}
|
||||
title={hint}
|
||||
aria-describedby={failed ? `${id || 'secret'}-hint` : undefined}
|
||||
onChange={(e) => onChange?.(e.target.value)}
|
||||
{...(rest as any)}
|
||||
/>
|
||||
{failed && <small id={`${id || 'secret'}-hint`} className="block mt-[5px] text-warn-bright text-tiny">{failed}</small>}
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
import { useEffect, useId, useMemo, useRef, useState } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Popup, barLayer, emptyLayer, itemCls, listLayer, panelInputLayer, tickSlotLayer, triggerCls, useListbox } from '../primitives'
|
||||
import { sameValue, summaryOf, toOptions, type OptionLike, type SelectOption } from './options'
|
||||
import { Caret } from './Caret'
|
||||
import { useMemo } from 'react'
|
||||
import { Select as AntSelect } from 'antd'
|
||||
import { sameValue, toOptions, type OptionLike } from './options'
|
||||
|
||||
/**
|
||||
* 全站统一下拉控件(替代原生 <select> 的系统外观)。
|
||||
* 全站统一下拉控件:Ant Design 5 Select 的唯一封装。
|
||||
*
|
||||
* 分工:浮层行为在 primitives/Popup(Radix Popover:portal / 跟随锚点 / 翻边 / 外点关闭 / Esc),
|
||||
* 键盘语义在 primitives/use-listbox,皮肤在 primitives/layers,这里只管「选中谁、怎么选」。
|
||||
* 页面侧 87 处调用的 props 一个都没动。
|
||||
*
|
||||
* 选项超过阈值自动出现过滤框,否则长列表只能靠滚动条盲摸;
|
||||
* 面板宽度取「至少和触发器一样宽」,不再固定 168px 压住右边的字段标题。
|
||||
* 症状(用户截图第二条):下拉是自己拼的按钮 + 绝对定位面板——面板比触发器窄,
|
||||
* 展开后压住右边字段的标题;选项行高、勾选位、hover 底色和旁边 antd 控件不同尺;
|
||||
* 搜索框只在选项超过阈值时出现,出现后键盘焦点还会丢。
|
||||
* 做法:整个控件交给 antd,皮肤来自 theme/antd.ts,页面继续只给 options/value/onChange。
|
||||
* props 一个都没动(87 处调用零改动),只补三件 antd 不会替我们决定的事:
|
||||
* 1) 面板至少和触发器同宽(popupMatchSelectWidth),不再压住右边的标题;
|
||||
* 2) 选项超过 searchThreshold 才开搜索(长列表盲摸滚动条,短列表不必多一次点击);
|
||||
* 3) 值的类型宽容:接口回来说不定是 number,表单里存的是 string,
|
||||
* 用 sameValue 反查真实选项,避免「选中项在下一次渲染后消失」;
|
||||
* 4) 选项值允许 null——业务里「不绑定 / 无台词 / 未指定」的真实值就是 null(接口也收 null),
|
||||
* 而 antd 把 null 当「没有值」:options 里出现 null 会在 dev 打
|
||||
* `Warning: 'value' in Select options should not be 'null'`,
|
||||
* 更要命的是选中之回显成灰色 placeholder「请选择」,用户看不出自己已经选了「不绑定」。
|
||||
* kit 内部折成哨兵交给 antd,出入口各折一次,页面永远只见 null,不看见哨兵。
|
||||
*/
|
||||
export type SelectProps = {
|
||||
value: any
|
||||
|
|
@ -20,9 +26,9 @@ export type SelectProps = {
|
|||
options: OptionLike[] | null | undefined
|
||||
disabled?: boolean
|
||||
placeholder?: string
|
||||
/** 选项超过该数量时自动显示过滤框(与 MultiSelect 一致) */
|
||||
/** 选项超过该数量时自动出现过滤框(与 MultiSelect 一致) */
|
||||
searchThreshold?: number
|
||||
/** sm 用于表格行内/工具条,md 用于表单 */
|
||||
/** sm 用于表格行内/工具条,md 用于表单;不给就跟随容器档位 */
|
||||
size?: 'sm' | 'md'
|
||||
ariaLabel?: string
|
||||
className?: string
|
||||
|
|
@ -30,129 +36,50 @@ export type SelectProps = {
|
|||
name?: string
|
||||
/** 禁用时要解释原因(「不能修改自己的角色」),否则灰掉的下拉只会让人反复点 */
|
||||
title?: string
|
||||
/** 清空按钮:筛选类下拉用它表达「不筛了」,表单必填字段不要给 */
|
||||
allowClear?: boolean
|
||||
}
|
||||
|
||||
/** 「值就是 null 的那一个选项」的内部代号。带 \u0000,业务值不可能撞上。 */
|
||||
const NULL_OPT = '\u0000nex-null'
|
||||
|
||||
export function Select({
|
||||
value, onChange, options, disabled, placeholder = '请选择', searchThreshold = 8,
|
||||
size = 'md', ariaLabel, className, id, name, title
|
||||
size, ariaLabel, className, id, name, title, allowClear
|
||||
}: SelectProps) {
|
||||
const opts = useMemo(() => toOptions(options), [options])
|
||||
const uid = useId()
|
||||
const listId = `${uid}-list`
|
||||
const boxRef = useRef<HTMLSpanElement | null>(null)
|
||||
const triggerRef = useRef<HTMLButtonElement | null>(null)
|
||||
const searchRef = useRef<HTMLInputElement | null>(null)
|
||||
const [open, setOpen] = useState(false)
|
||||
const [query, setQuery] = useState('')
|
||||
|
||||
const selIndex = useMemo(() => opts.findIndex((o) => sameValue(o.value, value)), [opts, value])
|
||||
const shown = selIndex >= 0 ? opts[selIndex].label : ''
|
||||
const view = useMemo(() => {
|
||||
const q = query.trim().toLowerCase()
|
||||
const all = opts.map((_, i) => i)
|
||||
return q ? all.filter((i) => opts[i].label.toLowerCase().includes(q)) : all
|
||||
}, [opts, query])
|
||||
const searchable = searchThreshold > 0 && opts.length > searchThreshold
|
||||
|
||||
const lb = useListbox({
|
||||
view,
|
||||
isDisabled: (i) => !!opts[i]?.disabled,
|
||||
labelOf: (i) => opts[i]?.label ?? '',
|
||||
open,
|
||||
onPick: chooseIndex,
|
||||
onOpen: openList,
|
||||
onClose: closeList,
|
||||
initialActive: () => (selIndex >= 0 ? selIndex : opts.findIndex((o) => !o.disabled))
|
||||
})
|
||||
|
||||
// 只盯 query:opts/view 每次渲染都是新引用,列进依赖会把高亮反复重置回第一行
|
||||
useEffect(() => {
|
||||
if (query) lb.setActive(view.find((i) => !opts[i]?.disabled) ?? -1)
|
||||
}, [query])
|
||||
|
||||
// 面板出现后把焦点交给过滤框(没有过滤框就留在触发器上,键盘不断)
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
;(searchable ? searchRef : triggerRef).current?.focus({ preventScroll: true })
|
||||
}, [open, searchable])
|
||||
|
||||
function openList() {
|
||||
if (disabled) return
|
||||
setQuery('')
|
||||
setOpen(true)
|
||||
lb.prime()
|
||||
}
|
||||
|
||||
/** refocus=false:外点到页面上的别的控件时,别把焦点抢回来,否则点不动下一个字段 */
|
||||
function closeList(refocus = true) {
|
||||
setQuery('')
|
||||
setOpen(false)
|
||||
if (refocus) triggerRef.current?.focus({ preventScroll: true })
|
||||
}
|
||||
|
||||
function chooseIndex(i: number) {
|
||||
const o = opts[i]
|
||||
if (!o || o.disabled) return
|
||||
onChange(o.value)
|
||||
setQuery('')
|
||||
setOpen(false)
|
||||
triggerRef.current?.focus({ preventScroll: true })
|
||||
}
|
||||
|
||||
const optId = (i: number) => `${uid}-o${i}`
|
||||
|
||||
void name /* 选项值由 value 表达,antd Select 不需要 DOM name */
|
||||
const raw = useMemo(() => toOptions(options), [options])
|
||||
const hasNull = raw.some((o) => o.value === null)
|
||||
const opts = useMemo(
|
||||
() => (hasNull ? raw.map((o) => (o.value === null ? { ...o, value: NULL_OPT } : o)) : raw),
|
||||
[raw, hasNull])
|
||||
// 先折 null,再折类型:外部给 null 且选项里真有「null 项」才选中它,否则照旧显示 placeholder
|
||||
const aimed = hasNull && value === null ? NULL_OPT : value
|
||||
// 类型宽容:把外部值折成选项里真实存在的那個 value(number/string 都认)
|
||||
const hit = aimed === null || aimed === undefined ? undefined : opts.find((o) => sameValue(o.value, aimed))
|
||||
const shown = aimed === null || aimed === undefined ? undefined : (hit ? hit.value : aimed)
|
||||
return (
|
||||
<Popup open={open} onOpenChange={(next) => (next ? openList() : closeList(false))}
|
||||
anchorRef={boxRef} label={ariaLabel || undefined} onKeyDown={lb.onKeyDown}
|
||||
anchor={
|
||||
<span ref={boxRef} className={cn('relative inline-flex w-full min-w-0 align-middle', open && 'z-[401]', className)}>
|
||||
<button ref={triggerRef} type="button" id={id} role="combobox" disabled={disabled}
|
||||
aria-label={ariaLabel || undefined} title={title}
|
||||
aria-haspopup="listbox" aria-expanded={open}
|
||||
aria-controls={open ? listId : undefined}
|
||||
aria-activedescendant={open && lb.active >= 0 ? optId(lb.active) : undefined}
|
||||
data-name={name}
|
||||
className={triggerCls({ size, open })}
|
||||
onClick={() => (open ? closeList() : openList())} onKeyDown={lb.onKeyDown}>
|
||||
<span className={cn('flex-1 min-w-0 truncate whitespace-nowrap', !shown && 'text-faint')}>{shown || placeholder}</span>
|
||||
<Caret open={open} />
|
||||
</button>
|
||||
</span>
|
||||
}>
|
||||
{searchable && (
|
||||
<div className={barLayer}>
|
||||
<input ref={searchRef} type="search" value={query} className={panelInputLayer} placeholder="过滤选项…"
|
||||
aria-label={`${ariaLabel || '选项'}:过滤`}
|
||||
onChange={(e) => setQuery(e.target.value)} onKeyDown={lb.onInputKeyDown} />
|
||||
<span className="flex-none text-tiny text-faint whitespace-nowrap">
|
||||
{view.length === opts.length ? `${opts.length} 项` : `${view.length} / ${opts.length} 项`}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<div ref={lb.listRef} id={listId} role="listbox" aria-label={ariaLabel || undefined} className={listLayer}>
|
||||
{view.map((i) => {
|
||||
const o: SelectOption = opts[i]
|
||||
const on = sameValue(o.value, value)
|
||||
return (
|
||||
<div key={`${o.value}-${i}`} id={optId(i)} role="option" aria-selected={on}
|
||||
data-active={i === lb.active ? '1' : undefined}
|
||||
data-on={on ? '1' : undefined}
|
||||
data-off={o.disabled ? '1' : undefined}
|
||||
className={itemCls({ mode: 'single' })}
|
||||
onMouseEnter={() => { if (!o.disabled) lb.setActive(i) }}
|
||||
onClick={() => chooseIndex(i)}>
|
||||
<span className={tickSlotLayer} style={{ opacity: on ? 1 : 0 }} aria-hidden>✓</span>
|
||||
<span className="min-w-0 break-anywhere">{o.label}</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{!opts.length && <div className={emptyLayer}>无可选项</div>}
|
||||
{!!opts.length && !view.length && <div className={emptyLayer}>没有匹配的选项</div>}
|
||||
</div>
|
||||
</Popup>
|
||||
<AntSelect
|
||||
id={id}
|
||||
title={title}
|
||||
aria-label={ariaLabel}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
className={className}
|
||||
size={size === 'sm' ? 'small' : size === 'md' ? 'middle' : undefined}
|
||||
allowClear={allowClear}
|
||||
value={shown}
|
||||
options={opts}
|
||||
// 面板宽度取触发器宽度,最少同宽:长选项在面板里折行,也不会横向压住别的字段
|
||||
popupMatchSelectWidth
|
||||
showSearch={searchThreshold > 0 && opts.length > searchThreshold}
|
||||
optionFilterProp="label"
|
||||
onChange={(next: any) => onChange(next === undefined ? '' : (next === NULL_OPT ? null : next))}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
/** 常用出口:把字典/枚举直接转成 options */
|
||||
export { toOptions, sameValue, summaryOf }
|
||||
export type { SelectOption }
|
||||
/** 页面偶尔要直接给选项数组(options 已经带 label/value):保持类型可用 */
|
||||
export function SelectOptionList({ options }: { options: OptionLike[] }) {
|
||||
return <>{toOptions(options).map((o) => o.label).join('、')}</>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,4 +3,3 @@ export * from './Select'
|
|||
export * from './MultiSelect'
|
||||
export * from './SecretInput'
|
||||
export * from './EyeIcon'
|
||||
export * from './Caret'
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export function AudioPlay({ src, label = '', durationMs = null, hint = '', size
|
|||
const total = active && duration ? duration * 1000 : Number(durationMs || 0)
|
||||
const progress = active && total ? Math.min(100, (position * 1000 / total) * 100) : 0
|
||||
|
||||
if (!src) return <span className="text-[10.5px] text-faint">无音频</span>
|
||||
if (!src) return <span className="text-tiny text-faint">无音频</span>
|
||||
|
||||
const toggle = () => (playing ? pauseAudio() : playAudio(src, label || '音频'))
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ export function AudioPlay({ src, label = '', durationMs = null, hint = '', size
|
|||
{cover && (
|
||||
<button type="button" title="在统一预览器中打开"
|
||||
onClick={(e) => { e.stopPropagation(); openMedia({ url: src, kind: 'audio', name: label || '音频' }) }}
|
||||
className={cn('flex-none w-[22px] h-[22px] border border-line-strong rounded-[6px] bg-transparent text-ink-3 text-tiny hover:border-accent-line hover:text-accent-bright', compact && 'w-[18px] h-[18px]')}>
|
||||
className={cn('flex-none w-[22px] h-[22px] border border-line-strong rounded-control bg-transparent text-ink-3 text-tiny hover:border-accent-line hover:text-accent-bright', compact && 'w-[18px] h-[18px]')}>
|
||||
⤢
|
||||
</button>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ import {
|
|||
viewedVersion
|
||||
} from '../../stores/preview'
|
||||
import { pauseAudio, playAudio, stopAudio, toggleAudio, useAudioStore } from '../../stores/audio'
|
||||
import { Button, MUTED, Tag } from '../ui'
|
||||
import { Button, MUTED, Tabs, Tag } from '../ui'
|
||||
import { Select } from '../forms'
|
||||
import { floatingLayerOpen } from '../primitives'
|
||||
import { floatingLayerOpen } from '../../lib/layers'
|
||||
import { VersionPanel } from './VersionPanel'
|
||||
|
||||
/** 格子上写「关键帧」就够,括注里的「(平台配音)/(模型原声)」留给 tooltip */
|
||||
|
|
@ -177,9 +177,14 @@ export function MediaLightbox() {
|
|||
const playingThis = audioPlaying && audioSrc === src
|
||||
const progress = audioDuration ? Math.min(100, (audioPosition / audioDuration) * 100) : 0
|
||||
|
||||
/* nex-lightbox:自绘浮层的表面标记。体检要靠它认出「该量的那块」——
|
||||
灯箱不在 antd 的 .ant-drawer / .ant-modal 里,没有标记就只能退回 main,
|
||||
于是「灯箱量过了」是假的(它的翻页箭头、本镜产物切换从没被量到过,
|
||||
42/34px 与 27px 就是这么藏住的)。别改成认 role="dialog":
|
||||
antd 抽屉的内容层同样带 role=dialog,会串味。 */
|
||||
return (
|
||||
<div role="dialog" aria-modal="true" aria-label={'预览 ' + item.title}
|
||||
className="fixed inset-0 z-220 grid place-items-center p-[14px] max-nav:p-2">
|
||||
className="nex-lightbox fixed inset-0 z-220 grid place-items-center p-[14px] max-nav:p-2">
|
||||
<div className="absolute inset-0 bg-backdrop [backdrop-filter:blur(7px)_saturate(.92)]" onClick={onClosed}></div>
|
||||
{/* 高度必须是确定值:.canvas img 的 max-height:100% 只有在父级高度确定时才生效,
|
||||
否则舞台高度由图片原始比例反推,footer 会被挤出 overflow:hidden,
|
||||
|
|
@ -188,25 +193,29 @@ export function MediaLightbox() {
|
|||
<header className="flex shrink-0 items-start justify-between gap-3.5 border-b border-line bg-raise px-4 py-3">
|
||||
<div className="min-w-0 grow [&_p]:m-0">
|
||||
<p className={MUTED}>{item.group || item.kindLabel || kindLabel(kind)}</p>
|
||||
<h3 className="mt-[3px] truncate text-[15px] font-bold">{item.title}</h3>
|
||||
<h3 className="mt-[3px] truncate text-title font-bold">{item.title}</h3>
|
||||
{item.subtitle && <p className="mt-1 truncate text-caption text-faint">{item.subtitle}</p>}
|
||||
</div>
|
||||
<div className="flex max-nav:max-w-[52%] shrink flex-wrap items-center justify-end gap-x-2 gap-y-1.5 max-w-[70%]">
|
||||
{peerCount > 1 && (
|
||||
<div role="group" aria-label="切换本镜产物"
|
||||
className="flex items-center gap-0.5 rounded-[9px] border border-line bg-sunken p-0.5">
|
||||
{peers.map((pb, pi) => (
|
||||
<button key={pb.key} type="button"
|
||||
className={cn('rounded-[7px] border border-transparent px-[9px] py-1 text-caption whitespace-nowrap hover:text-ink hover:bg-raise',
|
||||
pi === peerIndex ? 'border-line-strong bg-panel font-semibold text-ink' : 'text-dim')}
|
||||
title={`查看本镜的${pb.kindLabel}(${pi + 1}/${peerCount},[ 与 ] 切换)`}
|
||||
onClick={() => choosePeer(pi)}>{shortLabel(pb)}</button>
|
||||
))}
|
||||
</div>
|
||||
/* 本镜产物切换(关键帧 / 成片 / 配音…)。
|
||||
症状:原来是一只手写 pill——里面的 button 量到 27px(三档之外),
|
||||
选中态靠 border-line-strong + bg-panel 现场拼;它和顶栏那排
|
||||
视图切换页签明明是同一个动作,却长成两种控件。
|
||||
做法:交给 kit 的 <Tabs>(antd Segmented):短名进 label、说明进 hint
|
||||
(落到 title)、[ 与 ] 快捷键提示原样保留,左右方向键白送。
|
||||
为什么留在这里而不是页面:这是预览器自己的头部,属于媒体组件内部。 */
|
||||
<Tabs size="sm" ariaLabel="切换本镜产物" value={String(peerIndex)}
|
||||
onChange={(v) => choosePeer(Number(v))}
|
||||
items={peers.map((pb, pi) => ({
|
||||
value: String(pi),
|
||||
label: shortLabel(pb),
|
||||
hint: `查看本镜的${pb.kindLabel}(${pi + 1}/${peerCount},[ 与 ] 切换)`
|
||||
}))} />
|
||||
)}
|
||||
{count > 1 && <span className="rounded-[7px] border border-line bg-sunken px-2 py-1 font-mono text-caption text-ink-3">{position} / {count}</span>}
|
||||
{count > 1 && <span className="rounded-control border border-line bg-sunken px-2 py-1 font-mono text-caption text-ink-3">{position} / {count}</span>}
|
||||
{canSwitchVersion && (
|
||||
<label className="flex shrink-0 flex-row items-center gap-1.5 text-[10.5px] whitespace-nowrap text-faint">
|
||||
<label className="flex shrink-0 flex-row items-center gap-1.5 text-tiny whitespace-nowrap text-faint">
|
||||
<span>版本</span>
|
||||
<Select
|
||||
size="sm"
|
||||
|
|
@ -248,7 +257,7 @@ export function MediaLightbox() {
|
|||
<div className="relative flex min-h-0 grow items-stretch gap-1.5 bg-deepest p-2.5 max-nav:p-2">
|
||||
{count > 1 && (
|
||||
<button type="button" onClick={() => step(-1)} disabled={store.index <= 0} title="上一个 (←)"
|
||||
className="absolute top-1/2 left-4 z-3 grid h-[42px] w-[42px] -translate-y-1/2 place-items-center rounded-full border border-backdrop-veil bg-backdrop-veil p-0 pb-0.5 text-[21px] leading-none text-ink backdrop-blur-[6px] shadow-[0_6px_20px_var(--c-backdrop-shadow)] max-nav:left-2.5 max-nav:h-[34px] max-nav:w-[34px] max-nav:text-[17px] hover:not-disabled:scale-106 hover:not-disabled:border-accent-fill hover:not-disabled:bg-accent-fill hover:not-disabled:text-on-accent disabled:opacity-34">‹</button>
|
||||
className="absolute top-1/2 left-4 z-3 grid h-(--ctl-h-lg) w-(--ctl-h-lg) -translate-y-1/2 place-items-center rounded-full border border-backdrop-veil bg-backdrop-veil p-0 pb-0.5 text-num-sm leading-none text-ink backdrop-blur-[6px] shadow-[0_6px_20px_var(--c-backdrop-shadow)] max-nav:left-2.5 max-nav:text-h2 hover:not-disabled:scale-106 hover:not-disabled:border-accent-fill hover:not-disabled:bg-accent-fill hover:not-disabled:text-on-accent disabled:opacity-34">‹</button>
|
||||
)}
|
||||
|
||||
{/* canvas 必须自己撑满 stage 且行高确定(minmax(0,1fr)),
|
||||
|
|
@ -256,16 +265,16 @@ export function MediaLightbox() {
|
|||
<div className="relative grid min-h-0 min-w-0 grow [grid-template:minmax(0,1fr)/minmax(0,1fr)] place-items-center">
|
||||
{kind === 'image' && (
|
||||
<img src={src} alt={item.title} onError={() => setFailed(true)}
|
||||
className={cn('max-h-full max-w-full rounded-[8px] bg-black', failed && 'invisible')} />
|
||||
className={cn('max-h-full max-w-full rounded-tile bg-black', failed && 'invisible')} />
|
||||
)}
|
||||
{kind === 'video' && (
|
||||
<video ref={videoRef} src={src} poster={item.poster || undefined} controls autoPlay playsInline
|
||||
onError={() => setFailed(true)}
|
||||
className={cn('max-h-full max-w-full rounded-[8px] bg-black', failed && 'invisible')} />
|
||||
className={cn('max-h-full max-w-full rounded-tile bg-black', failed && 'invisible')} />
|
||||
)}
|
||||
{kind === 'audio' && (
|
||||
<div className="max-h-full w-[min(460px,100%)] max-w-full overflow-auto rounded-block border border-line bg-panel px-[18px] py-6 text-center">
|
||||
<div className={cn('mx-auto mb-3 grid h-[74px] w-[74px] place-items-center rounded-full border border-accent-line bg-accent-tint text-[26px] text-accent-bright', playingThis && 'animate-spin-slow')}>{iconFor('audio')}</div>
|
||||
<div className={cn('mx-auto mb-3 grid h-[74px] w-[74px] place-items-center rounded-full border border-accent-line bg-accent-tint text-h1 text-accent-bright', playingThis && 'animate-spin-slow')}>{iconFor('audio')}</div>
|
||||
<p className="mb-3 text-ui font-semibold">{item.title}</p>
|
||||
<div role="slider" aria-label="播放进度" aria-valuenow={Math.round(audioDuration ? (audioPosition / audioDuration) * 100 : 0)}
|
||||
className="h-[5px] overflow-hidden rounded-pill bg-active">
|
||||
|
|
@ -273,18 +282,18 @@ export function MediaLightbox() {
|
|||
</div>
|
||||
<div className="mt-3.5 flex items-center justify-center gap-2">
|
||||
<button type="button" onClick={() => playAudio(src, item.title)} disabled={playingThis} title="播放 (Space)"
|
||||
className="h-[30px] w-[34px] rounded-[8px] border border-line-strong bg-sunken text-[11px] text-ink disabled:opacity-35">▶</button>
|
||||
className="h-(--ctl-h-md) w-[34px] rounded-tile border border-line-strong bg-sunken text-caption text-ink disabled:opacity-35">▶</button>
|
||||
<button type="button" onClick={() => pauseAudio()} disabled={!playingThis} title="暂停 (Space)"
|
||||
className="h-[30px] w-[34px] rounded-[8px] border border-line-strong bg-sunken text-[11px] text-ink disabled:opacity-35">❚❚</button>
|
||||
<span className="ml-1.5 font-mono text-[10.5px] text-faint">{(audioPosition || 0).toFixed(1)}s / {audioDuration ? audioDuration.toFixed(1) + 's' : '—'}</span>
|
||||
className="h-(--ctl-h-md) w-[34px] rounded-tile border border-line-strong bg-sunken text-caption text-ink disabled:opacity-35">❚❚</button>
|
||||
<span className="ml-1.5 font-mono text-tiny text-faint">{(audioPosition || 0).toFixed(1)}s / {audioDuration ? audioDuration.toFixed(1) + 's' : '—'}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{kind !== 'image' && kind !== 'video' && kind !== 'audio' && (
|
||||
<div className="max-h-full max-w-full overflow-auto text-center text-ink-3">
|
||||
<b className="text-[34px] font-normal text-muted">{iconFor(kind)}</b>
|
||||
<b className="text-3xl font-normal text-muted">{iconFor(kind)}</b>
|
||||
<p className="my-2 text-ui">{item.title}</p>
|
||||
<a className="inline-flex items-center rounded-[7px] bg-accent-fill px-[11px] py-[7px] text-[10.5px] text-on-accent no-underline" href={downloadHref} target="_blank" rel="noopener">打开 / 下载文件</a>
|
||||
<a className="inline-flex items-center rounded-control bg-accent-fill px-[11px] py-[7px] text-tiny text-on-accent no-underline" href={downloadHref} target="_blank" rel="noopener">打开 / 下载文件</a>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
@ -300,7 +309,7 @@ export function MediaLightbox() {
|
|||
|
||||
{count > 1 && (
|
||||
<button type="button" onClick={() => step(1)} disabled={store.index >= count - 1} title="下一个 (→)"
|
||||
className="absolute top-1/2 right-4 z-3 grid h-[42px] w-[42px] -translate-y-1/2 place-items-center rounded-full border border-backdrop-veil bg-backdrop-veil p-0 pb-0.5 text-[21px] leading-none text-ink backdrop-blur-[6px] shadow-[0_6px_20px_var(--c-backdrop-shadow)] max-nav:right-2.5 max-nav:h-[34px] max-nav:w-[34px] max-nav:text-[17px] hover:not-disabled:scale-106 hover:not-disabled:border-accent-fill hover:not-disabled:bg-accent-fill hover:not-disabled:text-on-accent disabled:opacity-34">›</button>
|
||||
className="absolute top-1/2 right-4 z-3 grid h-(--ctl-h-lg) w-(--ctl-h-lg) -translate-y-1/2 place-items-center rounded-full border border-backdrop-veil bg-backdrop-veil p-0 pb-0.5 text-num-sm leading-none text-ink backdrop-blur-[6px] shadow-[0_6px_20px_var(--c-backdrop-shadow)] max-nav:right-2.5 max-nav:text-h2 hover:not-disabled:scale-106 hover:not-disabled:border-accent-fill hover:not-disabled:bg-accent-fill hover:not-disabled:text-on-accent disabled:opacity-34">›</button>
|
||||
)}
|
||||
|
||||
{manage && canSwitchVersion && store.versionPanelOpen && <VersionPanel onClose={() => toggleVersionPanel(false)} />}
|
||||
|
|
@ -318,14 +327,26 @@ export function MediaLightbox() {
|
|||
</div>
|
||||
)}
|
||||
<div className="ml-auto flex min-h-(--ctl-h-md) shrink-0 flex-wrap items-center justify-end gap-2">
|
||||
<span className="text-tiny text-faint">
|
||||
{/* 键盘提示在 ≤560 收起。
|
||||
症状:430 上这一整组量到 513px 宽,把「下载」顶到视口外 117px
|
||||
(体检读数:footer 溢出 117 · 下载 right=537.84 而 vw=430)。
|
||||
根因不是没写 flex-wrap:这一组自己就是 513px——flex-wrap 只管它
|
||||
的孩子折不折行,而这组作为 footer 的孩子是 shrink-0,
|
||||
基础尺寸 = 它的 max-content(键盘提示一整句 + 三颗按钮),
|
||||
宽度从来不受限,于是孩子永远不会折行,只能整组溢出。
|
||||
做法:≤560 是触摸档(metrics 的 narrow:控件升到 36/40/44),
|
||||
←/→、Space、Esc 这些键在这类设备上不存在,翻页有屏上的 ‹ › 圆钮、
|
||||
关闭有 ✕,这句话纯属占宽的噪声,直接收起而不是折行。
|
||||
为什么不改成 shrink-0 → min-w-0:那样会把这句在 3 个字处折断,
|
||||
读起来像坏了,而不是像为手机重排过。 */}
|
||||
<span className="text-tiny text-faint max-narrow:hidden">
|
||||
{count > 1 ? <>← / → 上一镜 / 下一镜{peerCount > 1 && <> · [ / ] 换本镜产物</>} · Space 播放 · Esc 关闭</> : 'Esc 关闭 · I 切换信息'}
|
||||
</span>
|
||||
{copied && <Tag tone="accent">{copied}</Tag>}
|
||||
{store.versionFeedback && <Tag tone={store.versionFeedback.tone === 'bad' ? 'bad' : 'ok'}>{store.versionFeedback.text}</Tag>}
|
||||
<Button variant="ghost" onClick={copyLink}>复制链接</Button>
|
||||
<Button variant="ghost" href={downloadHref} target="_blank" rel="noopener">新窗口</Button>
|
||||
<Button variant="primary" href={downloadHref} download={item.downloadName} className="text-[10.5px] no-underline">下载</Button>
|
||||
<Button variant="primary" href={downloadHref} download={item.downloadName} className="text-tiny no-underline">下载</Button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -22,21 +22,45 @@ export type MediaThumbProps = {
|
|||
title?: string
|
||||
size?: 'xs' | 'sm' | 'md' | 'lg'
|
||||
width?: string | number
|
||||
radius?: number
|
||||
/** 圆角档位(不传按 size 取默认):只准用尺子上的名字,页面不再传 5/6/8/10 这类数 */
|
||||
radius?: MediaRadius
|
||||
clickable?: boolean
|
||||
badge?: ReactNode
|
||||
queue?: any[]
|
||||
index?: number
|
||||
inlineAudio?: boolean
|
||||
/**
|
||||
* 页面自己决定「点开会看到什么」。给了它就不再走默认灯箱:
|
||||
* 分镜表格里点缩略图,要看的是「这一镜的关键帧 + 同组队列」,
|
||||
* 手上这张 92px 缩略图只是入口,默认逻辑再开一次等于抢页面决定好的内容。
|
||||
*/
|
||||
onOpen?: (item: MediaItem) => void
|
||||
/** 右上角的删除叉(整块媒体一个动作):皮肤属于媒体覆盖层族,不给页面自己拼 */
|
||||
onRemove?: () => void
|
||||
/** 说明删掉之后会连带丢什么(版本历史要不要):只写「删除」等于没写 */
|
||||
removeTitle?: string
|
||||
className?: string
|
||||
}
|
||||
|
||||
const FRAME_H: Record<string, string> = { xs: 'h-[34px]', sm: 'h-16', md: 'h-[118px]', lg: 'h-[172px]' }
|
||||
|
||||
/**
|
||||
* 缩略图圆角档位(tokens.css --radius-*)。
|
||||
* 之前 radius 是一个裸数字,19 处调用传了 5/6/7/8/10 五个值——
|
||||
* 6 和 8、10 都不在尺子上,同一面素材墙里的方块圆角肉眼可见地不一致。
|
||||
* 现在只能点档位,并且按尺寸有默认值(小方块跟控件同档、大方块跟 tile 同档),
|
||||
* 页面不传就是对的。
|
||||
*/
|
||||
export type MediaRadius = 'chip' | 'control' | 'tile' | 'block'
|
||||
const RADIUS_CLS: Record<MediaRadius, string> = {
|
||||
chip: 'rounded-chip', control: 'rounded-control', tile: 'rounded-tile', block: 'rounded-block'
|
||||
}
|
||||
const RADIUS_BY_SIZE: Record<string, MediaRadius> = { xs: 'control', sm: 'control', md: 'tile', lg: 'tile' }
|
||||
|
||||
export function MediaThumb({
|
||||
src = '', item = null, kind = '', mime = '', poster = '', title = '', size = 'md',
|
||||
width = '100%', radius = 8, clickable = true, badge, queue, index = 0, inlineAudio = true, onOpen, className
|
||||
width = '100%', radius, clickable = true, badge, queue, index = 0, inlineAudio = true, onOpen,
|
||||
onRemove, removeTitle, className
|
||||
}: MediaThumbProps) {
|
||||
const [failed, setFailed] = useState(false)
|
||||
const [posterFailed, setPosterFailed] = useState(false)
|
||||
|
|
@ -58,8 +82,8 @@ export function MediaThumb({
|
|||
|
||||
function click() {
|
||||
if (!clickable || !media) return
|
||||
if (onOpen) { onOpen(media); return }
|
||||
openPreview(queue?.length ? queue : [media], queue?.length ? index : 0)
|
||||
onOpen?.(media)
|
||||
}
|
||||
|
||||
/* 多版素材的角标:以前只写「v4」,没人知道点它管理版本,甚至版本被删回
|
||||
|
|
@ -84,14 +108,14 @@ export function MediaThumb({
|
|||
style={{ width }} onClick={click}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); click() } }}
|
||||
className={cn('block min-w-0', clickable && 'cursor-pointer group', className)}>
|
||||
<div className={cn('relative overflow-hidden bg-sunken border border-line w-full group-hover:border-accent-line group-hover:shadow-[0_0_0_2px_var(--c-accent-tint)]', FRAME_H[size] || FRAME_H.md)}
|
||||
style={{ borderRadius: radius }}>
|
||||
<div className={cn('relative overflow-hidden bg-sunken border border-line w-full group-hover:border-accent-line group-hover:shadow-[0_0_0_2px_var(--c-accent-tint)]',
|
||||
FRAME_H[size] || FRAME_H.md, RADIUS_CLS[radius || RADIUS_BY_SIZE[size] || 'control'])}>
|
||||
{kindNow === 'image' && !showFail && <img src={imageSrc} alt={label} loading="lazy" decoding="async" className="block w-full h-full object-cover" onError={() => setFailed(true)} />}
|
||||
{kindNow === 'video' && !showFail && posterSrc && !posterFailed && <img src={posterSrc} alt={label} loading="lazy" decoding="async" className="block w-full h-full object-cover" onError={() => setPosterFailed(true)} />}
|
||||
{kindNow === 'video' && !showFail && (!posterSrc || posterFailed) && <video src={url} muted playsInline preload="metadata" className="block w-full h-full object-cover" onError={() => setFailed(true)} />}
|
||||
{showFail && (
|
||||
<div className="absolute inset-0 grid place-content-center gap-[3px] justify-items-center text-center p-1.5 bg-sunken text-faint">
|
||||
<b className="text-[15px] font-medium text-muted">{iconFor(kindNow as any)}</b>
|
||||
<b className="text-title font-medium text-muted">{iconFor(kindNow as any)}</b>
|
||||
<small className="text-tiny leading-[1.35]">{placeholderFor(kindNow as any)}</small>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -103,6 +127,7 @@ export function MediaThumb({
|
|||
<span aria-hidden className="absolute left-1 top-1 text-tiny px-[5px] py-0.5 rounded-chip bg-scrim text-white max-w-[calc(100%-8px)] truncate">♫ {label}</span>
|
||||
)}
|
||||
{badge && <span className="absolute right-1 top-1 text-tiny px-[5px] py-0.5 rounded-chip bg-scrim text-white">{badge}</span>}
|
||||
{onRemove && <MediaRemove onClick={onRemove} title={removeTitle || '删除这份媒体'} />}
|
||||
{showVer && (
|
||||
<button type="button" onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
|
|
@ -111,7 +136,7 @@ export function MediaThumb({
|
|||
toggleVersionPanel(true)
|
||||
}}
|
||||
title={manageable ? `共 ${versionCount} 个版本,点击管理(设为默认 / 删除)` : `当前 v${media?.version}`}
|
||||
className={cn('absolute left-1 bottom-1 font-inherit text-tiny px-[5px] py-px rounded-chip bg-scrim text-white tracking-[.3px] leading-[1.45]',
|
||||
className={cn('nex-media-badge absolute left-1 bottom-1 font-inherit text-tiny px-[5px] py-px rounded-chip bg-scrim text-white tracking-[.3px] leading-[1.45]',
|
||||
manageable && 'cursor-pointer hover:bg-accent-fill hover:text-on-accent')}>
|
||||
{verBadge}
|
||||
</button>
|
||||
|
|
@ -120,3 +145,45 @@ export function MediaThumb({
|
|||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 贴在媒体右上角的删除叉。
|
||||
*
|
||||
* 症状:这颗叉原来是 AssetLibrary 页面里的私有常量 MEDIA_REMOVE,
|
||||
* 时间线 / 素材抽屉想要同一个动作时只能再抄一遍(w-5 h-5 + 六条颜色类),
|
||||
* 而它和 MediaThumb 自带的版本角标是同一族东西——都压在媒体上、都不参与控件档位。
|
||||
* 做法:收进媒体组件,谁要删除入口就给 MediaThumb 传 onRemove,
|
||||
* 自己拼的占位方块(无缩略图的文件)也可以直接用这只。
|
||||
* 为什么 stopPropagation:外层整块媒体本身可点开预览,删除不能顺手把灯箱也打开。
|
||||
*/
|
||||
export function MediaRemove({ onClick, title, label = '删除这个素材' }: {
|
||||
onClick: () => void; title?: string; label?: string
|
||||
}) {
|
||||
return (
|
||||
<button type="button" title={title} aria-label={label}
|
||||
onClick={(e) => { e.stopPropagation(); onClick() }}
|
||||
className="nex-media-remove absolute right-[3px] top-[3px] z-[3] grid place-items-center w-5 h-5 p-0 rounded-full cursor-pointer border border-danger-line text-danger-bright text-title leading-none hover:bg-danger-line bg-[color-mix(in_srgb,var(--c-danger-tint2)_91%,transparent)]">
|
||||
×
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 压在媒体左上角的勾选框底板。
|
||||
*
|
||||
* 为什么单独一只:缩略图是深色图,勾选框直接放上去看不见,必须垫一层半透明壳;
|
||||
* 这层壳以前写在 AssetLibrary 的私有常量 PICK 里,素材墙和卡片列表各调一次,
|
||||
* 位置还要各自用 left-[12px] 微调。现在位置留给页面(那是布局),底板皮肤归这里。
|
||||
*/
|
||||
export function MediaPick({ children, className, title }: {
|
||||
children: ReactNode; className?: string; title?: string
|
||||
}) {
|
||||
return (
|
||||
<label title={title}
|
||||
className={cn('nex-media-pick absolute left-2 top-2 z-[3] grid place-items-center w-[21px] h-[21px] '
|
||||
+ 'm-0 p-0 rounded-control bg-[color-mix(in_srgb,var(--c-bg-shell)_74%,transparent)] '
|
||||
+ '[&>[role=checkbox]]:w-[13px] [&>[role=checkbox]]:h-[13px]', className)}>
|
||||
{children}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ import {
|
|||
recordingBlockedReason, recordingSupported, type MicProbe, type Recording
|
||||
} from '../../lib/recorder'
|
||||
import { AudioPlay } from './AudioPlay'
|
||||
import { Checkbox } from '../primitives'
|
||||
import { Checkbox } from '../ui/Checkbox'
|
||||
import { Input } from '../ui'
|
||||
|
||||
export type RecordPickMeta = {
|
||||
durationMs: number
|
||||
|
|
@ -35,7 +36,7 @@ type Stage = 'idle' | 'recording' | 'preview'
|
|||
/** 提示语里用 **包起来** 的部分渲染成粗体(不动 dangerouslySetInnerHTML,免得中文标点被当标签吞) */
|
||||
function Segs({ text, className }: { text: string; className?: string }) {
|
||||
const parts = text ? text.split('**') : []
|
||||
return <p className={cn('m-0 text-[11px] leading-[1.6]', className)}>{parts.map((s, i) => i % 2 ? <b key={i}>{s}</b> : s)}</p>
|
||||
return <p className={cn('m-0 text-caption leading-[1.6]', className)}>{parts.map((s, i) => i % 2 ? <b key={i}>{s}</b> : s)}</p>
|
||||
}
|
||||
|
||||
export function RecordAudio({ label = '录制', target = '新版本', disabled = false, hint,
|
||||
|
|
@ -293,7 +294,7 @@ export function RecordAudio({ label = '录制', target = '新版本', disabled =
|
|||
<>
|
||||
<button type="button" disabled={!canStart} onClick={openSheet}
|
||||
title={blocked || hint || '录一段真人声音'}
|
||||
className={cn('inline-flex h-(--ctl-h-md) items-center gap-1 whitespace-nowrap rounded-[7px] border px-[9px] text-tiny',
|
||||
className={cn('inline-flex h-(--ctl-h-md) items-center gap-1 whitespace-nowrap rounded-control border px-[9px] text-tiny',
|
||||
stage === 'recording'
|
||||
? 'border-danger-line bg-danger-tint text-danger'
|
||||
: 'border-line-strong text-ink-2 hover:not-disabled:border-line-bright hover:not-disabled:bg-hover',
|
||||
|
|
@ -310,15 +311,15 @@ export function RecordAudio({ label = '录制', target = '新版本', disabled =
|
|||
<header className="flex items-start justify-between gap-2.5">
|
||||
<div>
|
||||
<small className="text-tiny tracking-[.1em] text-faint">RECORD · {target}</small>
|
||||
<h3 className="mt-[3px] text-[15px] font-bold">{stage === 'recording' ? '正在录制…' : stage === 'preview' ? '试听并保存' : '录一段声音'}</h3>
|
||||
<h3 className="mt-[3px] text-title font-bold">{stage === 'recording' ? '正在录制…' : stage === 'preview' ? '试听并保存' : '录一段声音'}</h3>
|
||||
</div>
|
||||
<button type="button" title="关闭(Esc)" onClick={close}
|
||||
className="border-0 bg-transparent px-1 py-0.5 text-[14px] text-faint hover:text-ink">✕</button>
|
||||
className="border-0 bg-transparent px-1 py-0.5 text-title text-faint hover:text-ink">✕</button>
|
||||
</header>
|
||||
|
||||
<ol className="m-0 flex list-none gap-1.5 p-0">
|
||||
{(['idle', 'recording', 'preview'] as Stage[]).map((s, i) => (
|
||||
<li key={s} className={cn('flex-1 rounded-[7px] border border-line bg-sunken py-[5px] text-center text-[10.5px] text-faint',
|
||||
<li key={s} className={cn('flex-1 rounded-control border border-line bg-sunken py-[5px] text-center text-tiny text-faint',
|
||||
stage === s && 'border-accent-line bg-tint-accent text-accent-bright',
|
||||
(s === 'idle' && stage !== 'idle') || (s === 'recording' && stage === 'preview') && 'border-success-line text-success')}>
|
||||
{['① 录制', '② 试听', '③ 保存'][i]}
|
||||
|
|
@ -328,20 +329,20 @@ export function RecordAudio({ label = '录制', target = '新版本', disabled =
|
|||
|
||||
{blocked ? <Segs text={`✕ ${blocked}`} className="text-danger" /> : supported && (
|
||||
<>
|
||||
<p className={cn('m-0 flex flex-wrap items-center gap-2 rounded-[8px] border px-2 py-1.5 text-[11px]',
|
||||
<p className={cn('m-0 flex flex-wrap items-center gap-2 rounded-tile border px-2 py-1.5 text-caption',
|
||||
micOk ? 'border-success-line bg-success-tint text-success' : 'border-warn-line bg-warn-tint text-warn')}>
|
||||
<span className="min-w-0 [overflow-wrap:anywhere]">{micOk ? '✓' : '⚠'} {micStatusText}</span>
|
||||
<span className="grow"></span>
|
||||
<button type="button" className="border-0 bg-transparent p-0 text-[10.5px] text-ink-3 underline whitespace-nowrap leading-[1.45] hover:text-accent-bright" onClick={() => void recheck()}>重新检测</button>
|
||||
{resetCmd && <button type="button" className="border-0 bg-transparent p-0 text-[10.5px] text-ink-3 underline whitespace-nowrap leading-[1.45] hover:text-accent-bright" onClick={copyReset}>复制修复命令</button>}
|
||||
{settingsLinks.map((l) => <a key={l.href} href={l.href} className="text-[10.5px] text-ink-3 underline underline-offset-2 whitespace-nowrap leading-[1.45] hover:text-accent-bright">{l.label}</a>)}
|
||||
<button type="button" className="border-0 bg-transparent p-0 text-tiny text-ink-3 underline whitespace-nowrap leading-[1.45] hover:text-accent-bright" onClick={() => void recheck()}>重新检测</button>
|
||||
{resetCmd && <button type="button" className="border-0 bg-transparent p-0 text-tiny text-ink-3 underline whitespace-nowrap leading-[1.45] hover:text-accent-bright" onClick={copyReset}>复制修复命令</button>}
|
||||
{settingsLinks.map((l) => <a key={l.href} href={l.href} className="text-tiny text-ink-3 underline underline-offset-2 whitespace-nowrap leading-[1.45] hover:text-accent-bright">{l.label}</a>)}
|
||||
</p>
|
||||
{copied && <p className="m-0 text-[10.5px] leading-[1.6] text-faint">{copied}</p>}
|
||||
{copied && <p className="m-0 text-tiny leading-[1.6] text-faint">{copied}</p>}
|
||||
{!micOk && preflight && <Segs text={preflight} className="text-warn" />}
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className={cn('flex flex-col items-center gap-2 rounded-[11px] border border-dashed border-line bg-sunken px-2.5 py-3',
|
||||
<div className={cn('flex flex-col items-center gap-2 rounded-tile border border-dashed border-line bg-sunken px-2.5 py-3',
|
||||
stage === 'recording' && 'border-solid border-danger-line')}>
|
||||
{stage !== 'recording' ? (
|
||||
<button ref={bigRef} type="button" disabled={!canStart} onClick={start}
|
||||
|
|
@ -358,34 +359,32 @@ export function RecordAudio({ label = '录制', target = '新版本', disabled =
|
|||
<b className="text-ui [font-variant-numeric:tabular-nums]">{fmtMs(elapsed)}</b>
|
||||
{stage === 'recording' && (
|
||||
<span title="麦克风电平" className="inline-flex h-[22px] w-[46px] items-end border border-line rounded-chip bg-shell p-0.5">
|
||||
<i className="block w-full rounded-[3px] bg-accent-fill transition-[height] duration-75" style={{ height: `${Math.max(6, Math.round(level * 100))}%` }}></i>
|
||||
<i className="block w-full rounded-chip bg-accent-fill transition-[height] duration-75" style={{ height: `${Math.max(6, Math.round(level * 100))}%` }}></i>
|
||||
</span>
|
||||
)}
|
||||
<span className="text-tiny text-faint">{stage === 'preview'
|
||||
? '已录好,点下面的 ▶ 试听确认后再保存'
|
||||
: `建议念满 ${minSec} 秒 · 上限 ${maxSec} 秒自动停止`}</span>
|
||||
</div>
|
||||
{silent && <p className="m-0 text-[11px] leading-[1.6] text-warn">已经录了 {Math.round(elapsed / 1000)} 秒还没收到声音:
|
||||
{silent && <p className="m-0 text-caption leading-[1.6] text-warn">已经录了 {Math.round(elapsed / 1000)} 秒还没收到声音:
|
||||
麦克风可能被静音,或选错了输入设备。点「停止录制」后重录。</p>}
|
||||
{awaiting > 0 && <p className="m-0 text-[11px] leading-[1.6] text-warn">⏳ 正在等系统授权(已等 {Math.ceil(awaiting / 1000)} 秒):
|
||||
{awaiting > 0 && <p className="m-0 text-caption leading-[1.6] text-warn">⏳ 正在等系统授权(已等 {Math.ceil(awaiting / 1000)} 秒):
|
||||
授权框{probe?.macos ? '在屏幕左下角,不在网页里' : '在地址栏左侧'},
|
||||
看不到就把这个浏览器切到最前面再点一次;超过 {Math.round(MIC_WAIT_MS / 1000)} 秒没点会自动取消。</p>}
|
||||
{busy && <p className="m-0 text-[10.5px] leading-[1.6] text-faint">转码中,请稍候…</p>}
|
||||
{busy && <p className="m-0 text-tiny leading-[1.6] text-faint">转码中,请稍候…</p>}
|
||||
{error && <Segs text={error} className="text-danger" />}
|
||||
{error && rawError && (
|
||||
<p className="-mt-0.5 flex flex-wrap items-center gap-[7px] text-tiny text-faint">浏览器原始报错 <code className="rounded-chip border border-line bg-sunken px-[5px] py-px font-mono">{rawError}</code>
|
||||
<button type="button" className="border-0 bg-transparent p-0 text-[10.5px] text-ink-3 underline whitespace-nowrap leading-[1.45] hover:text-accent-bright" onClick={copyDiag}>复制诊断码</button></p>
|
||||
<button type="button" className="border-0 bg-transparent p-0 text-tiny text-ink-3 underline whitespace-nowrap leading-[1.45] hover:text-accent-bright" onClick={copyDiag}>复制诊断码</button></p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{stage === 'preview' && (
|
||||
<div className="flex flex-col gap-2 rounded-[11px] bg-tint-accent p-2.5">
|
||||
<div className="flex flex-col gap-2 rounded-tile bg-tint-accent p-2.5">
|
||||
<AudioPlay src={previewUrl} label="刚才的录音" durationMs={taking?.durationMs || 0} size="sm" cover={false} />
|
||||
{warning && <p className="m-0 text-[11px] leading-[1.6] text-warn">{warning}</p>}
|
||||
<label className="m-0 flex flex-col gap-1 text-[11px]">存到哪条素材
|
||||
<input value={saveName} list={listId} placeholder="素材名称"
|
||||
title="选已有名称=追加成它的下一个版本(之后可删版本 / 设为当前版本);写新名称=新建一条素材"
|
||||
onChange={(e) => setSaveName(e.target.value)} />
|
||||
{warning && <p className="m-0 text-caption leading-[1.6] text-warn">{warning}</p>}
|
||||
<label className="m-0 flex flex-col gap-1 text-caption">存到哪条素材
|
||||
<Input value={saveName} list={listId} placeholder="素材名称" title="选已有名称=追加成它的下一个版本(之后可删版本 / 设为当前版本);写新名称=新建一条素材" onChange={(e) => setSaveName(e.target.value)} />
|
||||
<datalist id={listId}>{knownNames.map((n) => <option key={n} value={n} />)}</datalist>
|
||||
</label>
|
||||
<label className="m-0 inline-flex w-fit cursor-pointer flex-row items-center gap-[7px] text-label text-ink-2">
|
||||
|
|
@ -395,14 +394,14 @@ export function RecordAudio({ label = '录制', target = '新版本', disabled =
|
|||
)}
|
||||
|
||||
<footer className="flex items-center gap-2 [--ctl-h:var(--ctl-h-md)]">
|
||||
<button type="button" className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-[7px] border border-line-strong px-[9px] text-tiny text-ink-2 disabled:opacity-35" disabled={stage === 'recording'} onClick={close}>取消</button>
|
||||
{stage !== 'idle' && <button type="button" className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-[7px] border border-line-strong px-[9px] text-tiny text-ink-2" onClick={abandon}>清空重录</button>}
|
||||
<button type="button" className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-control border border-line-strong px-[9px] text-tiny text-ink-2 disabled:opacity-35" disabled={stage === 'recording'} onClick={close}>取消</button>
|
||||
{stage !== 'idle' && <button type="button" className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-control border border-line-strong px-[9px] text-tiny text-ink-2" onClick={abandon}>清空重录</button>}
|
||||
<span className="grow"></span>
|
||||
{stage === 'recording' ? (
|
||||
<button type="button" className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-[7px] border border-line-strong bg-line px-[9px] text-tiny text-ink" onClick={() => void stop()}>■ 停止并试听</button>
|
||||
<button type="button" className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-control border border-line-strong bg-line px-[9px] text-tiny text-ink" onClick={() => void stop()}>■ 停止并试听</button>
|
||||
) : (
|
||||
<button ref={primaryRef} type="button" disabled={stage !== 'preview' || !!busy || !saveName.trim()} onClick={confirmUpload}
|
||||
className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-[7px] bg-accent-fill px-[9px] text-tiny text-on-accent disabled:opacity-35">✓ 存为{target}</button>
|
||||
className="inline-flex h-(--ctl-h-md) items-center gap-1 rounded-control bg-accent-fill px-[9px] text-tiny text-on-accent disabled:opacity-35">✓ 存为{target}</button>
|
||||
)}
|
||||
</footer>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ export function VersionPanel({ onClose }: { onClose: () => void }) {
|
|||
<header className="flex shrink-0 items-start gap-2 [&_p]:m-0">
|
||||
<div className="min-w-0 grow">
|
||||
<p className={MUTED}>版本管理</p>
|
||||
<h4 className="mt-[2px] text-[13px] leading-[1.3] break-all">{item.title}</h4>
|
||||
<h4 className="mt-[2px] text-ui leading-[1.3] break-all">{item.title}</h4>
|
||||
<p className="mt-1 text-tiny text-ink-3">
|
||||
共 {rows.length} 版 · 当前默认 <b className="font-mono text-accent-bright">v{currentNo}</b>
|
||||
</p>
|
||||
|
|
@ -79,7 +79,7 @@ export function VersionPanel({ onClose }: { onClose: () => void }) {
|
|||
<Button variant="ghost" title="关闭版本管理" onClick={onClose} className="w-[26px] min-w-[26px] px-0">✕</Button>
|
||||
</header>
|
||||
|
||||
<p className="m-0 shrink-0 rounded-[8px] border border-line bg-sunken px-2 py-[7px] text-tiny leading-[1.55] text-ink-3">
|
||||
<p className="m-0 shrink-0 rounded-tile border border-line bg-sunken px-2 py-[7px] text-tiny leading-[1.55] text-ink-3">
|
||||
<b className="text-ink-2">设为默认</b>:平台母版与之后引入项目的素材都取这一版;项目里已锁定的快照不会自动改版。<br />
|
||||
<b className="text-ink-2">删除</b>:连同文件一起清理;若仍被生成记录引用,只删记录并保留文件。
|
||||
</p>
|
||||
|
|
@ -105,7 +105,7 @@ export function VersionPanel({ onClose }: { onClose: () => void }) {
|
|||
type="button"
|
||||
title={'预览 v' + row.version_no}
|
||||
onClick={() => chooseVersion(row.version_no)}
|
||||
className="grid h-10 w-[52px] shrink-0 place-items-center overflow-hidden rounded-[7px] border border-line bg-sunken p-0 text-[15px] text-muted [cursor:zoom-in]"
|
||||
className="grid h-10 w-[52px] shrink-0 place-items-center overflow-hidden rounded-control border border-line bg-sunken p-0 text-title text-muted [cursor:zoom-in]"
|
||||
>
|
||||
{cover
|
||||
? <img src={cover} alt={'v' + row.version_no} loading="lazy" decoding="async" className="block h-full w-full object-cover" />
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
import * as RadixCheckbox from '@radix-ui/react-checkbox'
|
||||
import { forwardRef, type ComponentPropsWithoutRef, type ElementRef, type ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 勾选框(Radix Checkbox)。
|
||||
*
|
||||
* 换掉的是 `<input type=checkbox>` + `accent-color`:那条路只能改颜色,改不了形状——
|
||||
* macOS 给的是 3px 圆角的系统绿块,Windows 是方角,表格行里并排看就是「控件不是一套」。
|
||||
* 更麻烦的是 Shift 范围选择与 `indeterminate`:原生 indeterminate 只能用 JS 设 property,
|
||||
* React 没有对应属性(旧代码为此写过 ref 副作用)。Radix 把三态放进 `checked` 的值里。
|
||||
*
|
||||
* 三态在这里是真实需求:素材库表头那颗「全选」在有部分行选中时必须是半选,
|
||||
* 画成「没勾」会让人再点一次变成全不选。
|
||||
*
|
||||
* 两个 Indicator 都 forceMount,靠各自的 data-state 显隐:
|
||||
* 只对 `props.checked` 做三元判断的写法在非受控(defaultChecked)时会画错半选。
|
||||
*
|
||||
* 皮肤:14px(触摸档 18px,见 tokens.css --check-size),描边 + 主色填充 + 白色对勾,
|
||||
* 半选用一条短横。焦点环走全局 :focus-visible,不额外画。
|
||||
*/
|
||||
export type CheckboxProps = Omit<ComponentPropsWithoutRef<typeof RadixCheckbox.Root>, 'children'> & {
|
||||
/** 只有画在选项行里的那些(MultiSelect)需要换尺寸 */
|
||||
size?: 'sm' | 'md'
|
||||
/** 换掉对勾:比如「展开/折叠」这种借用勾选框皮肤的开关 */
|
||||
icon?: ReactNode
|
||||
}
|
||||
|
||||
export const Checkbox = forwardRef<ElementRef<typeof RadixCheckbox.Root>, CheckboxProps>(
|
||||
({ size = 'md', icon, className, ...props }, ref) => (
|
||||
<RadixCheckbox.Root
|
||||
ref={ref}
|
||||
className={cn('flex-none grid place-items-center rounded-[4px] border border-line-strong bg-field '
|
||||
+ 'text-on-accent transition-colors duration-120 '
|
||||
+ 'data-[state=checked]:border-accent-fill data-[state=checked]:bg-accent-fill '
|
||||
+ 'data-[state=indeterminate]:border-accent-fill data-[state=indeterminate]:bg-accent-fill '
|
||||
+ 'disabled:opacity-40 disabled:cursor-not-allowed',
|
||||
size === 'sm' ? 'w-[13px] h-[13px]' : 'w-(--check-size) h-(--check-size)', className)}
|
||||
{...props}>
|
||||
<RadixCheckbox.Indicator forceMount
|
||||
className="grid place-items-center hidden data-[state=checked]:grid">
|
||||
{icon ?? <CheckIcon />}
|
||||
</RadixCheckbox.Indicator>
|
||||
<RadixCheckbox.Indicator forceMount aria-hidden
|
||||
className="grid place-items-center hidden data-[state=indeterminate]:grid">
|
||||
<span className="block w-[7px] h-[2px] rounded-pill bg-current" />
|
||||
</RadixCheckbox.Indicator>
|
||||
</RadixCheckbox.Root>
|
||||
))
|
||||
Checkbox.displayName = 'Checkbox'
|
||||
|
||||
function CheckIcon() {
|
||||
return (
|
||||
<svg viewBox="0 0 14 14" className="block w-[10px] h-[10px]" aria-hidden="true"
|
||||
fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M2.5 7.4 5.6 10.4 11.5 3.9" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
import * as RadixDialog from '@radix-ui/react-dialog'
|
||||
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 浮层行为层:Radix Dialog。
|
||||
*
|
||||
* 自己实现一份「浮层」要付的账(旧 Overlay.tsx 全踩过):
|
||||
* 焦点进不去、Tab 能跑到背后的页面上、Esc 靠 window 全局监听互相抢、
|
||||
* 滚动锁只写 body{overflow:hidden}(有滚动条的页面开抽屉会左右跳 15px)、
|
||||
* 读屏拿不到标题(role=dialog 却没有可关联的名字)。
|
||||
* Radix 把这五件事做完了,并且和 Popover / Menu 共用同一个 DismissableLayer 栈,
|
||||
* 「点下拉面板不算点外面」这类判断才有一个统一的地方。
|
||||
*
|
||||
* 皮肤仍然在我们的令牌里(tokens.css + Tailwind),Radix 只给 data-state。
|
||||
*
|
||||
* ⚠️ 可访问性名字必须显式给:Radix 找不到 <Dialog.Title> 又没看到
|
||||
* aria-label / aria-labelledby 就在控制台报警告。我们的标题是 <h2>{title}</h2>
|
||||
* 这种自带结构的节点(还常常套一层 <span title="…">),所以用 useId 把
|
||||
* id 牵到 aria-labelledby 上,而不是把 h2 塞进 Dialog.Title 里改排版;
|
||||
* 没有副标题时传 aria-describedby={undefined}(键存在就足够让警告闭嘴)。
|
||||
*/
|
||||
|
||||
export const DialogRoot = RadixDialog.Root
|
||||
export const DialogTrigger = RadixDialog.Trigger
|
||||
export const DialogClose = RadixDialog.Close
|
||||
export const DialogPortal = RadixDialog.Portal
|
||||
|
||||
/** 遮罩。层级低于面板、高于页面内容;下拉面板(Popup 的 400)再压在面板上 */
|
||||
export const scrimLayer = 'fixed inset-0 z-[100] bg-scrim backdrop-blur-[4px] data-[state=open]:animate-fade-in'
|
||||
|
||||
export function Scrim(props: ComponentPropsWithoutRef<typeof RadixDialog.Overlay>) {
|
||||
return <RadixDialog.Overlay {...props} className={cn(scrimLayer, props.className)} />
|
||||
}
|
||||
|
||||
/**
|
||||
* 「点外面」判定。
|
||||
*
|
||||
* 两种不关:① closeOnBackdrop=false(分镜那种要看旁边面板的浮层);
|
||||
* ② 点到的其实是浮层里那个下拉面板——Radix Popover 把面板 portal 到 body,
|
||||
* DOM 上不在 Content 里。Radix 自己的层栈能认出大多数情况,这里再兜一道,
|
||||
* 免得选中一项就把整个抽屉关掉(也顺便挡住焦点移出触发的 FocusOutside)。
|
||||
*/
|
||||
function floatingLayerOf(target: EventTarget | null) {
|
||||
const el = target instanceof Element ? target : null
|
||||
return !!el?.closest('[data-nex-layer],[data-radix-popper-content-wrapper]')
|
||||
}
|
||||
function keepOpen(closeOnBackdrop: boolean) {
|
||||
return <E extends { detail?: { originalEvent?: Event }; preventDefault(): void }>(e: E) => {
|
||||
const original = e.detail?.originalEvent
|
||||
if (!closeOnBackdrop || floatingLayerOf(original?.target ?? null)) e.preventDefault()
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开时不把焦点丢进第一个输入框:抽屉里 autofokus 会顶掉页面滚动位置 */
|
||||
function holdFocus() {
|
||||
return (e: Event) => {
|
||||
e.preventDefault()
|
||||
;(e.currentTarget as HTMLElement | null)?.focus?.({ preventScroll: true })
|
||||
}
|
||||
}
|
||||
|
||||
/** 右侧抽屉的面板(配合 DrawerBody/DrawerActions 三段式皮肤) */
|
||||
export function SheetContent({ children, width, closeOnBackdrop = true, labelledBy, describedBy, label, className }: {
|
||||
children: ReactNode
|
||||
/** Tailwind 宽度类;默认 1360px 表单抽屉 */
|
||||
width?: string
|
||||
closeOnBackdrop?: boolean
|
||||
labelledBy?: string
|
||||
describedBy?: string
|
||||
label?: string
|
||||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<RadixDialog.Content
|
||||
aria-labelledby={labelledBy} aria-describedby={describedBy ?? undefined} aria-label={label}
|
||||
onOpenAutoFocus={holdFocus()} onCloseAutoFocus={(e) => e.preventDefault()}
|
||||
onInteractOutside={keepOpen(closeOnBackdrop)} onFocusOutside={keepOpen(closeOnBackdrop)}
|
||||
className={cn('fixed inset-y-0 right-0 z-[101] flex flex-col min-w-0 h-full border-l border-line-strong '
|
||||
+ 'bg-shell shadow-drawer data-[state=open]:animate-sheet-in',
|
||||
width || 'w-[min(1360px,calc(100vw-20px))] max-huge:w-[calc(100vw-16px)] max-short:w-screen', className)}>
|
||||
{children}
|
||||
</RadixDialog.Content>
|
||||
)
|
||||
}
|
||||
|
||||
/** 居中模态的面板:只放一两句确认文案 + 两个动作 */
|
||||
export function ModalContent({ children, width = 560, closeOnBackdrop = true, labelledBy, describedBy, label, className }: {
|
||||
children: ReactNode
|
||||
/** 像素宽度上限(窄屏由 calc(100vw-32px) 兜住) */
|
||||
width?: number
|
||||
closeOnBackdrop?: boolean
|
||||
labelledBy?: string
|
||||
describedBy?: string
|
||||
label?: string
|
||||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<RadixDialog.Content
|
||||
aria-labelledby={labelledBy} aria-describedby={describedBy ?? undefined} aria-label={label}
|
||||
onOpenAutoFocus={holdFocus()} onCloseAutoFocus={(e) => e.preventDefault()}
|
||||
onInteractOutside={keepOpen(closeOnBackdrop)} onFocusOutside={keepOpen(closeOnBackdrop)}
|
||||
style={{ maxWidth: `min(${width}px, calc(100vw - 32px))` }}
|
||||
className={cn('fixed left-1/2 top-1/2 z-[111] -translate-x-1/2 -translate-y-1/2 '
|
||||
+ 'flex max-h-[calc(100vh-32px)] w-full flex-col overflow-hidden rounded-float '
|
||||
+ 'border border-line-strong bg-shell shadow-pop data-[state=open]:animate-pop-in', className)}>
|
||||
{children}
|
||||
</RadixDialog.Content>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
import * as RadixMenu from '@radix-ui/react-dropdown-menu'
|
||||
import type { ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 菜单(Radix DropdownMenu):账号菜单、行内操作菜单共用。
|
||||
*
|
||||
* 换掉的是「div + useOutsideClick + role=menu」那套手写实现:它没有焦点圈定
|
||||
* (Tab 会跑到菜单背后)、方向键不能走选项、Esc 只关自己不管焦点归还,
|
||||
* 而且每个使用点都得自己记得挂 useOutsideClick,漏一个就是一处 bug。
|
||||
*
|
||||
* 皮肤档位与下拉面板同源(tokens:圆角 float / 描边 line-strong / 底 panel)。
|
||||
*/
|
||||
export const MenuRoot = RadixMenu.Root
|
||||
export const MenuTrigger = RadixMenu.Trigger
|
||||
export const MenuPortal = RadixMenu.Portal
|
||||
export const MenuGroup = RadixMenu.Group
|
||||
|
||||
const CONTENT = 'z-[400] min-w-[196px] rounded-float border border-line-strong bg-panel p-[7px] '
|
||||
+ 'shadow-pop data-[state=open]:animate-fade-in'
|
||||
const ITEM = 'flex min-h-[32px] w-full items-center gap-[9px] rounded-[8px] px-[9px] py-[7px] '
|
||||
+ 'text-left text-body text-ink-2 no-underline outline-none cursor-pointer '
|
||||
+ 'data-[highlighted]:bg-hover data-[highlighted]:text-ink '
|
||||
+ 'disabled:opacity-40 disabled:cursor-not-allowed'
|
||||
export const MENU_ITEM = ITEM
|
||||
export const MENU_ICON = 'w-[15px] flex-none text-center text-body text-muted'
|
||||
|
||||
export function MenuContent({ children, className, label, align = 'end', sideOffset = 8 }: {
|
||||
children: ReactNode; className?: string; label?: string
|
||||
align?: 'start' | 'center' | 'end'; sideOffset?: number
|
||||
}) {
|
||||
return (
|
||||
<RadixMenu.Portal>
|
||||
<RadixMenu.Content data-nex-layer="menu" aria-label={label} side="bottom" align={align} sideOffset={sideOffset}
|
||||
// 打开时焦点进菜单(DropdownMenu 没有 onOpenAutoFocus——它本来就
|
||||
// 把焦点交给面板,方向键/首字母定位由 Radix 接管),
|
||||
// 关闭时由 Radix 还给触发按钮。
|
||||
className={cn(CONTENT, className)}>
|
||||
{children}
|
||||
</RadixMenu.Content>
|
||||
</RadixMenu.Portal>
|
||||
)
|
||||
}
|
||||
|
||||
/** 菜单项:asChild 时把语义挂到 Link / NavLink 上,路由跳转仍然由 React Router 负责 */
|
||||
export function MenuItem({ children, className, danger, asChild, ...props }:
|
||||
React.ComponentProps<typeof RadixMenu.Item> & { danger?: boolean }) {
|
||||
return (
|
||||
<RadixMenu.Item
|
||||
{...props} asChild={asChild}
|
||||
className={cn(ITEM, danger && 'text-danger data-[highlighted]:bg-danger-tint data-[highlighted]:text-danger-bright',
|
||||
className)}>
|
||||
{children}
|
||||
</RadixMenu.Item>
|
||||
)
|
||||
}
|
||||
|
||||
/** 菜单里的说明块(不可点:环境自检结论、权限提示) */
|
||||
export function MenuNote({ children, tone = 'muted', className }: {
|
||||
children: ReactNode; tone?: 'muted' | 'warn'; className?: string
|
||||
}) {
|
||||
return (
|
||||
<p className={cn('m-0 rounded-[8px] px-[9px] py-[7px] text-tiny leading-[1.5] [overflow-wrap:anywhere]',
|
||||
tone === 'warn' ? 'bg-warn-tint text-warn-bright' : 'bg-hover text-faint', className)}>
|
||||
{children}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
export function MenuSeparator({ className }: { className?: string }) {
|
||||
return <RadixMenu.Separator className={cn('my-[5px] mx-0.5 h-px bg-line-soft', className)} />
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
import * as RadixPopover from '@radix-ui/react-popover'
|
||||
import type { KeyboardEvent as ReactKeyboardEvent, ReactNode, RefObject } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { contentLayer } from './layers'
|
||||
|
||||
/**
|
||||
* 下拉面板的宿主:Radix Popover 负责 portal、跟随锚点、视口避让(放不下就翻边)、
|
||||
* 外点关闭、Esc、焦点管理;皮肤在 layers.ts,行为参数由调用点决定。
|
||||
*
|
||||
* 用 Anchor 而不是 Trigger:开合与键盘继续由 Select / MultiSelect 自己管
|
||||
* (两者共用 useListbox),Trigger 会替我们吞掉 Enter/Space/方向键。
|
||||
*
|
||||
* 代价是 Radix 的「点在触发器上不要当成外点」只认 Trigger 注册的 ref,
|
||||
* 用 Anchor 时 anchorRef 得我们自己传进来(见下面的 onInteractOutside)。
|
||||
*
|
||||
* 取代的是旧 forms/use-popup.ts:那份要自己量 left/top/width/maxH、
|
||||
* 渲染完再按 rect 二次纠正、手写 pointerdown/scroll/resize 监听,
|
||||
* 全站十几个 overflow 容器 + 抽屉照样能把面板裁掉。
|
||||
*/
|
||||
export function Popup({ open, onOpenChange, anchor, anchorRef, children, className, label, onKeyDown }: {
|
||||
open: boolean
|
||||
onOpenChange: (next: boolean) => void
|
||||
/** 触发器本身(必须能接 ref),面板贴着它摆 */
|
||||
anchor: ReactNode
|
||||
/** 指向 anchor 那个节点:外点/焦点离开时用来判断「其实点的是自己」 */
|
||||
anchorRef?: RefObject<HTMLElement | null>
|
||||
children: ReactNode
|
||||
className?: string
|
||||
/** 读屏用:面板是干什么的(Radix 给 Content 的 role 是 dialog) */
|
||||
label?: string
|
||||
onKeyDown?: (e: ReactKeyboardEvent) => void
|
||||
}) {
|
||||
// Radix 把 outside 事件派发在真正被点到的那个元素上,原始事件挂在 detail 里
|
||||
const hitAnchor = (target: EventTarget | null) => {
|
||||
const host = anchorRef?.current
|
||||
return !!host && !!target && host.contains(target as Node)
|
||||
}
|
||||
return (
|
||||
<RadixPopover.Root open={open} onOpenChange={onOpenChange} modal={false}>
|
||||
<RadixPopover.Anchor asChild>{anchor}</RadixPopover.Anchor>
|
||||
<RadixPopover.Portal>
|
||||
<RadixPopover.Content
|
||||
// 给 Dialog 的「点外面」判定认人用:面板 portal 在 body 上,
|
||||
// 抽屉需要知道「这点在我下拉里」,否则选中一项就把抽屉关了
|
||||
data-nex-layer="popup"
|
||||
aria-label={label}
|
||||
// 左对齐锚点、下沿 6px;离视口边留 8px,放不下由 Radix 翻到上方
|
||||
side="bottom" align="start" sideOffset={6} collisionPadding={8}
|
||||
// 焦点留在触发器上,键盘与首字母定位才不会一开就断;关闭时由调用点把焦点还回去
|
||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||
onCloseAutoFocus={(e) => e.preventDefault()}
|
||||
onInteractOutside={(e) => { if (hitAnchor(e.detail?.originalEvent?.target ?? null)) e.preventDefault() }}
|
||||
onFocusOutside={(e) => { if (hitAnchor(e.detail?.originalEvent?.target ?? null)) e.preventDefault() }}
|
||||
// 面板挂在 body 上,但 React 的事件仍沿组件树冒泡:不拦住的话,
|
||||
// 点一下选项会连带触发外层那一行 / 那张卡片的 click、mousedown
|
||||
onMouseDown={(e) => e.stopPropagation()}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className={cn(contentLayer, className)}
|
||||
onKeyDown={onKeyDown}>
|
||||
{children}
|
||||
</RadixPopover.Content>
|
||||
</RadixPopover.Portal>
|
||||
</RadixPopover.Root>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
import * as RadixSlider from '@radix-ui/react-slider'
|
||||
import type { ComponentPropsWithoutRef, ElementRef } from 'react'
|
||||
import { forwardRef } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 数值滑杆(Radix Slider)。
|
||||
*
|
||||
* 原生 `<input type=range>` 的 `accent-color` 只能改一个颜色:轨道粗细、滑块直径、
|
||||
* 已填充段全是系统画的(模型抽屉里 Temperature 那根 5px 灰线配一颗系统绿点,
|
||||
* 和旁边的自定义控件明显不是一套)。Radix 给出 track / range / thumb 三个槽,
|
||||
* 尺寸全部来自我们的令牌,键盘(← → Home End PageUp/Down)与 aria 值域也齐了。
|
||||
*
|
||||
* 命中区撑满 --ctl-h(肉眼看到的仍是 5px 细轨),拖动时不用瞄准。
|
||||
*/
|
||||
export type SliderProps = Omit<ComponentPropsWithoutRef<typeof RadixSlider.Root>, 'children'> & {
|
||||
trackClassName?: string
|
||||
/** 多段滑杆(起止时间)时才需要传第二个 thumb,Radix 按 value 数组长度画 */
|
||||
thumbs?: number
|
||||
}
|
||||
|
||||
export const Slider = forwardRef<ElementRef<typeof RadixSlider.Root>, SliderProps>(
|
||||
({ className, trackClassName, thumbs = 1, ...props }, ref) => (
|
||||
<RadixSlider.Root
|
||||
ref={ref}
|
||||
className={cn('relative flex items-center w-full min-w-0 h-(--ctl-h) touch-none select-none '
|
||||
+ 'disabled:opacity-45', className)}
|
||||
{...props}>
|
||||
<RadixSlider.Track
|
||||
className={cn('relative grow h-[5px] rounded-pill bg-active overflow-hidden', trackClassName)}>
|
||||
<RadixSlider.Range className="absolute inset-y-0 left-0 rounded-pill bg-accent-fill" />
|
||||
</RadixSlider.Track>
|
||||
{Array.from({ length: thumbs }, (_, i) => (
|
||||
<RadixSlider.Thumb key={i}
|
||||
className="block w-[14px] h-[14px] rounded-pill border-[3px] border-accent-fill bg-card" />
|
||||
))}
|
||||
</RadixSlider.Root>
|
||||
))
|
||||
Slider.displayName = 'Slider'
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
/**
|
||||
* primitives:Radix 行为 + 本站令牌皮肤。
|
||||
*
|
||||
* 分工(docs/UI规范.md §0.5):Radix 管「浮层怎么活」(定位/翻边/焦点/键盘/关闭),
|
||||
* layers.ts 管「长什么样」(尺寸、字号、圆角、配色全部来自 tokens.css),
|
||||
* ui/ 与 forms/ 管「业务语义」(字段、面板、状态标签…)。
|
||||
* 想换行为库,只动这一层。
|
||||
*/
|
||||
export * from './layers'
|
||||
export * from './use-listbox'
|
||||
export * from './Popup'
|
||||
export * from './Dialog'
|
||||
export * from './Menu'
|
||||
export * from './Checkbox'
|
||||
export * from './Slider'
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* primitives 的皮肤层:Radix 只负责行为(portal / 定位 / 翻边 / 视口避让 / 外点关闭 /
|
||||
* Esc / 焦点),DOM 和类名仍然归我们,`styles/tokens.css` 依旧是唯一的尺子来源。
|
||||
*
|
||||
* 这里是 Select / MultiSelect(以及后续 Tooltip、Menu)共用的一套档位,
|
||||
* 取代原先散在 forms/parts.ts 里的手写条件类名。
|
||||
*
|
||||
* 两条改过的规矩(都是量出来的问题):
|
||||
* 1. 触发器字号两档统一 text-body。旧实现 sm 档写死 `text-tiny`(10px) + `rounded-[6px]`,
|
||||
* 同一条筛选条里旁边的 input 是 12px / 7px 圆角,一眼就能看出两种控件。
|
||||
* 2. 弹层宽度「不小于触发器」而不是固定 168px。旧实现 82px 的触发器顶出 168px 的面板,
|
||||
* 多出来的 86px 直接压住右边的字段标题。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 页面上是否有浮层(Dialog / 下拉面板 / 菜单)正开着。
|
||||
*
|
||||
* 页面级快捷键必须先看它一眼:Radix 的 Esc 只负责关自己那一层,
|
||||
* 而页面的 window keydown 是另挂的——「检查器 + 下拉」「预览器 + 版本下拉」
|
||||
* 叠在一起时,一次 Esc 会把两层全关掉(用户描述:「按 Esc 结果整个抽屉都没了」)。
|
||||
* 判据用我们自己在每层浮层上打的 data-nex-layer / Radix 的 data-state,
|
||||
* 不依赖 z-index,也不依赖组件实例间的 context。
|
||||
*/
|
||||
export function floatingLayerOpen(root: ParentNode = document): boolean {
|
||||
return !!root.querySelector('[data-nex-layer][data-state="open"], [role="dialog"][data-state="open"]')
|
||||
}
|
||||
|
||||
/** 触发器:高度只来自 --ctl-h(容器决定档位),组件内部不写死 px */
|
||||
export const triggerLayer = cva([
|
||||
'appearance-none flex items-center gap-2 w-full min-w-0 text-left outline-none',
|
||||
'h-(--ctl-h) rounded-control border border-line-strong bg-field text-ink text-body leading-[1.35]',
|
||||
'transition-[border-color,background,box-shadow] duration-150',
|
||||
'hover:not-disabled:border-line-bright hover:not-disabled:bg-hover',
|
||||
'disabled:cursor-not-allowed disabled:opacity-50',
|
||||
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent'
|
||||
].join(' '), {
|
||||
variants: {
|
||||
size: { sm: 'px-2', md: 'px-[10px]' },
|
||||
open: { true: 'border-accent-deep shadow-[0_0_0_3px_var(--c-accent-tint)]' }
|
||||
},
|
||||
defaultVariants: { size: 'md', open: false }
|
||||
})
|
||||
|
||||
/**
|
||||
* 弹层容器。Radix 在 Content 上给出两个实测变量:
|
||||
* --radix-popover-trigger-width(锚点宽度)、--radix-popover-content-available-{width,height}(避让后的可用空间),
|
||||
* 直接消费它们,就不需要旧 use-popup.ts 里手算 left/top/maxH 与二次纠正。
|
||||
*/
|
||||
export const contentLayer = [
|
||||
// 不能写 fixed:Radix 的定位在它外层 wrapper 上(translate 摆位置),
|
||||
// 面板自己再 fixed 就脱离文档流,wrapper 量到的高度是 0,
|
||||
// flip/size 全按 0 高算——贴近视口底边时「该翻不翻」或「翻了不减高度」,面板掉到屏幕外。
|
||||
'z-[400] flex flex-col overflow-hidden',
|
||||
'rounded-[10px] border border-line-strong bg-panel shadow-pop',
|
||||
// 宽度三段式:至少和触发器一样宽(面板不会缩成一条)、按最长选项自然展开
|
||||
// (长标签不该被挤成两行)、超过 440 或视口放不下才换行
|
||||
'min-w-(--radix-popover-trigger-width) w-max',
|
||||
'max-w-[min(440px,calc(var(--radix-popover-content-available-width)-16px))]',
|
||||
'max-h-[min(320px,var(--radix-popover-content-available-height))]',
|
||||
'data-[state=open]:animate-fade-in'
|
||||
].join(' ')
|
||||
|
||||
/** 选项滚动区 */
|
||||
export const listLayer = 'flex-1 min-h-0 overflow-auto scrollbar-slim p-[5px]'
|
||||
|
||||
/**
|
||||
* 选项行:状态写在 DOM 属性上(data-active / data-on / data-off),类名只描述属性。
|
||||
*
|
||||
* 「选中」和「键盘高亮」同时命中时谁赢不能靠 CSS 出场顺序赌:
|
||||
* 叠加态用两个属性选择器(data-[on=1]:data-[active=1]:…),特指度天然更高。
|
||||
*/
|
||||
export const itemLayer = cva([
|
||||
'flex items-start gap-[7px] p-[7px_8px] rounded-[7px] cursor-pointer',
|
||||
'text-body leading-[1.45] text-ink-2',
|
||||
'data-[active=1]:bg-hover data-[active=1]:text-ink',
|
||||
'data-[off=1]:cursor-not-allowed data-[off=1]:opacity-40'
|
||||
].join(' '), {
|
||||
variants: {
|
||||
mode: {
|
||||
/** 单选:选中项点亮主色,且点亮色压过键盘高亮 */
|
||||
single: 'data-[on=1]:bg-accent-tint data-[on=1]:text-accent-bright '
|
||||
+ 'data-[on=1]:data-[active=1]:bg-accent-tint-2 data-[on=1]:data-[active=1]:text-accent-bright',
|
||||
/** 多选:勾选框自己说话,文字不换色,只保留键盘高亮底色 */
|
||||
multi: 'data-[on=1]:text-ink data-[on=1]:data-[active=1]:text-ink'
|
||||
}
|
||||
},
|
||||
defaultVariants: { mode: 'single' }
|
||||
})
|
||||
|
||||
/** 面板顶部那条(过滤框 + 计数 + 批量按钮) */
|
||||
export const barLayer = 'flex-none flex items-center gap-[7px] p-[7px_8px] border-b border-line bg-raise'
|
||||
|
||||
/** 面板里的小输入框:它不是字段,不吃 --ctl-h,只吃同一套圆角和描边 */
|
||||
export const panelInputLayer = [
|
||||
'flex-1 min-w-0 h-auto py-[5px] px-2 text-caption rounded-[6px]',
|
||||
'border border-line-strong bg-field text-ink outline-none focus:border-accent-deep',
|
||||
'[&::-webkit-search-cancel-button]:appearance-none'
|
||||
].join(' ')
|
||||
|
||||
export const emptyLayer = 'p-[10px] text-center text-caption text-faint'
|
||||
|
||||
/** 面板里的批量动作小按钮(全选 / 清空) */
|
||||
export const chipButtonLayer = [
|
||||
'flex-none p-[4px_7px] rounded-[6px] text-tiny border border-line-strong bg-hover text-ink-2',
|
||||
'disabled:opacity-40 disabled:cursor-not-allowed',
|
||||
'hover:not-disabled:border-line-bright hover:not-disabled:text-ink'
|
||||
].join(' ')
|
||||
|
||||
/** 多选触发器上的计数角标 */
|
||||
export const countBadgeLayer = [
|
||||
'flex-none min-w-[17px] h-[17px] px-[5px] rounded-pill grid place-items-center',
|
||||
'bg-accent-fill text-on-accent text-tiny font-bold leading-none'
|
||||
].join(' ')
|
||||
|
||||
/** 多选行的勾选框(画在行里,不是表单控件) */
|
||||
export const tickBoxLayer = 'flex-none w-[14px] h-[14px] mt-px rounded-[4px] grid place-items-center border text-on-accent'
|
||||
/** 单选行的对勾槽位:没选中也占位,否则文字会左右跳 */
|
||||
export const tickSlotLayer = 'flex-none w-3 shrink-0 mt-px text-[11px] text-accent-bright'
|
||||
|
||||
/** 下拉箭头:展开时翻转并点亮,用户永远知道面板是开还是关 */
|
||||
export const caretLayer = 'flex-none w-[15px] h-[15px] text-muted transition-transform duration-150'
|
||||
export const CARET_PATH = 'M5.5 7.5 10 12l4.5-4.5'
|
||||
|
||||
/** 保持函数式写法,调用点少改一层 */
|
||||
export function triggerCls(o: VariantProps<typeof triggerLayer> & { className?: string } = {}) {
|
||||
const { className, ...variants } = o
|
||||
return cn(triggerLayer(variants), className)
|
||||
}
|
||||
/** 选项行的类名:只有形态(单选/多选)参与拼类名,开关状态是 DOM 属性不是类 */
|
||||
export function itemCls(o: VariantProps<typeof itemLayer> & { className?: string } = {}) {
|
||||
const { className, ...variants } = o
|
||||
return cn(itemLayer(variants), className)
|
||||
}
|
||||
export function caretCls(open: boolean) {
|
||||
return cn(caretLayer, open && 'rotate-180 text-accent-bright')
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import type { KeyboardEvent as ReactKeyboardEvent } from 'react'
|
||||
|
||||
/**
|
||||
* 列表键盘导航:Select(单选)与 MultiSelect(多选)共用的一份实现。
|
||||
*
|
||||
* 原来两个控件各自写了 60 行几乎一样的 ↑↓ Home End Enter Esc + 首字母定位,
|
||||
* 改一处忘一处(例如多选漏掉首字母定位,单选漏掉 Home/End)。
|
||||
* 定位/关闭交给 Radix,这里只管「高亮哪一项、按键是什么意思」。
|
||||
*/
|
||||
export type ListboxSpec = {
|
||||
/** 过滤后可见的选项在完整列表里的下标(保持接口给的顺序,不做模糊重排) */
|
||||
view: number[]
|
||||
isDisabled: (i: number) => boolean
|
||||
labelOf: (i: number) => string
|
||||
open: boolean
|
||||
onPick: (i: number) => void
|
||||
onOpen: () => void
|
||||
onClose: () => void
|
||||
/** 展开时高亮谁:单选回显当前值,多选回显第一个已选 */
|
||||
initialActive: () => number
|
||||
}
|
||||
|
||||
export function useListbox(spec: ListboxSpec) {
|
||||
// spec 每次渲染都是新对象:放进 ref,回调保持恒定身份,省掉一串 useCallback 依赖
|
||||
const ref = useRef(spec)
|
||||
ref.current = spec
|
||||
const listRef = useRef<HTMLDivElement | null>(null)
|
||||
const type = useRef({ text: '', timer: 0 })
|
||||
const [active, setActive] = useState(-1)
|
||||
// 高亮项也要读最新值:下面这些回调故意保持恒定身份,否则会锁死在旧闭包里
|
||||
const activeRef = useRef(active)
|
||||
activeRef.current = active
|
||||
|
||||
const firstEnabled = useCallback(() => {
|
||||
const { view, isDisabled } = ref.current
|
||||
return view.find((i) => !isDisabled(i)) ?? -1
|
||||
}, [])
|
||||
|
||||
/** 展开时把高亮挪到初值(没有可选就是 -1,让 Enter 什么也不做) */
|
||||
const prime = useCallback(() => {
|
||||
const s = ref.current
|
||||
const want = s.initialActive()
|
||||
setActive(s.view.includes(want) ? want : firstEnabled())
|
||||
}, [firstEnabled])
|
||||
|
||||
/** 高亮项滚进可视区:键盘走三屏之后看不见光标,和没做键盘一个体验 */
|
||||
const scrollActive = useCallback(() => {
|
||||
listRef.current?.querySelector<HTMLElement>('[data-active="1"]')?.scrollIntoView({ block: 'nearest' })
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (spec.open) queueMicrotask(scrollActive)
|
||||
}, [spec.open, active, scrollActive])
|
||||
|
||||
useEffect(() => () => window.clearTimeout(type.current.timer), [])
|
||||
|
||||
const step = useCallback((delta: number) => {
|
||||
const { view, isDisabled } = ref.current
|
||||
if (!view.length) return
|
||||
let pos = Math.max(0, view.indexOf(activeRef.current))
|
||||
for (let n = 0; n < view.length; n++) {
|
||||
pos = (pos + delta + view.length) % view.length
|
||||
if (!isDisabled(view[pos])) break
|
||||
}
|
||||
setActive(view[pos])
|
||||
}, [])
|
||||
|
||||
const jump = useCallback((edge: 'first' | 'last') => {
|
||||
const { view, isDisabled } = ref.current
|
||||
const order = edge === 'first' ? view : [...view].reverse()
|
||||
setActive(order.find((i) => !isDisabled(i)) ?? -1)
|
||||
}, [])
|
||||
|
||||
/** 首字母定位:连续敲字在 420ms 内累加,能直接敲「qwen」跳到那一项 */
|
||||
const typeAhead = useCallback((ch: string) => {
|
||||
const { view, labelOf, isDisabled } = ref.current
|
||||
const buf = type.current
|
||||
buf.text += ch.toLowerCase()
|
||||
window.clearTimeout(buf.timer)
|
||||
buf.timer = window.setTimeout(() => { buf.text = '' }, 420)
|
||||
const hit = view.find((i) => !isDisabled(i) && labelOf(i).toLowerCase().startsWith(buf.text))
|
||||
if (hit !== undefined) setActive(hit)
|
||||
}, [])
|
||||
|
||||
/** 触发器与面板共用:面板里的按键会冒泡到这里,统一消化,避免二次执行 */
|
||||
const onKeyDown = useCallback((e: ReactKeyboardEvent) => {
|
||||
if ((e.target as HTMLElement | null)?.tagName === 'INPUT') return
|
||||
const s = ref.current
|
||||
if (e.key === 'Escape') {
|
||||
if (s.open) { e.preventDefault(); e.stopPropagation(); s.onClose() }
|
||||
return
|
||||
}
|
||||
if (e.key === 'Tab') { if (s.open) s.onClose(); return }
|
||||
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
||||
e.preventDefault()
|
||||
if (!s.open) s.onOpen()
|
||||
else step(e.key === 'ArrowDown' ? 1 : -1)
|
||||
return
|
||||
}
|
||||
if (e.key === 'Home' || e.key === 'End') {
|
||||
if (!s.open) return
|
||||
e.preventDefault()
|
||||
jump(e.key === 'Home' ? 'first' : 'last')
|
||||
return
|
||||
}
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault()
|
||||
if (!s.open) s.onOpen()
|
||||
else if (activeRef.current >= 0) s.onPick(activeRef.current)
|
||||
return
|
||||
}
|
||||
if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
||||
if (!s.open) s.onOpen()
|
||||
else typeAhead(e.key)
|
||||
}
|
||||
}, [step, jump, typeAhead])
|
||||
|
||||
/** 过滤框自己吃掉的键:不拦的话方向键一次走两格、回车来回切换 */
|
||||
const onInputKeyDown = useCallback((e: ReactKeyboardEvent) => {
|
||||
const s = ref.current
|
||||
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
||||
e.preventDefault(); e.stopPropagation(); step(e.key === 'ArrowDown' ? 1 : -1)
|
||||
} else if (e.key === 'Home' || e.key === 'End') {
|
||||
e.preventDefault(); e.stopPropagation(); jump(e.key === 'Home' ? 'first' : 'last')
|
||||
} else if (e.key === 'Enter') {
|
||||
if (activeRef.current >= 0) { e.preventDefault(); e.stopPropagation(); s.onPick(activeRef.current) }
|
||||
else e.stopPropagation()
|
||||
} else if (e.key === 'Escape') {
|
||||
e.stopPropagation(); s.onClose()
|
||||
}
|
||||
}, [step, jump])
|
||||
|
||||
return { listRef, active, setActive, firstEnabled, prime, scrollActive, step, jump, onKeyDown, onInputKeyDown }
|
||||
}
|
||||
|
|
@ -1,95 +1,177 @@
|
|||
import { type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ReactNode, type Ref, forwardRef } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 全站唯一的按钮。
|
||||
* 按钮:Ant Design 5 Button 的唯一封装。
|
||||
*
|
||||
* 为什么只有这一个组件:旧站同一颗「取消」在四个页面分别是 .secondary / .outline /
|
||||
* .ghost / 裸 button,padding 各自写死,同一行里量出 31/34/36/38 四种高度。
|
||||
* 现在高度只有两档,且**由所在容器决定**:容器用 [--ctl-h:var(--ctl-h-md)]
|
||||
* 声明自己是紧凑档(工具条、筛选条、卡片动作行),按钮写 h-(--ctl-h) 自动跟随。
|
||||
* 页面要更矮不要加 padding,把外层换成 <Ctlbar> / <ChipBar> 就行。
|
||||
* 页面只说语义(primary / secondary / ghost / add / del / link),
|
||||
* 颜色、高度、圆角、字号全部来自 theme/antd.ts 的 Button token——
|
||||
* 以前每页自己拼 bg-/border-/rounded- 类,同一页里能长出四五种按钮。
|
||||
*
|
||||
* 变体语义(不要凭手感挑):
|
||||
* primary 一个区域里唯一的主动作(保存 / 开始生成)
|
||||
* secondary 有底的次动作
|
||||
* outline 中性动作、与主按钮并排的「取消」
|
||||
* ghost 紧凑行里的轻动作(抽屉、灯箱、卡片角)
|
||||
* add / del 成组列表里的「加一行 / 删一行」,不是页面级主操作
|
||||
* link 文字链样式的动作(表格行内),仍然是控件、与同行等高
|
||||
* 尺寸只有两档真实存在:md=38(表单、页面主操作)、sm=31(工具条、卡片动作行、表格行内)。
|
||||
* 档位不由页面指定:容器(Ctlbar / 表格)用 <ConfigProvider componentSize> 统一下发,
|
||||
* 页面写 size 只用于「这一处就是要比容器小一档」的例外。
|
||||
*/
|
||||
import { forwardRef, type ReactNode } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Button as AntButton } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import type { ButtonProps as AntButtonProps } from 'antd'
|
||||
|
||||
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'add' | 'del' | 'link'
|
||||
export type ButtonSize = 'sm' | 'md' | 'lg'
|
||||
|
||||
const BASE = 'inline-flex items-center justify-center gap-1.5 rounded-control border border-transparent '
|
||||
+ 'font-semibold whitespace-nowrap shrink-0 select-none h-(--ctl-h) px-[13px] text-caption leading-[1.2] '
|
||||
+ 'transition-[background,border-color,color,filter] duration-150 '
|
||||
+ 'disabled:opacity-35 disabled:cursor-not-allowed'
|
||||
|
||||
const VARIANTS: Record<ButtonVariant, string> = {
|
||||
primary: 'bg-accent-fill text-on-accent hover:not-disabled:brightness-[1.09] active:not-disabled:translate-y-px',
|
||||
secondary: 'bg-line text-ink border-line-strong hover:not-disabled:bg-raise',
|
||||
outline: 'bg-transparent text-ink-2 border-line-strong hover:not-disabled:bg-hover',
|
||||
ghost: 'bg-transparent text-ink-2 border-line-strong rounded-[7px] px-[9px] text-tiny h-(--ctl-h-md) '
|
||||
+ 'hover:not-disabled:border-line-bright hover:not-disabled:bg-hover',
|
||||
add: 'bg-accent-fill text-on-accent rounded-[8px] px-[10px] text-caption h-(--ctl-h-md) min-w-(--ctl-h-md) shadow-raise '
|
||||
+ 'hover:not-disabled:brightness-[1.09] active:not-disabled:translate-y-px',
|
||||
del: 'bg-danger-tint-2 text-danger-bright border-danger-line rounded-[8px] px-[10px] text-caption h-(--ctl-h-md) min-w-(--ctl-h-md) '
|
||||
+ 'hover:not-disabled:bg-danger hover:not-disabled:border-danger hover:not-disabled:text-danger-ink',
|
||||
link: 'border-transparent bg-transparent text-success text-body px-0 h-auto min-h-(--ctl-h-md) '
|
||||
+ 'hover:not-disabled:underline disabled:opacity-40'
|
||||
}
|
||||
|
||||
const SIZES: Record<ButtonSize, string> = {
|
||||
sm: 'h-(--ctl-h-md) px-[9px] text-tiny gap-[5px]',
|
||||
md: '',
|
||||
lg: 'h-(--ctl-h-main) text-body'
|
||||
}
|
||||
|
||||
type CommonProps = {
|
||||
type Common = {
|
||||
variant?: ButtonVariant
|
||||
/** 不写=跟随容器档位(antd 的 middle = 主档 38) */
|
||||
size?: ButtonSize
|
||||
/** 只有一个符号(× / +)时保持正方形,热区不小于控件高度 */
|
||||
square?: boolean
|
||||
/** 危险语义的描边/幽灵按钮 */
|
||||
/** 危险语义:红色只表达「会丢数据」 */
|
||||
danger?: boolean
|
||||
/** 选中态(筛选、分段开关) */
|
||||
/** 选中态(筛选、分段开关这类要点亮的按钮) */
|
||||
on?: boolean
|
||||
/** 只有一个图标(× / ↺):antd 的图标按钮本身就是正方形热区 */
|
||||
square?: boolean
|
||||
loading?: boolean
|
||||
disabled?: boolean
|
||||
block?: boolean
|
||||
icon?: ReactNode
|
||||
children?: ReactNode
|
||||
className?: string
|
||||
title?: string
|
||||
type?: 'button' | 'submit' | 'reset'
|
||||
onClick?: AntButtonProps['onClick']
|
||||
}
|
||||
|
||||
type ButtonProps = CommonProps & ButtonHTMLAttributes<HTMLButtonElement> & { href?: undefined }
|
||||
type AnchorProps = CommonProps & AnchorHTMLAttributes<HTMLAnchorElement> & { href: string }
|
||||
/** 语义变体 → antd 的 type / ghost / danger 三轴。映射只在这里做一次。 */
|
||||
function mapVariant({ variant = 'secondary', on, danger }: { variant?: ButtonVariant; on?: boolean; danger?: boolean }) {
|
||||
if (on) return { type: 'primary' as const, ghost: true, danger: false }
|
||||
switch (variant) {
|
||||
case 'primary': return { type: 'primary' as const, ghost: false, danger: !!danger }
|
||||
case 'outline': return { type: 'default' as const, ghost: false, danger: !!danger }
|
||||
case 'ghost': return { type: 'text' as const, ghost: false, danger: !!danger }
|
||||
case 'add': return { type: 'dashed' as const, ghost: false, danger: false }
|
||||
case 'del': return { type: 'text' as const, ghost: false, danger: true }
|
||||
case 'link': return { type: 'link' as const, ghost: false, danger: !!danger }
|
||||
default: return { type: 'default' as const, ghost: false, danger: !!danger }
|
||||
}
|
||||
}
|
||||
|
||||
const SIZES: Record<ButtonSize, 'small' | 'middle' | 'large'> = { sm: 'small', md: 'middle', lg: 'large' }
|
||||
|
||||
export const Button = forwardRef<HTMLButtonElement, Common & Record<string, any>>(function Button({
|
||||
variant = 'secondary', size, danger, on, square, loading, disabled, block,
|
||||
icon, children, className, title, type = 'button', onClick, ...rest
|
||||
}, ref) {
|
||||
const v = mapVariant({ variant, on, danger })
|
||||
return (
|
||||
<AntButton
|
||||
{...rest}
|
||||
ref={ref}
|
||||
type={v.type}
|
||||
ghost={v.ghost}
|
||||
danger={v.danger}
|
||||
size={size ? SIZES[size] : undefined}
|
||||
loading={loading}
|
||||
disabled={disabled}
|
||||
block={block}
|
||||
icon={icon}
|
||||
className={className}
|
||||
title={title}
|
||||
htmlType={type}
|
||||
onClick={onClick}
|
||||
>
|
||||
{children}
|
||||
</AntButton>
|
||||
)
|
||||
})
|
||||
|
||||
/**
|
||||
* 按钮的样式计算单独拿出来:<Link> / <NavLink> 这类「看起来是按钮的站内链接」
|
||||
* (模型迁移入口、空状态里的「去创建」)复用同一份配方,
|
||||
* 而不是再抄一遍类名 —— 抄的那份永远不会跟着变体调整。
|
||||
* 路由跳转用的按钮:antd Button 的 href 会整页刷新,这里换成 router 的 navigate,
|
||||
* 同时保留 <a> 的「右键新开 / 复制链接」语义(修饰键点击不被拦截)。
|
||||
*/
|
||||
export function buttonCls(opt: CommonProps & { variant?: ButtonVariant } = {}) {
|
||||
const { variant = 'secondary', size = 'md', square, danger, on, className } = opt
|
||||
return cn(
|
||||
BASE,
|
||||
VARIANTS[variant as ButtonVariant],
|
||||
size !== 'md' && SIZES[size as ButtonSize],
|
||||
square && 'w-(--ctl-h) px-0 text-ui',
|
||||
danger && variant === 'outline' && 'text-danger-bright border-danger-line hover:not-disabled:bg-danger-tint-2',
|
||||
danger && variant === 'ghost' && 'text-danger-bright border-danger-line',
|
||||
danger && variant === 'del' && 'bg-danger border-danger text-danger-ink shadow-raise',
|
||||
on && 'border-accent-line bg-accent-tint text-accent-bright',
|
||||
className
|
||||
export const LinkButton = forwardRef<HTMLButtonElement, Common & { to: string; state?: any }>(
|
||||
function LinkButton({ to, children, state, ...rest }, ref) {
|
||||
const navigate = useNavigate()
|
||||
return (
|
||||
<Button
|
||||
ref={ref}
|
||||
{...rest}
|
||||
component="a"
|
||||
href={to}
|
||||
onClick={(e: any) => {
|
||||
if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return
|
||||
e.preventDefault()
|
||||
navigate(to, { state })
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Button>
|
||||
)
|
||||
})
|
||||
|
||||
/** 纯图标按钮:label 同时喂给 title 与 aria-label,页面不会再漏掉无障碍名 */
|
||||
export const IconButton = forwardRef<HTMLButtonElement, Common & { icon: ReactNode; label: string }>(
|
||||
function IconButton({ icon, label, ...rest }, ref) {
|
||||
return <Button ref={ref} {...rest} icon={icon} square title={rest.title || label} aria-label={label} />
|
||||
})
|
||||
|
||||
/**
|
||||
* 顶栏工具按钮:图标 + 文字,窄屏自动收成方块(文字进 <span> 就被隐掉)。
|
||||
*
|
||||
* 症状:顶栏「手册 / 主题」两颗原来各自写在同一条页面私有常量 TOOL 上,
|
||||
* 登录页右上角那颗主题按钮又抄了第三份(少了图标位、圆角换成 tile)。
|
||||
* 它们既不是 antd 的 default 也不是 text——顶栏在深底上,要的是
|
||||
* 「和 PipelineConsole 同高的胶囊位」,标准控件组里没有这一档。
|
||||
* 做法:皮肤收进 kit,语义只留两个:href 渲染 <a>(右键可新开),
|
||||
* onClick 渲染 <button>。高度仍写 --ctl-h,不自造变量名。
|
||||
*/
|
||||
const TOOL = 'group flex h-(--ctl-h) flex-none items-center justify-center gap-1.5 rounded-tile '
|
||||
+ 'border border-line bg-transparent px-[9px] text-body font-semibold text-ink-3 '
|
||||
+ 'whitespace-nowrap no-underline hover:border-line-bright hover:bg-hover hover:text-ink '
|
||||
+ 'max-nav:justify-center max-nav:w-(--ctl-h) max-nav:px-0 max-nav:[&>span]:hidden'
|
||||
|
||||
export function ToolButton({ children, href, onClick, className, title, ariaLabel, target }: {
|
||||
children: ReactNode
|
||||
/** 给 href 就是导航(可右键新开),否则是一颗按钮 */
|
||||
href?: string
|
||||
onClick?: () => void
|
||||
className?: string
|
||||
title?: string
|
||||
ariaLabel?: string
|
||||
target?: string
|
||||
}) {
|
||||
const cls = cn('nex-tool cursor-pointer', TOOL, className)
|
||||
if (href) {
|
||||
return (
|
||||
<a href={href} target={target} rel={target === '_blank' ? 'noopener' : undefined}
|
||||
className={cls} title={title} aria-label={ariaLabel}>{children}</a>
|
||||
)
|
||||
}
|
||||
return <button type="button" onClick={onClick} className={cls} title={title} aria-label={ariaLabel}>{children}</button>
|
||||
}
|
||||
|
||||
export const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps | AnchorProps>(
|
||||
function Button({ variant = 'secondary', size = 'md', square, danger, on, className, children, ...rest }: any, ref) {
|
||||
const classes = buttonCls({ variant, size, square, danger, on, className })
|
||||
/* ref 是「按钮或链接」的联合类型,到这里没法收窄,交给 DOM 元素自己判断 */
|
||||
const nodeRef = ref as Ref<any> | undefined
|
||||
if (rest.href !== undefined) {
|
||||
return <a ref={nodeRef} className={classes} {...(rest as AnchorProps)}>{children}</a>
|
||||
}
|
||||
return <button ref={nodeRef} type="button" className={classes} {...(rest as ButtonProps)}>{children}</button>
|
||||
}
|
||||
)
|
||||
/**
|
||||
* 24px 方形图标位:贴在文字行内的单个图标动作(密钥明文切换这类)。
|
||||
*
|
||||
* 症状:它不能抬到 31px——眼睛图标挨着一行 19px 高的密钥文字,
|
||||
* 抬到控件档会把整行顶开,反而更像两个东西。
|
||||
* 做法:整站「比控件小一号的图标热区」只有这一只,24px 由体检器按标记类放行
|
||||
* (EXPECTED 里那条 nex-icon-spot),页面不再手写 w-6 h-6 + 六条 hover 类。
|
||||
* active 给「当前正显示明文」这种命中态,无障碍名同时进 title 与 aria-label。
|
||||
*/
|
||||
export function IconSpot({ children, label, onClick, active, disabled, className }: {
|
||||
children: ReactNode
|
||||
/** 同时喂给 title 与 aria-label:图标按钮不会再没有名字 */
|
||||
label: string
|
||||
onClick?: () => void
|
||||
active?: boolean
|
||||
disabled?: boolean
|
||||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<button type="button" onClick={onClick} disabled={disabled} title={label} aria-label={label} aria-pressed={active}
|
||||
className={cn('nex-icon-spot grid place-items-center w-6 h-6 flex-none shrink-0 p-0 rounded-control '
|
||||
+ 'cursor-pointer border border-line bg-raise text-ink-3 hover:text-ink hover:border-line-strong '
|
||||
+ 'disabled:opacity-60 disabled:cursor-progress',
|
||||
active && 'text-accent-bright border-accent-line bg-accent-tint-2', className)}>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
/**
|
||||
* 勾选框:Ant Design 5 Checkbox 的唯一封装。
|
||||
*
|
||||
* 症状:卡片墙 / 表格行首的勾选框原来是手写的——尺寸靠 accent-color 染系统控件,
|
||||
* 31px 高的行里它只有 16px,键盘 Space 能切但点标签不生效,深色主题下还是个白底方块。
|
||||
* 做法:本体是 antd Checkbox,尺寸/圆角/描边全部来自 theme/antd.ts 的 Checkbox token。
|
||||
* props 同时兼容几种写法,页面迁移时不必改逻辑:
|
||||
* · onChange(next: boolean) —— 受控 + 直接给布尔值(表单字段用这个)
|
||||
* · onCheckedChange(next) —— 原 headless 时代的名字(残留调用)
|
||||
* · onClick(event) —— 要 shift 范围选 / 阻止冒泡的卡片墙用这个
|
||||
* 受控时永远挂一个 onChange:antd 内部是真实 <input type=checkbox>,
|
||||
* 只给 checked 不给 onChange 会被 React 判定成只读并发告警。
|
||||
*/
|
||||
import type { MouseEvent, ReactNode } from 'react'
|
||||
import { Checkbox as AntCheckbox } from 'antd'
|
||||
|
||||
export type CheckboxProps = {
|
||||
checked?: boolean | 'indeterminate'
|
||||
disabled?: boolean
|
||||
className?: string
|
||||
title?: string
|
||||
'aria-label'?: string
|
||||
children?: ReactNode
|
||||
onClick?: (e: MouseEvent<HTMLLabelElement>) => void
|
||||
/** 布尔版受控回调 */
|
||||
onChange?: (next: boolean) => void
|
||||
/** 兼容原 headless 命名 */
|
||||
onCheckedChange?: (next: boolean) => void
|
||||
}
|
||||
|
||||
export function Checkbox({ checked, onChange, onCheckedChange, children, ...rest }: CheckboxProps) {
|
||||
return (
|
||||
<AntCheckbox
|
||||
{...rest}
|
||||
checked={checked === 'indeterminate' ? false : !!checked}
|
||||
indeterminate={checked === 'indeterminate'}
|
||||
onChange={(e) => {
|
||||
onCheckedChange?.(e.target.checked)
|
||||
onChange?.(e.target.checked)
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</AntCheckbox>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,273 +1,196 @@
|
|||
import { createContext, useContext } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Checkbox } from '../primitives'
|
||||
import { Select } from '../forms/Select'
|
||||
import { TAG_DENSE } from './Status'
|
||||
|
||||
/**
|
||||
* 控件栏体系(docs/UI规范.md §1~§5 的唯一实现)。
|
||||
* 控件栏与字段体系(docs/UI规范.md §1~§5 的唯一实现)。
|
||||
*
|
||||
* 症状:筛选栏 / 工具条 / 抽屉字段里「标签在上、控件在下」,一个字段吃掉整行;
|
||||
* 同一行搜索框 38、下拉 31、复选框 16,中心线各走各的;chip 行贴住下方面板。
|
||||
* 做法:布局只在这几个组件里定义,页面只给内容——
|
||||
* <Ctlbar> 含控件的横条(一行、垂直居中、紧凑高度、下边距 12)
|
||||
* <Field> 行内标签字段(标签在左、控件在右;grow / wide / narrow 调宽)
|
||||
* <BarRight> 需要右靠的一组控件(替代写在控件上的 margin-left:auto)
|
||||
* <ChipBar> chip 行(与下方内容强制呼吸 12px)
|
||||
* <FormGrid> 表单级栅格作用域:一个表单只在这里定义一次列边界(12 等分)
|
||||
* <FormRow> 表单里的一行(有 FormGrid 时按跨格数落位,没有时 auto-fit 自己降列)
|
||||
* 症状(用户截图里那些):筛选栏 / 抽屉字段「标签在上、控件在下」,一个字段吃掉整行;
|
||||
* 同一行搜索框 38、下拉 31、复选框 16,中心线各走各的;标签列宽随中文标题字数漂移。
|
||||
* 做法:布局与档位只在这几个组件里定义,页面只给内容——
|
||||
* <Ctlbar> 含控件的横条:一行、垂直居中、紧凑档、下边距 12
|
||||
* <Field> 标签在左、控件在右的字段(标签列宽由容器统一给)
|
||||
* <FieldBlock> 标签在上的长字段
|
||||
* <FormGrid> 表单作用域:列边界 + 标签列宽只在这里定义一次(12 等分)
|
||||
* <FormRow> 表单里的一行(cols = 这行几个字段)
|
||||
* <ChipBar> 可点筛选胶囊行
|
||||
* <Pager> 分页条(page_size 唯一的家)
|
||||
* 高度一律不写在控件上:容器把 --ctl-h 压到紧凑档,行内控件跟着一起降。
|
||||
* <Check> <FilePick> 复选、文件选择
|
||||
* 高度不写在控件上:容器同时做两件事——CSS 侧压 --ctl-h 档,
|
||||
* antd 侧用 <ConfigProvider componentSize> 下发 small,两条路同一个数。
|
||||
*/
|
||||
import { createContext, useContext, type ReactNode } from 'react'
|
||||
import { ConfigProvider, Checkbox as AntCheckbox, Pagination } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Button } from './Button'
|
||||
import { Select } from '../forms/Select'
|
||||
import { fieldGroupLabelCls, LABEL_CLS } from './field-labels'
|
||||
|
||||
/** 行内字段标签的唯一尺子:Field 与 Slider 共用,抽屉里两种字段的标题必须量出同一个字号 */
|
||||
export const LABEL_CLS = 'flex flex-row items-center gap-1.5 m-0 text-muted text-tiny tracking-[.3px] whitespace-nowrap'
|
||||
const LABEL = LABEL_CLS
|
||||
/** 字段行内标签(标签在左):文字本身不拉伸,否则被挤成两行 */
|
||||
const LABEL_CHILD = '[&>label]:flex [&>label]:flex-row [&>label]:items-center [&>label]:gap-1.5 [&>label]:m-0 '
|
||||
+ '[&>label]:text-muted [&>label]:text-tiny [&>label]:tracking-[.3px] [&>label]:whitespace-nowrap'
|
||||
export { LABEL_CLS }
|
||||
|
||||
/**
|
||||
* 字段内部的排布:控件的宽度靠 base.css 的 w-full + flex 收缩填满标签右侧,
|
||||
* **不给 flex-1**。因为 <FormRow stack> 会把字段翻成纵向 flex,
|
||||
* flex-1 的 flex-basis:0% 会接管高度——同一抽屉里 input 被拉到 46px、
|
||||
* 旁边那行又是 38px,就是用户截图中「第一行明显更高」的根因。
|
||||
* 紧凑档作用域:工具条 / 分页条 / 卡片动作行里所有 antd 控件降一档(31px)。
|
||||
* 页面不需要、也不准再给单个控件写 size。
|
||||
*/
|
||||
const FIELD_INNER = '[&>*]:min-w-0 [&_span:first-child]:flex-none [&_[role=checkbox]]:flex-none [&_[role=radio]]:flex-none'
|
||||
|
||||
export function Ctlbar({ children, className, as: As = 'div' }: { children: ReactNode; className?: string; as?: any }) {
|
||||
export function Dense({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return (
|
||||
<As className={cn('[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center flex-wrap gap-y-2 gap-x-[10px] min-w-0 mb-3',
|
||||
'[&>*]:min-w-0', LABEL_CHILD, className)}>
|
||||
{children}
|
||||
</As>
|
||||
<ConfigProvider componentSize="small">
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)]', className)}>{children}</div>
|
||||
</ConfigProvider>
|
||||
)
|
||||
}
|
||||
|
||||
/** 卡片内部的动作行:布局同 Ctlbar,但不带 12px 下边距(否则卡片里凭空多一段空白) */
|
||||
/** 含控件的横条:一行垂直居中,标签挨着控件(--label-w 压回 0) */
|
||||
export function Ctlbar({ children, className, as: As = 'div' }: {
|
||||
children: ReactNode; className?: string; as?: any
|
||||
}) {
|
||||
return (
|
||||
<Dense className={cn('nex-ctlbar', className)}>
|
||||
<As className="nex-ctlbar-inner">{children}</As>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
||||
/** 卡片内部的动作行:布局同 Ctlbar,但不带 12px 下边距 */
|
||||
export function CardActions({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return (
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center flex-wrap gap-y-2 gap-x-[10px] min-w-0 [&>*]:min-w-0', className)}>
|
||||
{children}
|
||||
</div>
|
||||
<Dense className="contents">
|
||||
<div className={cn('nex-card-actions', className)}>{children}</div>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
||||
/** 需要右靠的一组控件(替代写在控件上的 margin-left:auto) */
|
||||
export function BarRight({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('ml-auto flex items-center gap-2 flex-wrap min-w-0', className)}>{children}</div>
|
||||
return <div className={cn('nex-barright', className)}>{children}</div>
|
||||
}
|
||||
|
||||
type FieldWidth = 'default' | 'grow' | 'narrow' | 'wide' | 'full'
|
||||
const WIDTHS: Record<FieldWidth, string> = {
|
||||
default: 'basis-[170px] shrink grow-0',
|
||||
grow: 'basis-[240px] grow shrink',
|
||||
narrow: 'basis-[122px] shrink grow-0',
|
||||
/** .wide = 「宽字段」而不是「吃满整行」:1360px 抽屉里的下拉会撑到整行 89% */
|
||||
wide: 'basis-[330px] grow shrink max-w-[min(460px,58%)]',
|
||||
full: 'basis-full grow shrink'
|
||||
default: 'nf-w-default', grow: 'nf-w-grow', narrow: 'nf-w-narrow', wide: 'nf-w-wide', full: 'nf-w-full'
|
||||
}
|
||||
|
||||
/**
|
||||
* 行内标签字段:`<Field label="类型">…</Field>`;stack 场景交给 <FormRow stack> 统一翻向。
|
||||
* title 挂在外层 label 上:整块(标签 + 控件)都是悬停热区,和旧站 .fld[title] 一致。
|
||||
* 行内字段:标签在左、控件在右。
|
||||
*
|
||||
* 标签列宽(对齐的关键):标签是 flex-none + nowrap,宽度就是文字本身,
|
||||
* 于是「显示名」的输入框比「角色」右移 14px——同一张表单里每条控件的左边缘都不同。
|
||||
* 现在标签至少占 --label-w:表单栅格(FormRow)把它抬到 --field-label-w=66px,
|
||||
* 同行同列共用一条控件左边界;筛选条这类贴边排版的容器把它压回 0px(保持老样子)。
|
||||
* 只给下限不给上限:超过 66px 的长标题(「覆盖负面提示词(可选)」)宁可把控件顶右,
|
||||
* 也不截断标题。宽度是量出来的,见 tokens.css --field-label-w。
|
||||
*
|
||||
* ⚠️ 下限必须写在**容器**上(`[&>span:first-child]`),不能只写在标签 span 自己那句
|
||||
* `min-w-(--label-w)` 里:同一个 Field 还带着 `[&>*]:min-w-0`(让长控件能收缩),
|
||||
* 它编译成 `.min-w-0 > *`,和 `.min-w-\(--label-w\)` 同为 0-1-0 特指度,
|
||||
* 而 Tailwind 把 `min-w-0` 排在自定义值之后 → 后者赢,标签的 66px 下限被无声清零。
|
||||
* /account 的「登录名 30.9 / 邮箱 20.6 / 当前密码 41.2」就是这么来的。
|
||||
* `span:first-child` 多一个伪类(0-2-1)才压得住;span 上那句留着,是为了
|
||||
* 让脱离 Field 复用 LABEL_CLS 的地方也有同一个下限。
|
||||
* 「标题与控件对齐」的唯一机制是标签列宽:同一张表单里所有字段的标签列共用
|
||||
* `--label-w`(FormGrid 抬到 66px,Ctlbar 压回 0),只给下限不给上限——
|
||||
* 比 66px 长的中文标题宁可把控件顶右,也不截断标题。
|
||||
*/
|
||||
export function Field({ label, required, children, width = 'default', className, hint, title }: {
|
||||
label?: ReactNode; required?: boolean; children: ReactNode; width?: FieldWidth; className?: string; hint?: ReactNode
|
||||
title?: string
|
||||
label?: ReactNode; required?: boolean; children: ReactNode; width?: FieldWidth
|
||||
className?: string; hint?: ReactNode; title?: string
|
||||
}) {
|
||||
return (
|
||||
<label title={title} data-full={width === 'full' ? '' : undefined}
|
||||
className={cn(LABEL, FIELD_INNER, WIDTHS[width], 'min-w-0',
|
||||
// 标签列宽的下限(写法原因见上面的 ⚠️):只有真的传了 label 才加,
|
||||
// 否则无标签字段的第一个 span 会被当成标签列撑到 66px。
|
||||
label && '[&>span:first-child]:min-w-(--label-w)',
|
||||
// 带 hint 的字段翻成两列栅格:标签在左上、控件在右上、说明贴在控件下面。
|
||||
// 不能只是 flex-wrap——base.css 里控件是 w-full,一换行控件就被整体挤到第二行,
|
||||
// 标签跑回上面,同一栅格里就成了「一个横排、两个竖排」的混排(规范 R3)。
|
||||
hint && 'grid grid-cols-[minmax(var(--label-w),max-content)_minmax(0,1fr)]', className)}>
|
||||
{label && <span className="flex-none min-w-(--label-w)">{label}{required && <Req />}</span>}
|
||||
{children}
|
||||
{hint && (
|
||||
<span className="col-start-2 w-full pt-[3px] text-faint text-tiny leading-[1.5] font-normal tracking-[0]">
|
||||
{hint}
|
||||
</span>
|
||||
)}
|
||||
<label title={title} className={cn('nex-field', WIDTHS[width], hint && 'nf-has-hint', className)}>
|
||||
{label && <span className="nf-label">{label}{required && <Req />}</span>}
|
||||
<span className="nf-ctl">{children}</span>
|
||||
{hint && <span className="nf-hint">{hint}</span>}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
|
||||
/** 必填星号:和标签文字同一个 flex item,否则列方向 label 会把「*」顶到下一行 */
|
||||
/** 必填星号:和标签文字同一个 flex item,否则列方向会把「*」顶到下一行 */
|
||||
export function Req() {
|
||||
return <b className="text-danger font-bold ml-[2px]">*</b>
|
||||
return <b className="nf-req">*</b>
|
||||
}
|
||||
|
||||
/** 长字段(标签在上):抽屉/对话框里的多行文本、上传区用这个 */
|
||||
export function FieldBlock({ label, required, children, className, title }: {
|
||||
/** 长字段(标签在上):抽屉 / 对话框里的多行文本、上传区用这个 */
|
||||
export function FieldBlock({ label, required, children, className, title, hint }: {
|
||||
label?: ReactNode; required?: boolean; children: ReactNode; className?: string
|
||||
/** 标签的含义/后果说明(分镜的检查器里几乎每个长字段都要一句),与 Field 保持一致 */
|
||||
title?: string
|
||||
/** 标签的含义/后果说明:分镜检查器里几乎每个长字段都要一句 */
|
||||
title?: string; hint?: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<label title={title} className={cn('[--ctl-h:var(--ctl-h-main)] [--label-w:0px] flex flex-col gap-[5px] mb-[10px] min-w-0', className)}>
|
||||
<span className="flex items-center gap-1 text-muted text-tiny tracking-[.3px] flex-wrap whitespace-nowrap">
|
||||
{label}{required && <Req />}
|
||||
</span>
|
||||
{children}
|
||||
<label title={title} className={cn('nex-field-block', className)}>
|
||||
{label && <span className="nf-label nf-label-stack">{label}{required && <Req />}</span>}
|
||||
<span className="nf-ctl">{children}</span>
|
||||
{hint && <span className="nf-hint">{hint}</span>}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 12 列基准栅格:整个表单的列边界只在这里定义一次。
|
||||
* 表单作用域:列边界与标签列宽只在这里定义一次。
|
||||
*
|
||||
* 病灶(用户说的「字段标题不对齐」):轨道以前写在每条 FormRow 自己身上,
|
||||
* 模型抽屉里「模型身份」那行 cols={3}、「并发/RPM」那行 cols={4},
|
||||
* 同宽的两行列边界差了 110px,标题看着就是斜的。
|
||||
* 现在基准取 12 等分(2/3/4/6 都能整除),FormRow 的 cols 退化成
|
||||
* 「这一行放几个字段」= 每个字段跨 12/cols 格,任何一行都对齐同一套线。
|
||||
*
|
||||
* 没有 FormGrid 的孤立 FormRow 走原来的 auto-fit 路径,全站不必一次性改写;
|
||||
* 只要一个表单里出现两行列数不同,就必须用 FormGrid 包起来。
|
||||
*
|
||||
* 它是「布局作用域」而不是又一个盒子:只发 context,不加 DOM,
|
||||
* 所以能在不改动缩进结构、不新增一层 div 的前提下套住整个抽屉表单。
|
||||
* 病灶:轨道以前写在每条 FormRow 自己身上,同一个抽屉里两行不同 cols
|
||||
* 的字段列边界差了 110px,标题看着就是斜的。基准取 12 等分(2/3/4/6 都能整除),
|
||||
* FormRow 的 cols 退化成「这一行放几个字段」= 每字段跨 12/cols 格。
|
||||
*/
|
||||
const FormGridCtx = createContext<{ gapX: string; gapY: string } | null>(null)
|
||||
/** FormGrid 作用域标记:FormRow 靠它决定用 12 等分基准栅格还是 auto-fit */
|
||||
const FormGridCtx = createContext(false)
|
||||
|
||||
export function FormGrid({ children, gap = 'loose' }: {
|
||||
children: ReactNode; gap?: 'loose' | 'tight'
|
||||
export function FormGrid({ children, className, cols = 12, labelWidth }: {
|
||||
children: ReactNode; className?: string; cols?: number
|
||||
/**
|
||||
* 标签列宽(px)。默认不锁:minmax(66, max-content) 让超长标题把那一格控件顶右。
|
||||
* 抽屉里字段多、标题长短不一时传一个数(例如 92)把上下限锁死,
|
||||
* 整表严格对齐,超长标题自动折行——对齐优先于单行。
|
||||
*/
|
||||
labelWidth?: number
|
||||
}) {
|
||||
const spec = gap === 'tight' ? { gapX: 'gap-x-[8px]', gapY: 'gap-y-[8px]' }
|
||||
: { gapX: 'gap-x-[10px]', gapY: 'gap-y-[8px]' }
|
||||
return <FormGridCtx.Provider value={spec}>{children}</FormGridCtx.Provider>
|
||||
const style: Record<string, string | number> = { '--form-cols': cols }
|
||||
if (labelWidth) {
|
||||
const w = `${labelWidth}px`
|
||||
style['--label-w'] = w
|
||||
style['--label-max'] = w
|
||||
}
|
||||
return (
|
||||
<FormGridCtx.Provider value>
|
||||
<div className={cn('nex-form', className)} style={style as any}>{children}</div>
|
||||
</FormGridCtx.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 每行字段数 → 跨格数 + 窄屏降列。
|
||||
* 降列的档位沿用原来的规则:3/4 列在 mid 以下两列、6 列在 nav 以下两列,2 列不降。
|
||||
* cols 省略(原来靠 auto-fit 猜列数)在基准栅格里按每行 4 个字段处理——
|
||||
* 栅格必须有一个确定的列数,这正是「轨道写在行上」会被消灭的原因。
|
||||
*
|
||||
* 两个「占满整行」的例外,否则长文本字段会在 12 格里被压成一小截:
|
||||
* :only-child —— 整行只有一个字段(审核台那种一行一项),铺满;
|
||||
* width="full" —— 字段自己声明占满(Field 挂 data-full)。
|
||||
* 表单里的一行。
|
||||
* 有 FormGrid 时按跨格数落位(cols 只决定「这行几个字段」);
|
||||
* 没有 FormGrid 时 auto-fit 自己降列(孤立一行筛选字段的场合)。
|
||||
*/
|
||||
// 注意:这些类名必须原样写成字面量。Tailwind 扫的是源码文本,
|
||||
// 用模板字符串把 col-span-${n} 拼出来,产物 CSS 里根本不会有那条规则(踩过)。
|
||||
const SPAN_FULL = '[&>[data-full]]:col-span-full [&>:only-child]:col-span-full'
|
||||
const LATTICE: Record<number, string> = {
|
||||
2: '[&>*:not([data-full]):not(:only-child)]:col-span-6 '
|
||||
+ 'max-mid:[&>*:not([data-full]):not(:only-child)]:col-span-12 ' + SPAN_FULL,
|
||||
3: '[&>*:not([data-full]):not(:only-child)]:col-span-4 '
|
||||
+ 'max-mid:[&>*:not([data-full]):not(:only-child)]:col-span-6 ' + SPAN_FULL,
|
||||
4: '[&>*:not([data-full]):not(:only-child)]:col-span-3 '
|
||||
+ 'max-mid:[&>*:not([data-full]):not(:only-child)]:col-span-6 ' + SPAN_FULL,
|
||||
6: '[&>*:not([data-full]):not(:only-child)]:col-span-2 '
|
||||
+ 'max-nav:[&>*:not([data-full]):not(:only-child)]:col-span-6 ' + SPAN_FULL
|
||||
}
|
||||
|
||||
/**
|
||||
* 短字段栅格:列边界来自 <FormGrid>;stack 把标签退回控件上方。
|
||||
*
|
||||
* 表单容器显式声明自己是主尺寸(38px):抽屉/对话框里的字段永远同一档,
|
||||
* 不会因为外面套了一层紧凑档工具条(Ctlbar / ChipBar / 抽屉动作条)
|
||||
* 就整排缩水成 31px——一个容器只有一个 --ctl-h 档位。
|
||||
* 同理在这里抬 --label-w:标签列宽是「表单才需要」的规则,
|
||||
* 由行作用域下发,页面永远不必自己写宽度。
|
||||
*/
|
||||
export function FormRow({ children, cols, tight, stack, className }: {
|
||||
export function FormRow({ children, cols = 3, className, tight, stack }: {
|
||||
children: ReactNode
|
||||
/** 这一行放几个字段;在 FormGrid 里 = 每个字段跨 12/cols 格 */
|
||||
/** 这一行放几个字段(FormGrid 里 = 每字段跨 12/cols 格);脱离 FormGrid 时忽略 */
|
||||
cols?: 2 | 3 | 4 | 6
|
||||
/** 更紧的一行(仅脱离 FormGrid 时生效,基准栅格里间距由表单统一) */
|
||||
tight?: boolean
|
||||
stack?: boolean
|
||||
className?: string
|
||||
/**
|
||||
* 更紧的一行。**在 FormGrid 里只收纵向呼吸**,列间距留在表单基准上;
|
||||
* 脱离 FormGrid 的孤立行(auto-fit)才两个方向一起收。
|
||||
* 别把它当「间距降一档」用:12 等分基准栅格里一改 column-gap,
|
||||
* 列线就按「前面已经过了几条轨道」累计漂移,同一个抽屉里两行的第二列控件错开 2px。
|
||||
*/
|
||||
tight?: boolean
|
||||
/** 标签退回控件上方:长标题字段、代码/路径类输入用它 */
|
||||
stack?: boolean
|
||||
}) {
|
||||
const grid = useContext(FormGridCtx)
|
||||
const shared = '[--ctl-h:var(--ctl-h-main)] [--label-w:var(--field-label-w)] grid mb-[10px] min-w-0 [&>*]:min-w-0 '
|
||||
// 每个字段贴到自己格子的顶端:否则带 hint 的字段把行撑高之后,
|
||||
// 旁边没 hint 的字段会被垂直居中,同一行三个输入框错开半行(规范 R3)。
|
||||
+ '[&>*]:self-start '
|
||||
// 这里必须显式 [&>*]:flex:带 hint 的字段自己是 grid,
|
||||
// grid 元素不认 flex-direction,不覆盖就会在 stack 栅格里漏掉竖排。
|
||||
+ (stack ? 'gap-y-[10px] [&>*]:flex [&>*]:flex-col [&>*]:items-stretch [&>*]:gap-[5px] [&>*]:w-auto [&>*:not(span)]:w-full' : '')
|
||||
if (grid) {
|
||||
// 间距也归 FormGrid 统管:基准 12 格下只要列间距换一个数,
|
||||
// 每条列线就整体漂移(实测 10→8px 时最后一格偏 1.7px),对齐又是假的。
|
||||
// 所以基准栅格里 tight 只影响纵向,横向密度由表单说了算。
|
||||
return (
|
||||
<div className={cn(shared, 'grid-cols-12', grid.gapX, grid.gapY, LATTICE[cols ?? 3], className)}>
|
||||
// 在 FormGrid 里走 12 等分基准;孤立一行交给 auto-fit 自己降列(窄屏不会挤成一列宽)
|
||||
const inGrid = useContext(FormGridCtx)
|
||||
return (
|
||||
<div className={cn('nex-form-row', inGrid ? 'nf-row-grid' : 'nf-row-auto',
|
||||
inGrid && `nf-cols-${cols}`, stack && 'nf-stack', tight && 'nf-tight', className)}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 可点的筛选胶囊行(与下方内容强制呼吸 12px);只读回显一律走 TagGroup */
|
||||
export function ChipBar({ children, label, className, top }: {
|
||||
children: ReactNode; label?: ReactNode; className?: string; top?: boolean
|
||||
}) {
|
||||
return (
|
||||
<Dense className={cn('contents')}>
|
||||
<div className={cn('nex-chipbar', top && 'mt-3', className)}>
|
||||
{label && <span className={fieldGroupLabelCls}>{label}</span>}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const tracks = cols === undefined ? 'repeat(auto-fit,minmax(190px,1fr))'
|
||||
: cols === 6 ? 'repeat(6,minmax(78px,1fr))'
|
||||
: `repeat(${cols},minmax(0,1fr))`
|
||||
return (
|
||||
<div className={cn(shared,
|
||||
// 间距照旧站 .frow(gap: 8px 10px):列间 10px 是「标签在左」不贴到上一格控件的地板,
|
||||
// 之前这里只在 tight 时给 gap,非 tight 档位间距为 0,窄屏上「镜号」几乎贴着上一格的输入框。
|
||||
tight ? 'gap-[8px]' : 'gap-x-[10px] gap-y-[8px]',
|
||||
cols === undefined && 'max-mid:grid-cols-2',
|
||||
(cols === 3 || cols === 4) && 'max-mid:grid-cols-2',
|
||||
(cols === 4 || cols === 6) && 'max-nav:grid-cols-2',
|
||||
className)}
|
||||
style={{ gridTemplateColumns: tracks }}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** chip / 标签行(规范 §2):与下方内容强制呼吸 12px */
|
||||
export function ChipBar({ children, label, className, top }: { children: ReactNode; label?: ReactNode; className?: string; top?: boolean }) {
|
||||
return (
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center gap-1.5 flex-wrap mb-3 min-w-0', top && 'mt-3', className)}>
|
||||
{label && <span className="flex-none text-muted text-tiny tracking-[.6px] font-bold">{label}</span>}
|
||||
{children}
|
||||
</div>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选/开关胶囊(.chip):**可点的**东西才属于这一族(31px,与同排按钮等高)。
|
||||
*
|
||||
* 只读回显(计数、能力、状态)不要在这里传 as="span",一律用 Tag / TagGroup:
|
||||
* 一行里 31px 的只读胶囊和 20px 的标签并排,正是「标签样式不统一」最显眼的那处。
|
||||
* as="span" 只留一个例外——文件选择器旁边「已选 xxx.mp3」这种回显,
|
||||
* 它跟着同排那串可点的素材 chip 成组,而不是跟着标签成组。
|
||||
* 筛选 / 开关胶囊:**可点的**东西才属于这一族(与同排按钮等高)。
|
||||
* 只读回显(计数、能力、状态)用 Tag / TagGroup,别在这里装成 span。
|
||||
*/
|
||||
export function Chip({ active, children, onClick, className, title, disabled, as = 'button', href, size = 'md' }: {
|
||||
active?: boolean; children: ReactNode; onClick?: () => void; className?: string; title?: string
|
||||
disabled?: boolean; as?: 'button' | 'a' | 'span'; href?: string; size?: 'md' | 'sm'
|
||||
}) {
|
||||
const classes = cn('inline-flex items-center justify-center border whitespace-nowrap shrink-0 no-underline '
|
||||
+ 'transition-colors duration-150',
|
||||
// sm 档存在的唯一理由:卡片元信息行里「可点的标签」和「只读的标签」必须同高同形,
|
||||
// 而 31px 的默认档会把那一行撑成工具条。尺寸取自标签令牌,不在这儿重复一遍数字。
|
||||
size === 'sm'
|
||||
? cn(TAG_DENSE, 'min-h-(--tag-h) px-(--tag-px) gap-(--tag-gap) [font-size:var(--tag-text)] rounded-chip')
|
||||
: 'h-(--ctl-h-md) px-2 gap-[5px] text-tiny rounded-pill',
|
||||
active ? 'bg-accent-fill border-accent-fill text-on-accent font-bold'
|
||||
: 'bg-raise border-line-strong text-ink-3 hover:bg-active hover:text-ink',
|
||||
disabled && 'opacity-40 cursor-not-allowed', className)
|
||||
const classes = cn('nex-chip', size === 'sm' && 'nex-chip-sm', active && 'is-on', disabled && 'is-off', className)
|
||||
if (as === 'span') return <span title={title} className={classes}>{children}</span>
|
||||
if (as === 'a') return <a href={href} title={title} className={classes}>{children}</a>
|
||||
return <button type="button" title={title} disabled={disabled} onClick={onClick} className={classes}>{children}</button>
|
||||
|
|
@ -278,31 +201,25 @@ export function TagChip({ children, onRemove, className, removeTitle }: {
|
|||
children: ReactNode; onRemove?: () => void; className?: string; removeTitle?: string
|
||||
}) {
|
||||
return (
|
||||
<span className={cn('inline-flex items-center justify-center gap-[5px] h-(--ctl-h-md) px-[9px] text-tiny rounded-pill '
|
||||
+ 'border bg-accent-fill border-accent-fill text-on-accent font-bold whitespace-nowrap shrink-0', className)}>
|
||||
<span className={cn('nex-tag-chip', className)}>
|
||||
{children}
|
||||
{onRemove && (
|
||||
<button type="button" onClick={onRemove} title={removeTitle} aria-label="移除"
|
||||
className="grid place-items-center w-[17px] h-[17px] ml-[5px] p-0 flex-none border-0 rounded-full bg-[color-mix(in_srgb,var(--c-on-accent)_20%,transparent)] text-inherit text-[12px] leading-none hover:bg-danger hover:text-danger-ink">×</button>
|
||||
<button type="button" onClick={onRemove} title={removeTitle} aria-label="移除" className="nex-tag-chip-x">×</button>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页条(规范 §5):page_size 唯一的家,筛选栏里不再出现「每页」。
|
||||
*
|
||||
* 档位默认覆盖表格页的常用宽度;卡片墙这类一格 150px 的网格要的是 24/60/120/全部,
|
||||
* 所以档位开成入参,由页面自己给(sizes 里 0 表示不分页)。
|
||||
* 长文本字段的最小高度:挂在**容器**上(`[&_textarea]`)而不是每个 textarea 上——
|
||||
* 往抽屉里加字段的人不该再记一遍这三条。
|
||||
*/
|
||||
/**
|
||||
* 长文本字段的统一高度(UI规范 §3):抽屉里的提示词 / 描述至少要 86px 才装得下一句完整的话,
|
||||
* 同时允许用户自己继续拉长。
|
||||
* 挂在**容器**上(`[&_textarea]`)而不是每个 textarea 上——往抽屉里加字段的人
|
||||
* 不该再记一遍这三条类名;此前 AssetLibrary 与 Library 各抄了一份,leading 已经写歪。
|
||||
*/
|
||||
export const TEXTAREA_TALL = '[&_textarea]:min-h-[86px] [&_textarea]:resize-y [&_textarea]:leading-[1.65]'
|
||||
export const TEXTAREA_TALL = 'nex-textarea-tall'
|
||||
|
||||
/**
|
||||
* 分页条(规范 §5):page_size 唯一的家,筛选栏里不再出现「每页」。
|
||||
* 档位由页面给(卡片墙要的是 24/60/120/全部;0 表示不分页)。
|
||||
*/
|
||||
const DEFAULT_SIZES = [12, 20, 24, 30, 48, 60, 120]
|
||||
export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra, sizes = DEFAULT_SIZES }: {
|
||||
page: number; pages: number; total?: number; pageSize?: number
|
||||
|
|
@ -310,74 +227,76 @@ export function Pager({ page, pages, total, pageSize, onPageSize, onPage, extra,
|
|||
sizes?: number[]
|
||||
}) {
|
||||
const last = Math.max(1, pages)
|
||||
const opts = sizes.map((n) => ({ value: n, label: String(n || '全部') }))
|
||||
return (
|
||||
<div className="[--ctl-h:var(--ctl-h-md)] [--label-w:0px] flex items-center justify-center gap-[10px] flex-wrap mt-3 text-dim text-tiny">
|
||||
<button type="button" className="h-(--ctl-h-md) px-2 rounded-control border border-line-strong bg-raise text-ink-3 text-body disabled:opacity-35"
|
||||
disabled={page <= 1} onClick={() => onPage(page - 1)}>上一页</button>
|
||||
<span>{page} / {last}{total !== undefined ? ` · 共 ${total} 条` : ''}</span>
|
||||
<button type="button" className="h-(--ctl-h-md) px-2 rounded-control border border-line-strong bg-raise text-ink-3 text-body disabled:opacity-35"
|
||||
disabled={page >= last} onClick={() => onPage(page + 1)}>下一页</button>
|
||||
<Dense className={cn('nex-pager', (total === undefined || total === 0) && !extra && 'hidden')}>
|
||||
<span className="text-caption text-dim">
|
||||
{page} / {last}{total !== undefined ? ` · 共 ${total} 条` : ''}
|
||||
</span>
|
||||
<Pagination current={page} total={Math.max(last * (pageSize || 1), total || 0)} pageSize={pageSize || 12}
|
||||
showSizeChanger={false} onChange={(p) => onPage(p)} size="small" simple />
|
||||
{onPageSize && (
|
||||
<label className="flex items-center gap-1.5 m-0 text-muted text-tiny whitespace-nowrap">
|
||||
<span className="flex-none">每页</span>
|
||||
{/* 分页条是全站最后一个裸 <select>:系统箭头 + 系统弹单,和旁边 31px 的按钮不成一套。
|
||||
换成 forms/Select(同一套 Radix Popover 皮肤);选项最多 8 条,不配过滤框。 */}
|
||||
<span className="inline-flex items-center gap-1.5 text-caption text-dim">
|
||||
每页
|
||||
<Select size="sm" ariaLabel="每页条数" searchThreshold={0} placeholder="全部"
|
||||
value={pageSize} onChange={(v) => onPageSize(Number(v))}
|
||||
className="w-auto min-w-[64px]"
|
||||
options={sizes.map((n) => ({ value: n, label: String(n || '全部') }))} />
|
||||
</label>
|
||||
value={pageSize} onChange={(v: any) => onPageSize(Number(v))}
|
||||
className="w-[72px]" options={opts} />
|
||||
</span>
|
||||
)}
|
||||
{extra}
|
||||
</div>
|
||||
</Dense>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 复选(.check):勾选框 + 文案,整块可点。
|
||||
*
|
||||
* 勾选框本体是 primitives/Checkbox(Radix),不再是 `<input type=checkbox>` + `accent-color`:
|
||||
* 系统控件只有 3px 圆角的绿块能改颜色,形状、描边、三态都改不了,
|
||||
* 和同排的自定义控件并排就是两套东西(模型抽屉的「启用模型」是现场证据)。
|
||||
* 文案留在外层 <label> 里:button 属于 HTML 的 labelable 元素,
|
||||
* 点文字会转成点控件,热区比原来大,同时给控件读出这个名字(不需要再写 aria-label)。
|
||||
*/
|
||||
/** 复选(勾选框 + 文案整块可点):本体是 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
|
||||
checked: boolean; onChange: (next: boolean) => void; children: ReactNode; disabled?: boolean
|
||||
className?: string; title?: string
|
||||
}) {
|
||||
return (
|
||||
<label title={title} className={cn('inline-flex flex-row items-center gap-[7px] text-caption text-ink-3 cursor-pointer flex-none whitespace-nowrap', className)}>
|
||||
<Checkbox checked={checked} disabled={disabled} onCheckedChange={(v) => onChange(v === true)} />
|
||||
<AntCheckbox checked={checked} disabled={disabled} title={title} className={cn('nex-check', className)}
|
||||
onChange={(e) => onChange(e.target.checked)}>
|
||||
{children}
|
||||
</label>
|
||||
</AntCheckbox>
|
||||
)
|
||||
}
|
||||
|
||||
/** 单选组(分段用 antd 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 (
|
||||
<span className={cn('inline-flex flex-wrap items-center gap-x-[14px] gap-y-1 min-w-0', className)}>
|
||||
{options.map((o) => (
|
||||
<AntCheckbox key={String(o.value)} checked={o.value === value} disabled={disabled || o.disabled}
|
||||
onChange={() => onChange(o.value)}>
|
||||
{o.label}
|
||||
</AntCheckbox>
|
||||
))}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件选择(.upload):整块标签就是按钮,点哪里都能开文件对话框。
|
||||
*
|
||||
* 旧站把 <input type=file> 塞进 label 里 display:none,外壳用 padding 自己撑高度,
|
||||
* 结果同一行里 chip 31px、上传 26px、按钮 38px 三种高度混在一起;
|
||||
* 这里并进 --ctl-h 体系,容器决定档位,页面不再调 padding。
|
||||
* 文件选择:整块按钮就是热区,点哪里都开文件对话框。
|
||||
* 选完把 input 清空:否则连着两次选同一个文件 value 没变,onChange 不再触发
|
||||
* (分镜导入要反复试同一份脚本)。
|
||||
*/
|
||||
export function FilePick({ label, accept, multiple, onFiles, className, title }: {
|
||||
export function FilePick({ label, accept, multiple, onFiles, className, title, disabled }: {
|
||||
label: ReactNode; accept?: string; multiple?: boolean; onFiles: (files: File[]) => void; className?: string
|
||||
/** 悬浮说明「选出来的文件会落到哪里」:一页里上传点越多越需要这句话 */
|
||||
title?: string
|
||||
title?: string; disabled?: boolean
|
||||
}) {
|
||||
return (
|
||||
<label title={title} className={cn('inline-flex h-(--ctl-h) flex-row items-center justify-center gap-[5px] m-0 cursor-pointer '
|
||||
+ 'rounded-chip border border-line-strong bg-hover px-[9px] text-tiny leading-[1.2] text-ink-2 '
|
||||
+ 'whitespace-nowrap shrink-0 hover:bg-raise hover:text-ink', className)}>
|
||||
{label}
|
||||
{/* 选完就把 input 清空:否则连着两次选同一个文件,input.value 没变,
|
||||
onChange 不再触发,用户以为「没选上」(分镜导入要反复试同一份脚本)。 */}
|
||||
<input type="file" className="hidden" accept={accept} multiple={multiple}
|
||||
<Button variant="secondary" className={className} title={title} disabled={disabled}>
|
||||
<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)
|
||||
}} />
|
||||
</label>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* 文本 / 数值输入:Ant Design 5 Input 的唯一封装。
|
||||
*
|
||||
* 症状:页面里散落着 130 多个裸 `<input>`/`<textarea>`,浏览器默认皮肤
|
||||
* (白底、系统圆角、原生数字步进器)既不吃主题也不吃尺子,
|
||||
* 和同一行里的 antd 下拉差着一整个档位。
|
||||
* 做法:控件一律来自 antd,这里只补三件事——
|
||||
* 1) 事件形状沿用 React 原生(Input/TextArea 的 onChange 仍是 event),
|
||||
* 页面迁移只是把标签换掉,逻辑一行不动;
|
||||
* 2) NumberInput 把 antd 的 (value:number|null) 收窄成页面惯用的数字;
|
||||
* 3) 宽度统一由 .nf-ctl 撑满字段列,页面不再写 w-[...]。
|
||||
*
|
||||
* ref 一律是 **DOM 节点**(HTMLInputElement / HTMLTextAreaElement),不是 antd 的句柄:
|
||||
* React 18 必须 forwardRef,而且页面拿到节点才能 focus / setSelectionRange /
|
||||
* scrollIntoView——契约与理由见 lib/ref.ts。
|
||||
*/
|
||||
import { forwardRef } from 'react'
|
||||
import { Input as AntInput, InputNumber } from 'antd'
|
||||
import { SearchOutlined } from '@ant-design/icons'
|
||||
import { domInput, domTextarea, passRef } from '../../lib/ref'
|
||||
|
||||
const { TextArea: AntTextArea, Search: AntSearch } = AntInput
|
||||
|
||||
/** 单行文本(原生 event 兼容:onChange={(e) => setX(e.target.value)}) */
|
||||
export const Input = forwardRef<HTMLInputElement, React.ComponentProps<typeof AntInput>>(
|
||||
function Input(props, ref) {
|
||||
return <AntInput {...props} ref={(h) => passRef(ref, domInput(h))} />
|
||||
})
|
||||
|
||||
/**
|
||||
* 多行文本。rows 保留:抽屉里的字段高度是排版的一部分,
|
||||
* autoSize 会让同一抽屉的字段随内容长短跳动。
|
||||
*/
|
||||
export const TextArea = forwardRef<HTMLTextAreaElement, React.ComponentProps<typeof AntTextArea>>(
|
||||
function TextArea(props, ref) {
|
||||
return <AntTextArea {...props} ref={(h) => passRef(ref, domTextarea(h))} />
|
||||
})
|
||||
|
||||
/**
|
||||
* 数值输入:antd 的数字框(步进按钮在框内,不再露出系统控件)。
|
||||
*
|
||||
* 「清空」这件事有两种语义,页面原先就是这么用的,所以拆成两个组件而不是一个开关:
|
||||
* · NumberInput 清空 = 回到 min(没有 min 就 0)——表单里的步数、fps、RPM 这类必填数;
|
||||
* · MaybeNumberInput 清空 = null——「留空表示不改 / 未设置」(分镜批量改时长、字幕起止 ms)。
|
||||
* 两个都把外来的字符串数字折成 number(接口经常回 "5"),页面拿到的一定是自己要的形态。
|
||||
*/
|
||||
export const NumberInput = forwardRef<HTMLInputElement, NumProps<number>>(function NumberInput(
|
||||
{ value, onChange, min, max, step, ...rest }, ref) {
|
||||
return (
|
||||
<InputNumber
|
||||
{...rest}
|
||||
ref={(h) => passRef(ref, domInput(h))}
|
||||
value={toNum(value)}
|
||||
min={numOrUndef(min)}
|
||||
max={numOrUndef(max)}
|
||||
step={numOrUndef(step)}
|
||||
onChange={(next: number | string | null) => {
|
||||
const n = toNum(next)
|
||||
onChange?.(n === null ? (numOrUndef(min) ?? 0) : n)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
/** 清空即 null:这一格留空=不改这个字段 */
|
||||
export const MaybeNumberInput = forwardRef<HTMLInputElement, NumProps<number | null>>(
|
||||
function MaybeNumberInput({ value, onChange, min, max, step, ...rest }, ref) {
|
||||
return (
|
||||
<InputNumber
|
||||
{...rest}
|
||||
ref={(h) => passRef(ref, domInput(h))}
|
||||
value={toNum(value)}
|
||||
min={numOrUndef(min)}
|
||||
max={numOrUndef(max)}
|
||||
step={numOrUndef(step)}
|
||||
onChange={(next: number | string | null) => onChange?.(toNum(next))}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
const toNum = (v: unknown): number | null => {
|
||||
if (v === null || v === undefined || v === '') return null
|
||||
const n = Number(v)
|
||||
return Number.isNaN(n) ? null : n
|
||||
}
|
||||
const numOrUndef = (v?: number | string) => (v === undefined || v === '' ? undefined : Number(v))
|
||||
|
||||
type NumProps<Out> = {
|
||||
/** 表单状态里数字经常是字符串(接口回 "5"),进来宽容 */
|
||||
value?: number | string | null
|
||||
onChange?: (next: Out) => void
|
||||
min?: number | string
|
||||
max?: number | string
|
||||
step?: number | string
|
||||
} & Omit<React.ComponentProps<typeof InputNumber>, 'value' | 'onChange' | 'min' | 'max' | 'step'>
|
||||
|
||||
/** 搜索框:放大镜 + 一键清空,行为与 Input 一致(回车提交由页面自己接 onPressEnter) */
|
||||
export const SearchInput = forwardRef<HTMLInputElement, React.ComponentProps<typeof AntSearch>>(
|
||||
function SearchInput(props, ref) {
|
||||
return <AntSearch allowClear prefix={<SearchOutlined />} {...props}
|
||||
ref={(h) => passRef(ref, domInput(h))} />
|
||||
})
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
* 下拉菜单:Ant Design 5 Dropdown 的唯一出口。
|
||||
*
|
||||
* 症状:菜单原来是 primitives/Menu(Radix)+ 自己拼的面板,页面里另一批菜单又是
|
||||
* div + useOutsideClick——同一种「点开一个浮层」有两套行为,Tab 会跑到菜单背后。
|
||||
* 做法:焦点圈定、Esc、外点关闭、portal 全交给 antd Dropdown,皮肤来自 theme/antd.ts
|
||||
* 的 Dropdown token;面板内容照旧由调用方自己排(头像块、角色徽标都是业务信息)。
|
||||
* 为什么要在这一层转一道:`import 'antd'` 只允许出现在 theme/、app/providers.tsx
|
||||
* 与 components/{ui,forms} 里(§0.6),页面只认这里给出的名字。
|
||||
*/
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { Dropdown } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Button } from './Button'
|
||||
|
||||
export const Menu = Dropdown
|
||||
export type MenuProps = React.ComponentProps<typeof Dropdown>
|
||||
|
||||
/**
|
||||
* 导出菜单:一颗按钮 + 标准下拉列出格式。
|
||||
*
|
||||
* 病灶:分镜 / 时间线把「Markdown ↗ CSV ↗ JSON ↗」三个下载链接直接摊在筛选条右边,
|
||||
* 它们的字号、下划线、热区高度和同一排的下拉按钮不是一个族,
|
||||
* 加第四种格式时又得再抄一个链接。
|
||||
* 做法:菜单项、键盘、外点关闭全部交给 antd Dropdown(见 §0.6),
|
||||
* 点击走同一个下载器;页面只登记「格式名 + 取文件的接口」。
|
||||
*/
|
||||
export function ExportMenu({ label = '导出', items, size, className }: {
|
||||
label?: React.ReactNode; className?: string; size?: 'sm' | 'md'
|
||||
items: { label: React.ReactNode; href: string; hint?: string }[]
|
||||
}) {
|
||||
return (
|
||||
<Dropdown trigger={['click']}
|
||||
menu={{
|
||||
items: items.map((it) => ({ key: it.href, label: it.label, title: it.hint })),
|
||||
onClick: ({ key }) => {
|
||||
const a = document.createElement('a')
|
||||
a.href = key
|
||||
a.download = ''
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
a.remove()
|
||||
}
|
||||
}}>
|
||||
<Button variant="outline" size={size} className={className}>{label} ▾</Button>
|
||||
</Dropdown>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 浮层面板里的一行。
|
||||
*
|
||||
* 症状:账号面板用 antd Dropdown 的浮层壳(阴影 / 圆角 / 焦点都来自 token),
|
||||
* 但里面每一行还是页面自己写的 ITEM 类名 + 裸 <button>/<NavLink> 各一套,
|
||||
* 「退出登录」甚至要手写 border-0 bg-transparent 才能像一行菜单。
|
||||
* 做法:菜单项这一族收进 kit——导航给 to,外链给 href,动作给 onClick,
|
||||
* 三种渲染路径共用同一条 32px 行高与 hover 皮肤;danger 只表达「会丢会话」。
|
||||
*/
|
||||
const MENU_ITEM = 'flex min-w-0 items-center gap-[7px] rounded-control px-[7px] py-[6px] '
|
||||
+ 'text-body text-ink-2 no-underline hover:bg-hover hover:text-ink'
|
||||
|
||||
export function MenuRow({ children, icon, to, href, onClick, danger, title, className }: {
|
||||
children: React.ReactNode
|
||||
/** 行首图标位(纯装饰,缺了它文字会贴左边) */
|
||||
icon?: React.ReactNode
|
||||
/** 站内导航(走 router,不整页刷新) */
|
||||
to?: string
|
||||
href?: string
|
||||
onClick?: () => void
|
||||
/** 会丢掉当前会话 / 当前编辑内容 */
|
||||
danger?: boolean
|
||||
title?: string
|
||||
className?: string
|
||||
}) {
|
||||
const body = (
|
||||
<>
|
||||
{icon !== undefined && <i aria-hidden="true" className="w-[14px] flex-none text-center not-italic">{icon}</i>}
|
||||
<span className="min-w-0">{children}</span>
|
||||
</>
|
||||
)
|
||||
const cls = cn(MENU_ITEM, danger && 'cursor-pointer border-0 bg-transparent text-left hover:bg-danger-tint hover:text-danger', className)
|
||||
if (to) return <NavLink to={to} title={title} className={cls}>{body}</NavLink>
|
||||
if (href) return <a href={href} title={title} className={cls}>{body}</a>
|
||||
return <button type="button" onClick={onClick} title={title} className={cls}>{body}</button>
|
||||
}
|
||||
|
||||
/** 面板内的分隔线(一行一条,别写 my-3 各自发挥) */
|
||||
export function MenuDivider() {
|
||||
return <span className="my-[5px] block h-px bg-line-soft" />
|
||||
}
|
||||
|
||||
/**
|
||||
* 面板里的一行说明(告警语气):不常驻,只在真有问题时冒出来。
|
||||
* 给 to 就整行可点(「初始密码还没改,点此设置」这类要跳走的提示),
|
||||
* 页面不必再套一层 Link + 一块自己拼的黄色底。
|
||||
*/
|
||||
export function MenuNote({ children, to, onClick, className }: {
|
||||
children: React.ReactNode; to?: string; onClick?: () => void; className?: string
|
||||
}) {
|
||||
const cls = cn('block w-full min-w-0 px-[7px] pb-[3px] text-left text-tiny leading-[1.5] '
|
||||
+ 'text-warn-bright no-underline [overflow-wrap:anywhere]', className)
|
||||
if (to) return <NavLink to={to} onClick={onClick} className={cls}>{children}</NavLink>
|
||||
if (onClick) return <button type="button" onClick={onClick} className={cls}>{children}</button>
|
||||
return <small className={cls}>{children}</small>
|
||||
}
|
||||
|
|
@ -1,54 +1,45 @@
|
|||
import { useId, type ReactNode } from 'react'
|
||||
import { DialogPortal, DialogRoot, ModalContent, Scrim, SheetContent } from '../primitives/Dialog'
|
||||
import { Drawer as AntDrawer, Modal as AntModal } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Button } from './Button'
|
||||
|
||||
/**
|
||||
* 浮层:抽屉(右滑全高)与居中模态。
|
||||
* 浮层:Ant Design 5 Drawer / Modal 的唯一封装。
|
||||
*
|
||||
* 旧站每个页面各抄一份 .drawer-backdrop + .drawer + .drawer-x,
|
||||
* 三处 padding、两处宽度、四种关闭条件互不相同;抽屉内控件高度也因此
|
||||
* 各写各的 --ctl-h(历史散落在 MediaLightbox / AssetLibrary / ModelCenter)。
|
||||
* 现在宽度、留白、高度档只在这里有一份,页面只提供内容。
|
||||
*
|
||||
* 行为(焦点圈定、背后滚动锁、Esc、外点关闭、读屏名字)在 primitives/Dialog(Radix),
|
||||
* 这里只剩三段式皮肤与业务参数——页面 API 一个都没变。
|
||||
* 症状:自绘抽屉的遮罩、Esc、焦点返还、滚动锁各写一份,抽屉里再开下拉时
|
||||
* z-index 还会互相压;宽度和内边距靠页面传 Tailwind 类。
|
||||
* 做法:行为(portal / 遮罩 / Esc / 焦点陷阱 / 滚动锁)全交给 antd,
|
||||
* 视觉来自 theme/antd.ts 的 Drawer、Modal token;这里只保留站的语义:
|
||||
* 「标题 + 副标题 + 右上 ✕」的头部、「只有 body 滚」的滚动区、吸底动作条。
|
||||
* 页面继续用 <Drawer title sub actions> / <Modal title footer>,props 不变。
|
||||
*/
|
||||
|
||||
/* ── 抽屉三段式的皮肤(UI规范 §3)────────────────────────────────────────
|
||||
<Drawer> 一处用它们时,类名写死在 JSX 里就够了;分镜「检查器」是第二处:
|
||||
它刻意不做成 Drawer(Drawer 是模态——遮罩会吞掉左边看板的点击、Esc 一按就关,
|
||||
而改分镜要在看板和字段之间来回看),外观却又必须和抽屉一模一样。
|
||||
皮肤抄第二遍,下次调 padding 只会改到一处,另一处慢慢就长歪。
|
||||
所以三段类名提到这里,页面写成 <header className={DRAWER_HEAD}>,
|
||||
结构各留各的(检查器有自己的页签条和逐镜导航),视觉只有一个来源。 */
|
||||
export const DRAWER_HEAD = 'flex-none flex justify-between items-start gap-[14px] p-[20px_24px_15px] '
|
||||
+ 'max-short:p-[20px_14px_15px] border-b border-[--c-bg-emphasis] '
|
||||
+ 'bg-[linear-gradient(120deg,var(--c-bg-raised),var(--c-bg-panel)_55%)]'
|
||||
/** 唯一滚动区:只有 body 滚,标题条与动作条不动 */
|
||||
export const DRAWER_BODY = 'flex-1 min-w-0 overflow-y-auto scrollbar-slim p-[20px_24px_24px] '
|
||||
+ 'max-short:p-[20px_14px_14px] [scrollbar-gutter:stable]'
|
||||
/** 吸底动作条。flex-wrap 不能省:窄屏下按钮挤成一排是溢出,不是折行 */
|
||||
export const DRAWER_ACTIONS = 'flex-none flex flex-wrap items-center gap-2 p-[14px_24px] max-short:p-[14px] '
|
||||
+ 'border-t border-line bg-raised [--ctl-h:var(--ctl-h-md)]'
|
||||
/** 抽屉头部:标题条不滚,副标题解释「这一层在改什么」 */
|
||||
export const DRAWER_HEAD = 'flex flex-col min-w-0 gap-[5px]'
|
||||
/** body 内边距交给 antd token(Drawer.paddingLG),这里只留旧站「窄屏收窄」的一条规则。
|
||||
* `nex-drawer-body` 是给 `scripts/ui/audit.py` 的落点标记:分镜检查器**不是模态**
|
||||
* (它用 DRAWER_* 自拼外壳),探针原来的兜底 scope 是 `main`,而 `<aside>` 在 `main`
|
||||
* 外面——「量过了」其实是把页面又量了一遍,检查器里的 27 个字段一条没测。 */
|
||||
export const DRAWER_BODY = 'nex-drawer-body min-w-0 [scrollbar-gutter:stable]'
|
||||
/** 吸底动作条:flex-wrap 不能省,窄屏下按钮挤成一排是溢出,不是折行 */
|
||||
export const DRAWER_ACTIONS = 'flex flex-wrap items-center gap-2 min-w-0 [--ctl-h:var(--ctl-h-md)]'
|
||||
|
||||
/**
|
||||
* 浮层右上角的 ✕。抽屉、模态、分镜检查器各抄过一份,
|
||||
* 其中模态那份就漏了 hover 描边——同一个动作长三种样子,这里收成一个。
|
||||
* 提示统一带「(Esc)」:浮层一律 Esc 可关(Radix 的 dismissable 层负责),
|
||||
* 别让人去猜。
|
||||
* 浮层右上角的 ✕:标准控件组里的 ghost 方形按钮(与任何一颗行内图标钮同档)。
|
||||
* 提示统一带「(Esc)」:浮层一律 Esc 可关,别让人去猜。
|
||||
*/
|
||||
export function CloseButton({ onClose, label = '关闭' }: { onClose: () => void; label?: string }) {
|
||||
return (
|
||||
<button type="button" aria-label={label} title={`${label}(Esc)`} onClick={onClose}
|
||||
className="flex-none grid place-items-center w-(--ctl-h-md) h-(--ctl-h-md) border border-line-strong rounded-tile bg-card text-ink-2 text-ui hover:border-[--c-accent-deep] hover:text-accent-bright hover:bg-accent-tint">✕</button>
|
||||
)
|
||||
return <Button variant="ghost" size="sm" square aria-label={label} title={`${label}(Esc)`} onClick={onClose}>✕</Button>
|
||||
}
|
||||
|
||||
/** 标题/副标题与面板的关联:Radix 只认 aria-labelledby / aria-label,没有就控制台告警 */
|
||||
function useNames() {
|
||||
const uid = useId()
|
||||
return { titleId: `${uid}-t`, subId: `${uid}-d` }
|
||||
}
|
||||
|
||||
/** 默认宽:表单抽屉吃满视野,只放一块面板的抽屉由页面传更窄的 CSS 宽度 */
|
||||
const DRAWER_WIDE = 'min(1360px, calc(100vw - 20px))'
|
||||
|
||||
export function Drawer({ open, onClose, title, sub, children, actions, width, closeOnBackdrop = true, label }: {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
|
|
@ -57,38 +48,46 @@ export function Drawer({ open, onClose, title, sub, children, actions, width, cl
|
|||
children: ReactNode
|
||||
/** 底部动作条;不传就不渲染这一行 */
|
||||
actions?: ReactNode
|
||||
/** 宽度档:默认 1360px 表单抽屉;只放一块面板的抽屉要窄一些,
|
||||
* 好让左侧列表仍可见(旧站 .gen-drawer 就是 980px),传 Tailwind 宽度类即可 */
|
||||
width?: string
|
||||
/** 宽度(CSS 宽度值,如 980 或 'min(980px, calc(100vw - 64px))');默认 1360 表单抽屉 */
|
||||
width?: number | string
|
||||
closeOnBackdrop?: boolean
|
||||
/** 无障碍名:标题是节点(带 title 属性的 span)时用它补一个纯文本名字 */
|
||||
label?: string
|
||||
}) {
|
||||
const { titleId, subId } = useNames()
|
||||
return (
|
||||
<DialogRoot open={open} onOpenChange={(next) => { if (!next) onClose() }}>
|
||||
<DialogPortal>
|
||||
<Scrim />
|
||||
<SheetContent width={width} closeOnBackdrop={closeOnBackdrop}
|
||||
labelledBy={titleId} describedBy={sub ? subId : undefined}
|
||||
label={typeof label === 'string' ? label : undefined}>
|
||||
<header className={DRAWER_HEAD}>
|
||||
<div className="min-w-0">
|
||||
<h2 id={titleId} className="text-lg font-bold mt-0 mb-0">{title}</h2>
|
||||
{sub && <p id={subId} className="mt-[5px] mb-0 text-tiny text-dim leading-[1.6]">{sub}</p>}
|
||||
</div>
|
||||
<CloseButton onClose={onClose} />
|
||||
</header>
|
||||
<div className={DRAWER_BODY}>
|
||||
{children}
|
||||
</div>
|
||||
{actions && (
|
||||
<footer className={DRAWER_ACTIONS}>
|
||||
{actions}
|
||||
</footer>
|
||||
)}
|
||||
</SheetContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
<AntDrawer
|
||||
className="nex-drawer"
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
placement="right"
|
||||
width={width || DRAWER_WIDE}
|
||||
closable={false}
|
||||
maskClosable={closeOnBackdrop}
|
||||
push={false}
|
||||
// 抽屉里再开下拉/日期面板时,浮层必须挂在抽屉内部才压得住它自己的 body
|
||||
getContainer={false}
|
||||
// ⚠️ 这里只能是 fixed。`getContainer={false}` 让 antd 把抽屉**就地**渲染在页面树里,
|
||||
// 于是 antd 给它的绝对定位相对的是文档而不是视口:窄屏上要点开的按钮几乎都在折叠线以下,
|
||||
// 探针/用户都得先把页面滚下去,抽屉就跟着文档滚到屏幕上方去了
|
||||
//(430px 实测 scrollY=1125 时抽屉 y=-1125,整块在视口外——用户点了「AI 生成」像没反应)。
|
||||
// 六项判据一条都不红:它们量的是元素几何,元素在不在屏幕上没人管。
|
||||
// 现在由 audit 的 surface 闸盯着(在视口内 + 中心点没被别的东西盖住)。
|
||||
rootStyle={{ position: 'fixed' }}
|
||||
title={
|
||||
<div className={DRAWER_HEAD}>
|
||||
<span id={titleId} className="block text-lg font-bold min-w-0" title={typeof label === 'string' ? label : undefined}>
|
||||
{title}
|
||||
</span>
|
||||
{sub && <span id={subId} className="block text-tiny text-dim leading-[1.6] font-normal min-w-0">{sub}</span>}
|
||||
</div>
|
||||
}
|
||||
extra={<CloseButton onClose={onClose} label={typeof label === 'string' ? label : '关闭'} />}
|
||||
footer={actions ? <div className={DRAWER_ACTIONS}>{actions}</div> : null}
|
||||
styles={{ footer: { background: 'var(--ant-color-bg-elevated)', borderColor: 'var(--ant-color-split)', padding: '12px 20px' } }}
|
||||
>
|
||||
<div className={DRAWER_BODY}>{children}</div>
|
||||
</AntDrawer>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -103,26 +102,39 @@ export function Modal({ open, onClose, title, children, footer, width = 560, clo
|
|||
closeOnBackdrop?: boolean
|
||||
label?: string
|
||||
}) {
|
||||
const { titleId, subId } = useNames()
|
||||
const { titleId } = useNames()
|
||||
return (
|
||||
<DialogRoot open={open} onOpenChange={(next) => { if (!next) onClose() }}>
|
||||
<DialogPortal>
|
||||
<Scrim />
|
||||
<ModalContent width={width} closeOnBackdrop={closeOnBackdrop}
|
||||
labelledBy={title ? titleId : undefined} describedBy={subId}
|
||||
label={label}>
|
||||
{title && (
|
||||
<header className="flex-none flex items-center justify-between gap-3 p-[14px_18px] border-b border-[--c-bg-emphasis] bg-[linear-gradient(120deg,var(--c-bg-raised),var(--c-bg-panel)_55%)]">
|
||||
<div className="min-w-0">
|
||||
<h2 id={titleId} className="text-md font-bold m-0">{title}</h2>
|
||||
</div>
|
||||
<CloseButton onClose={onClose} />
|
||||
</header>
|
||||
)}
|
||||
<div id={subId} className="flex-1 min-w-0 overflow-y-auto scrollbar-slim p-[18px] [scrollbar-gutter:stable]">{children}</div>
|
||||
{footer && <footer className="flex-none flex items-center justify-end gap-2 p-[12px_18px] border-t border-line bg-raised [--ctl-h:var(--ctl-h-md)]">{footer}</footer>}
|
||||
</ModalContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
<AntModal
|
||||
className="nex-modal"
|
||||
open={open}
|
||||
onCancel={onClose}
|
||||
width={width}
|
||||
centered
|
||||
closable={false}
|
||||
maskClosable={closeOnBackdrop}
|
||||
footer={footer ? <div className="flex flex-wrap items-center justify-end gap-2 [--ctl-h:var(--ctl-h-md)]">{footer}</div> : null}
|
||||
title={title
|
||||
? <span id={titleId} className="block min-w-0" title={typeof label === 'string' ? label : undefined}>{title}</span>
|
||||
: undefined}
|
||||
styles={{ body: { maxHeight: 'calc(100vh - 240px)', overflowY: 'auto' } }}
|
||||
>
|
||||
{children}
|
||||
</AntModal>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 遮罩:整块盖住页面、点空白处关闭,但**不锁滚动、不吸走焦点**。
|
||||
*
|
||||
* 症状:分镜详情检查器故意不是 Drawer(Drawer 是模态:Esc 关闭 + 锁滚动 + 遮罩吞点击,
|
||||
* 而改分镜要「左边挑镜头、右边改文案」来回看),可它自己写了一个 fixed 满屏 <button>
|
||||
* 当遮罩,皮肤(bg-scrim + backdrop-blur + z-index)是页面私有的第三份。
|
||||
* 做法:遮罩这一层归浮层族管,页面只说「关掉它」和「怎么称呼它」;
|
||||
* 检查器本体仍由页面自己排(它要跟着顶栏高度吸边)。
|
||||
*/
|
||||
export function Scrim({ onClose, label, className }: { onClose: () => void; label: string; className?: string }) {
|
||||
return (
|
||||
<button type="button" aria-label={label} onClick={onClose}
|
||||
className={cn('nex-scrim fixed inset-0 z-[55] cursor-default border-0 bg-scrim backdrop-blur-[2px]', className)} />
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { cn } from '../../lib/cn'
|
|||
/** 次要说明文字(.muted):11px + 最淡的一级灰,表格单元格的第二行、附注都用它 */
|
||||
export const MUTED = 'text-faint text-caption'
|
||||
/** 等宽小字(.mono):路径 / id / 枚举码 / 数值列 */
|
||||
export const MONO = 'font-mono text-[10.5px] tracking-[-.2px]'
|
||||
export const MONO = 'font-mono text-tiny tracking-[-.2px]'
|
||||
/** 弱化 + 等宽(.muted.mono):id、路径、枚举码 */
|
||||
export const MUTED_MONO = `${'text-faint'} ${MONO}`
|
||||
|
||||
|
|
|
|||
|
|
@ -52,17 +52,70 @@ export function SectionTitle({ children, action, className, title }: {
|
|||
)
|
||||
}
|
||||
|
||||
/** 指标卡 */
|
||||
export function Stat({ label, value, hint, className }: { label: ReactNode; value: ReactNode; hint?: ReactNode; className?: string }) {
|
||||
/**
|
||||
* 指标:全站「数字 + 标题」只有这一个写法。
|
||||
*
|
||||
* 病灶:同一个统计数字长出过三套皮肤——概览/仪表盘用这里的卡片、资产库自己写了
|
||||
* 一张带渐变的 MetricCard、分镜顶栏又写了一套更小的 Metric。
|
||||
* 于是「镜头 7」和「母版资产 21」并排一看就是两个产品。
|
||||
* 做法:一个组件两档形态,档位是**参数**不是第二套类名——
|
||||
* card(默认)=页面顶部那排统计卡;inline=sticky 顶栏 / 工具条里的一列小数字。
|
||||
* 给了 onClick 就渲染成 <button>(整张卡是筛选入口,键盘点得动,AS-7),
|
||||
* active 点亮描边 = 「当前这一屏数字就是这个筛选命中的那批」。
|
||||
* 数字一律 tabular-nums:状态每 5 秒轮询一次,行宽不能跟着抖。
|
||||
*/
|
||||
export type StatTone = 'lead' | 'ok' | 'warn' | 'bad'
|
||||
const STAT_TONE: Record<StatTone, string> = {
|
||||
lead: 'text-accent', ok: 'text-success', warn: 'text-warn', bad: 'text-danger'
|
||||
}
|
||||
|
||||
export function Stat({ label, value, hint, className, variant = 'card', tone, active, onClick, title, valueSize = 'num' }: {
|
||||
label: ReactNode; value: ReactNode; hint?: ReactNode; className?: string
|
||||
/** card=页面统计卡;inline=顶栏里的一列小数字 */
|
||||
variant?: 'card' | 'inline'
|
||||
tone?: StatTone
|
||||
/** 命中当前筛选:点亮描边 + 标题 */
|
||||
active?: boolean
|
||||
/** 整张卡是筛选入口(给了就渲染 button) */
|
||||
onClick?: () => void
|
||||
title?: string
|
||||
/**
|
||||
* 数值字号。`num`(默认)给纯数字;`title` 给「这里放的是一段名字而不是数」
|
||||
* 的卡(模型控制台的「当前默认大模型」),否则一个模型名会被撑成整屏最重的东西。
|
||||
*/
|
||||
valueSize?: 'num' | 'title'
|
||||
}) {
|
||||
const toneCls = tone ? STAT_TONE[tone] : ''
|
||||
if (variant === 'inline') {
|
||||
return (
|
||||
<div title={title} className={cn('flex min-w-0 flex-col', className)}>
|
||||
<b className={cn('text-num-sm font-bold leading-[1.1] tabular-nums text-ink', toneCls)}>{value}</b>
|
||||
<small className="mt-[3px] text-tiny tracking-[.6px] text-faint">{label}</small>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const As: any = onClick ? 'button' : 'div'
|
||||
return (
|
||||
<div className={cn('bg-panel border border-line rounded-block p-[18px] min-w-0 max-narrow:p-[13px]', className)}>
|
||||
<As title={title} {...(onClick ? { type: 'button', onClick } : {})}
|
||||
className={cn('nex-stat bg-panel border border-line rounded-block p-[18px] min-w-0 max-narrow:p-[13px] text-left',
|
||||
onClick && 'transition-colors hover:border-accent-line',
|
||||
active && 'border-success-line shadow-[inset_0_0_0_1px_var(--c-success-line)] [&>small:first-child]:text-success',
|
||||
className)}>
|
||||
<small className="block text-muted text-tiny">{label}</small>
|
||||
<b className="block text-num mt-[9px] font-bold max-narrow:text-num-sm break-words">{value}</b>
|
||||
{/* value 里的 <i> 是「次要的一半」(9<i>/47</i> 里的分母、/ 未设置),样式只在这里定义一次 */}
|
||||
<b className={cn('block mt-[9px] font-bold break-words tabular-nums max-narrow:text-num-sm '
|
||||
+ '[&_i]:not-italic [&_i]:font-medium [&_i]:ml-[3px] [&_i]:text-faint [&_i]:text-title',
|
||||
valueSize === 'num' ? 'text-num' : 'text-h2 truncate whitespace-nowrap', toneCls)}>{value}</b>
|
||||
{hint && <small className="block text-faint text-tiny mt-[6px]">{hint}</small>}
|
||||
</div>
|
||||
</As>
|
||||
)
|
||||
}
|
||||
|
||||
/** 顶栏 / 工具条里的一排小指标(分镜、调度那种 sticky 条);卡片栅格请用 StatGrid */
|
||||
export function StatRow({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('flex min-w-0 flex-wrap items-end gap-[22px]', className)}>{children}</div>
|
||||
}
|
||||
|
||||
/* 降列档位写成字面量:Tailwind 按源码里的字符串生成工具类,
|
||||
运行时拼出来的 `max-[${w}px]:grid-cols-${c}` 根本不会被扫描到。 */
|
||||
const STEP_CLS: Record<string, string> = {
|
||||
|
|
@ -99,7 +152,10 @@ export function StatGrid({ children, cols = 4, steps, className }: {
|
|||
export function ProgressBar({ value, bad, className }: { value: number; bad?: boolean; className?: string }) {
|
||||
const pct = Math.max(0, Math.min(100, Number(value) || 0))
|
||||
return (
|
||||
<span className={cn('inline-block h-[5px] bg-active rounded-pill overflow-hidden min-w-[60px] align-middle', className)}>
|
||||
/* block 不是 inline-block:条子经常和下一行的百分比写在同一个 nowrap 单元格里
|
||||
(首页项目表的「进度」列),inline-block + w-full 会和后面的数字排在同一条基线上,
|
||||
整行比单元格宽 25px,「100%」直接被挤出右边界。块级就天然换行。 */
|
||||
<span className={cn('block h-[5px] bg-active rounded-pill overflow-hidden min-w-[60px] align-middle', className)}>
|
||||
<i className={cn('block h-full', bad ? 'bg-danger' : 'bg-accent-fill')} style={{ width: `${pct}%` }} />
|
||||
</span>
|
||||
)
|
||||
|
|
@ -127,7 +183,7 @@ export function Notice({ children, danger, className, onClose }: {
|
|||
}) {
|
||||
if (!children) return null
|
||||
return (
|
||||
<div className={cn('flex items-start gap-2 p-[11px] rounded-[8px] border mb-4 text-[11.5px] leading-[1.6] break-words break-anywhere',
|
||||
<div className={cn('flex items-start gap-2 p-[11px] rounded-tile border mb-4 text-label leading-[1.6] break-words break-anywhere',
|
||||
danger ? 'border-danger-line bg-danger-tint text-danger-bright' : 'border-accent-line bg-accent-tint-2 text-accent-bright',
|
||||
className)}>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
|
|
@ -145,12 +201,12 @@ export function Value({ children, muted, className }: { children: ReactNode; mut
|
|||
}
|
||||
|
||||
export function LineHint({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return <div className={cn('flex items-baseline gap-1.5 text-[10.5px] leading-[1.5] text-warn mt-[6px]', className)}>{children}</div>
|
||||
return <div className={cn('flex items-baseline gap-1.5 text-tiny leading-[1.5] text-warn mt-[6px]', className)}>{children}</div>
|
||||
}
|
||||
|
||||
/** 等宽小字(路径 / id / 枚举码) */
|
||||
export function Mono({ children, className, title }: { children: ReactNode; className?: string; title?: string }) {
|
||||
return <span title={title} className={cn('font-mono text-[10.5px] tracking-[-.2px]', className)}>{children}</span>
|
||||
return <span title={title} className={cn('font-mono text-tiny tracking-[-.2px]', className)}>{children}</span>
|
||||
}
|
||||
|
||||
/** 文字链(.link):导航用 <Link>,这里只给「打开外部资源 / 下载」 */
|
||||
|
|
@ -166,7 +222,7 @@ export function ExtLink({ href, children, className, download }: { href: string;
|
|||
*/
|
||||
export const CARD_ROW = 'flex justify-between gap-3 items-start py-3 min-w-0 '
|
||||
+ 'border-b border-active last:border-b-0 '
|
||||
+ '[&_h4]:m-0 [&_h4]:mb-1 [&_h4]:text-[12.5px] [&_h4]:font-semibold [&_h4]:text-ink '
|
||||
+ '[&_h4]:m-0 [&_h4]:mb-1 [&_h4]:text-body [&_h4]:font-semibold [&_h4]:text-ink '
|
||||
+ '[&_p]:m-[3px]_0 [&_p]:text-caption [&_p]:text-muted [&_p]:leading-[1.55]'
|
||||
|
||||
/** 卡片行(.cardrow):标题 + 说明 + 右侧动作,列表里重复项的统一骨架 */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
/**
|
||||
* 左栏类型导航(.type-rail):「按类别筛这一页」的那一列。
|
||||
*
|
||||
* 症状:430px 手机上资产库左栏里,「人物 / 定妆、造型与角色一致性」这块文字
|
||||
* 实测只有 **16.7px 宽**——一个字一行,竖着排了十一行。体检器报出来的
|
||||
* 只是「溢出 3px」,那是顿号「、」在最窄一行里放不下,是症状不是病。
|
||||
* 真凶是这一列被切成了三格:每格 104px,扣掉内边距 18 + 图标 31 + 两道间距 20
|
||||
* + 右端计数 24,留给标题和说明的只剩 16.7px。
|
||||
* 而这一列在两个页面各抄了一份,抄完就分叉:栏宽 224 vs 236、图标 31 vs 29、
|
||||
* 窄屏列数 3 vs 2、正文 text-ink-2 vs text-ink-3、说明行高 1.35 vs 1.3、
|
||||
* 底部注释内边距 20 vs 19——同一层骨架六种写法,谁都不知道该抄谁。
|
||||
* 做法:整条栏(外壳 + 吸附 + 断点阶梯 + 一行项目的三件套)只住在这里。
|
||||
* 收列不再写死列数,改成 `minmax(200px,1fr)` 自动适配:**200px 是实测下限**
|
||||
* (200 − 内边距 18 − 图标 31 − 间距 20 − 计数 24 = 107px 正文,说明文字刚好
|
||||
* 还能横着读完),到 640px 以下强制单列——手机上满宽一行一条,比并排三列挤成
|
||||
* 竖排汉字好读。3 类、4 类、将来 6 类都不用再改断点。
|
||||
* 为什么不给页面留 className 拼皮肤:这一列的"长什么样"就是它的全部语义;
|
||||
* 页面只需要说「有哪几类、各几个、当前是哪类」,见 UI规范 §0.6。
|
||||
*/
|
||||
import type { ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Tile } from './Tile'
|
||||
|
||||
/**
|
||||
* 页面主栅格:左栏 + 右内容。和 <Rail> 配套使用,栏宽只有这一个数。
|
||||
* (以前 224 / 236 / 190 三个数并存,改一处要记着改另一处。)
|
||||
*/
|
||||
export const RAIL_GRID = 'grid min-w-0 items-start gap-[13px] '
|
||||
+ 'grid-cols-[236px_minmax(0,1fr)] max-mid:grid-cols-[208px_minmax(0,1fr)] '
|
||||
+ 'max-short:grid-cols-1 [&>*]:min-w-0'
|
||||
|
||||
/** 栏外壳:宽屏吸附在左侧,≤820 落回正文上方并自动铺成多列 */
|
||||
export function Rail({ children, className }: { children: ReactNode; className?: string }) {
|
||||
return (
|
||||
<aside className={cn('nex-rail sticky top-[14px] flex flex-col gap-1.5 p-2 min-w-0 '
|
||||
+ 'bg-card border border-line rounded-float '
|
||||
+ 'max-short:static max-short:grid max-short:grid-cols-[repeat(auto-fit,minmax(200px,1fr))] '
|
||||
+ 'max-tiny:grid-cols-1', className)}>
|
||||
{children}
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
||||
/** 计数右端的语义色:只给档位,不给类名——页面说「这批要警示」,颜色由 kit 定 */
|
||||
const COUNT_TONE = { ok: 'text-success', warn: 'text-warn-bright', muted: 'text-ink-3' } as const
|
||||
|
||||
/**
|
||||
* 栏里的一条:图标 + 标题/说明 + 计数。整块可点(点下去 = 切到这一类)。
|
||||
* iconClass 是唯一允许页面传进来的颜色:它承载的是业务身份
|
||||
* (视频模型=sky / 图像模型=warn / 声音模型=pink,卡片头像与栏内共用同一套),
|
||||
* 不是这一行长什么样。
|
||||
*/
|
||||
export function RailItem({ icon, iconClass, label, hint, count, tone = 'ok',
|
||||
active, onClick, title, ariaLabel }: {
|
||||
icon: ReactNode
|
||||
/** 业务身份色(text-accent / text-sky / …),不传就用中性强调色 */
|
||||
iconClass?: string
|
||||
label: ReactNode
|
||||
hint?: ReactNode
|
||||
count?: ReactNode
|
||||
tone?: keyof typeof COUNT_TONE
|
||||
active?: boolean
|
||||
onClick?: () => void
|
||||
title?: string
|
||||
ariaLabel?: string
|
||||
}) {
|
||||
return (
|
||||
<Tile onClick={onClick} active={active} title={title} ariaLabel={ariaLabel}
|
||||
className="text-ink-2">
|
||||
<span className={cn('grid place-items-center w-[31px] h-[31px] flex-none rounded-tile '
|
||||
+ 'bg-line-soft text-md', iconClass || 'text-accent')}>{icon}</span>
|
||||
<span className="min-w-0">
|
||||
<b className="block text-body">{label}</b>
|
||||
{hint && <small className="block mt-[3px] text-dim text-tiny leading-[1.35]">{hint}</small>}
|
||||
</span>
|
||||
{count !== undefined && (
|
||||
<em className={cn('ml-auto not-italic text-h2', COUNT_TONE[tone])}>{count}</em>
|
||||
)}
|
||||
</Tile>
|
||||
)
|
||||
}
|
||||
|
||||
/** 栏底那条分隔说明:窄屏跟着铺满整行(col-span-full 与列数无关,不用再抄一遍列数) */
|
||||
export function RailNote({ children, className, title }: {
|
||||
children: ReactNode; className?: string; title?: string
|
||||
}) {
|
||||
return (
|
||||
<div title={title}
|
||||
className={cn('border-t border-active pt-[19px] pb-[5px] px-[7px] max-short:col-span-full',
|
||||
className)}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,16 +1,14 @@
|
|||
import { type ReactNode } from 'react'
|
||||
import { Slider as AntSlider } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { Slider as RadixSlider } from '../primitives/Slider'
|
||||
import { LABEL_CLS } from './Controls'
|
||||
|
||||
/**
|
||||
* 数值滑杆 + 当前值。
|
||||
* 数值滑杆 + 当前值(字段形态与 <Field> 同一把尺子)。
|
||||
*
|
||||
* 旧站滑杆散在 ModelCenter / Timeline 里各自写 height:5px + accent-color,
|
||||
* 值只出现在 label 里,拖动时看不到反馈。这里把「值」和「尺子」绑在一起。
|
||||
* 滑杆本体是 primitives/Slider(Radix)——原生 `<input type=range>` 只有
|
||||
* 轨道粗细、滑块直径、已填充段全是系统画的(模型抽屉里那根绿色系统滑块),
|
||||
* 命中区也只有 5px,拖动要先瞄准。
|
||||
* 值只出现在 label 里,拖动时看不到反馈;原生 range 的命中区也只有 5px。
|
||||
* 现在本体是 antd Slider(轨道/滑块/键盘/触屏热区都是标准控件组的行为),
|
||||
* 标签列宽仍走 --label-w,于是它和旁边同一列的输入框严格对齐。
|
||||
*/
|
||||
export function Slider({ value, min = 0, max = 1, step = 0.01, onChange, label, hint, format, disabled, className }: {
|
||||
value: number
|
||||
|
|
@ -25,16 +23,16 @@ export function Slider({ value, min = 0, max = 1, step = 0.01, onChange, label,
|
|||
className?: string
|
||||
}) {
|
||||
return (
|
||||
<label className={cn('flex items-center gap-2 min-w-0', className)}>
|
||||
{label && <span className={cn('flex-none min-w-(--label-w)', LABEL_CLS)}>{label}</span>}
|
||||
<RadixSlider value={[value]} min={min} max={max} step={step} disabled={disabled}
|
||||
onValueChange={([next]) => onChange(next)}
|
||||
aria-label={typeof label === 'string' ? label : undefined}
|
||||
className="min-w-0 flex-1" />
|
||||
<b className="flex-none w-[42px] text-right text-body font-mono text-ink-2 tabular-nums">
|
||||
{format ? format(value) : value}
|
||||
</b>
|
||||
{hint && <span className="flex-none text-tiny text-faint">{hint}</span>}
|
||||
<label className={cn('nex-field nf-has-slider', hint && 'nf-has-hint', className)}>
|
||||
{label && <span className="nf-label">{label}</span>}
|
||||
<span className="nf-ctl nf-slider-ctl">
|
||||
<AntSlider value={value} min={min} max={max} step={step} disabled={disabled}
|
||||
tooltip={{ formatter: (v) => (format ? String(format(v ?? 0)) : String(v ?? '')) }}
|
||||
onChange={(next) => onChange(Number(next))}
|
||||
aria-label={typeof label === 'string' ? label : undefined} />
|
||||
<b className="nf-slider-value">{format ? format(value) : value}</b>
|
||||
</span>
|
||||
{hint && <span className="nf-hint">{hint}</span>}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,90 +1,60 @@
|
|||
import type { ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { statusLabel, statusTone } from '../../lib/format'
|
||||
|
||||
/**
|
||||
* 标签体系(docs/UI规范.md §2)。
|
||||
* 标签体系(docs/UI规范.md §2):Tag / Status / Badge 共用一个壳。
|
||||
*
|
||||
* 症状:同一个「这是什么 / 现在到哪」的小方块站内有三套写法——
|
||||
* Tag(text-tiny + py-0.5)、Status(text-tiny + py-[3px] 无边框)、
|
||||
* 以及各页面手抄的 rounded-pill span;同一行里 16/18/21px 混排,
|
||||
* 和旁边的 12px 正文、31px chip 挤在一起,间距全靠页面临场发挥。
|
||||
* 做法:**一个尺寸配方 + 一张色板**,Tag / Status / Badge 共用同一个壳,
|
||||
* 于是三种标签混排也严格等高;成排出现时用 TagGroup 拿到统一间距。
|
||||
* 高度只由 min-height 决定(Tailwind 的 border-box),不写 padding-block:
|
||||
* 写 padding 的话字号一变高度就跟着变,又会回到「三套高度」。
|
||||
* 分工(别再新增第四种):
|
||||
* 症状:同一个「这是什么 / 现在到哪」的小方块站内有三套写法,同一行里 16/18/21px 混排。
|
||||
* 做法:**一套度量(.nex-tag,挂在容器上的 --tag-* 两档)+ 一张色板(theme/palette.ts)**。
|
||||
* 分工(不再新增第四种):
|
||||
* Tag 只读名词标签——「竖屏」「已锁定」这类「它是什么」
|
||||
* Status 只读状态标签——后端状态枚举经 statusTone() 映射成色调
|
||||
* Badge 数字气泡——计数,挂在标题右侧
|
||||
* Chip 可点的筛选 / 开关胶囊(31px,ui/Controls.tsx)
|
||||
* TagChip 可移除的选中态胶囊(多选回显,31px,ui/Controls.tsx)
|
||||
* Chip 可点的筛选 / 开关胶囊(ui/Controls.tsx)
|
||||
*/
|
||||
import type { ReactNode } from 'react'
|
||||
import { Tag as AntTag } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
import { statusLabel, statusTone } from '../../lib/format'
|
||||
import { fieldGroupLabelCls } from './field-labels'
|
||||
|
||||
export type TagSize = 'sm' | 'md'
|
||||
/** 密集档:挂在容器上(表格单元格、TagGroup size="sm"),整片标签一起降 */
|
||||
export const TAG_DENSE = 'nex-tag-dense'
|
||||
|
||||
/**
|
||||
* 密集档。两档的圆角、边框、行高完全相同,只有高度、内边距、间隙和字号不同,
|
||||
* 所以混排仍然同形;sm 给密度高的地方——表格单元格、缩略图角标、一行挤五六个的元信息行。
|
||||
*
|
||||
* 档位是**挂在容器上的 CSS 变量**(同 --ctl-h 的规矩),不是每个标签的类名:
|
||||
* `<TagGroup size="sm">` 或 `<td className={TAG_DENSE}>` 一挂,整片标签一起降,
|
||||
* 往表格里加标签的人不必再记一遍尺寸。单独一个标签要降档就写 size="sm"。
|
||||
*/
|
||||
export const TAG_DENSE = '[--tag-h:var(--tag-h-sm)] [--tag-px:var(--tag-px-sm)] '
|
||||
+ '[--tag-gap:var(--tag-gap-sm)] [--tag-text:var(--tag-text-sm)]'
|
||||
/** 语义色调:每一档对应 palette 里的「文字色 / 底纹 / 描边」三件套,页面不许自己上色 */
|
||||
export type TagTone = 'default' | 'ok' | 'bad' | 'warn' | 'info' | 'accent' | 'mono' | 'pink' | 'sky'
|
||||
|
||||
/**
|
||||
* 尺寸全部来自令牌,标签自己不写 padding-block:高度只由 min-height 决定。
|
||||
*
|
||||
* 字号写成任意属性 `[font-size:var(--tag-text)]` 而不是 `text-(length:--tag-text)`:
|
||||
* tailwind-merge 认为「带任意值的 text-*」可能同时携带行高,会把前面的
|
||||
* `leading-[1.45]` 判成冲突吃掉(DOM 里leading 莫名消失就是这么来的)。
|
||||
*/
|
||||
const SHELL = 'inline-flex items-center align-middle whitespace-nowrap rounded-chip border leading-[1.45] '
|
||||
+ 'min-h-(--tag-h) px-(--tag-px) gap-(--tag-gap) [font-size:var(--tag-text)]'
|
||||
|
||||
/** 语义色(旧站 .tag / .tag.ok / .bad / …):default 是中性名词,色调只给有语义的字段 */
|
||||
export type TagTone = 'default' | 'ok' | 'bad' | 'warn' | 'info' | 'accent' | 'mono'
|
||||
|
||||
const TONES: Record<TagTone, string> = {
|
||||
default: 'bg-line-soft text-ink-3 border-line',
|
||||
ok: 'bg-success-tint text-success border-success-line',
|
||||
bad: 'bg-danger-tint-2 text-danger border-danger-line',
|
||||
warn: 'bg-warn-tint text-warn border-warn-line',
|
||||
info: 'bg-info-tint text-info border-info-line',
|
||||
accent: 'bg-accent-tint text-accent-bright border-accent-line',
|
||||
mono: 'bg-line-soft text-ink-3 border-line font-mono'
|
||||
const TONE_VARS: Record<Exclude<TagTone, 'default' | 'mono'>, string> = {
|
||||
ok: 'success', bad: 'danger', warn: 'warn', info: 'info', accent: 'accent', pink: 'pink', sky: 'sky'
|
||||
}
|
||||
|
||||
export function Tag({ tone = 'default', size = 'md', icon, children, className, title }: {
|
||||
tone?: TagTone
|
||||
size?: TagSize
|
||||
/** 前导图标(文本图标或小 svg),与文字之间是 SIZES 里的固定间隙 */
|
||||
/** 前导图标(小 svg 或文本图标),与文字之间的间隙由 .nex-tag 的 gap 管 */
|
||||
icon?: ReactNode
|
||||
children?: ReactNode
|
||||
children: ReactNode
|
||||
className?: string
|
||||
title?: string
|
||||
}) {
|
||||
const v = TONE_VARS[tone as keyof typeof TONE_VARS]
|
||||
const style = v
|
||||
? { background: `var(--c-${v}-tint)`, borderColor: `var(--c-${v}-line)`, color: `var(--c-${v})` }
|
||||
: undefined
|
||||
return (
|
||||
<span title={title} className={cn(SHELL, size === 'sm' && TAG_DENSE, TONES[tone], className)}>
|
||||
{icon}
|
||||
<AntTag title={title} className={cn('nex-tag', size === 'sm' && 'nex-tag-solo-sm', tone === 'mono' && 'font-mono')}
|
||||
style={style} bordered>
|
||||
{icon && <span className="nex-tag-icon" aria-hidden>{icon}</span>}
|
||||
{children}
|
||||
</span>
|
||||
</AntTag>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态胶囊:从前的 Status 有自己一套无边框、另一个行高的皮肤,
|
||||
* 和 Tag 并排时永远差 2~3px。现在它只剩「枚举 → 色调」这一层语义映射。
|
||||
* 状态胶囊:只剩「后端枚举 → 色调」这一层语义映射,皮肤与 Tag 完全相同。
|
||||
*/
|
||||
export type Tone = 'completed' | 'failed' | 'running' | 'queued' | ''
|
||||
|
||||
const STATUS_TONES: Record<Tone, TagTone> = {
|
||||
completed: 'ok',
|
||||
failed: 'bad',
|
||||
running: 'warn',
|
||||
queued: 'info',
|
||||
'': 'default'
|
||||
completed: 'ok', failed: 'bad', running: 'warn', queued: 'info', '': 'default'
|
||||
}
|
||||
|
||||
export function Status({ value, tone, size, children, className }: {
|
||||
|
|
@ -105,34 +75,32 @@ export function Badge({ children, tone = 'default', size = 'md', className }: {
|
|||
size?: TagSize
|
||||
className?: string
|
||||
}) {
|
||||
const v = TONE_VARS[tone as keyof typeof TONE_VARS]
|
||||
const style = v
|
||||
? { background: `var(--c-${v}-tint)`, borderColor: `var(--c-${v}-line)`, color: `var(--c-${v})` }
|
||||
: undefined
|
||||
return (
|
||||
<span className={cn(SHELL, 'rounded-pill font-semibold', size === 'sm' && TAG_DENSE, TONES[tone], className)}>
|
||||
<AntTag className={cn('nex-tag nex-badge', size === 'sm' && 'nex-tag-solo-sm', className)} style={style} bordered>
|
||||
{children}
|
||||
</span>
|
||||
</AntTag>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签组:一排只读标签(或标签 + 说明文字)的横向流。
|
||||
*
|
||||
* 页面上手抄的 `flex flex-wrap gap-1` 有两种病:gap-1(4px)比标签自己的左右
|
||||
* 内边距还小,两个标签读起来像一个词被劈开;没有下边距时又直接贴住下面的面板。
|
||||
* 这里把「组内 6px、组与下方 12px」定死,行首说明文字用 label(同 ChipBar 的 label)。
|
||||
* 嵌在卡片里不想留 12px 时下边距交给 className="mb-0" 覆盖。
|
||||
* 别和 ChipBar 混用:ChipBar 装**可点**的 chip(31px),TagGroup 装**只读**标签。
|
||||
* 组内 6px、组与下方 12px 定死;size="sm" 让整组降到密集档,
|
||||
* 单个标签不用再写 size。别和 ChipBar 混用:ChipBar 装**可点**的 chip。
|
||||
*/
|
||||
export function TagGroup({ children, label, size, className, top }: {
|
||||
children: ReactNode
|
||||
label?: ReactNode
|
||||
/** sm = 整组标签降到密集档;组内单个标签不用再写 size */
|
||||
size?: TagSize
|
||||
className?: string
|
||||
top?: boolean
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('flex flex-wrap items-center gap-[6px] min-w-0 mb-3',
|
||||
size === 'sm' && TAG_DENSE, top && 'mt-3', className)}>
|
||||
{label && <span className="flex-none text-muted text-tiny tracking-[.6px] font-bold">{label}</span>}
|
||||
<div className={cn('nex-taggroup', size === 'sm' && TAG_DENSE, top && 'mt-3', className)}>
|
||||
{label && <span className={fieldGroupLabelCls}>{label}</span>}
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
import { type ReactNode, type Ref } from 'react'
|
||||
import { forwardRef, type ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 流程节点条里的「一格」(全站唯一一份:WorkflowBar 与项目列表、概览共用)。
|
||||
*
|
||||
* 宽度下限只有 min-w-[96px] 一个:这里不能再挂 min-w-0——cn() 走 tailwind-merge,
|
||||
* 同一个 min-width 组只留最后一个,1280 下节点被压到 10px、序号圆点溢出 6px。
|
||||
* 内部要缩的字段各自带 min-w-0(进度那一行),外层交给 Steps 的 overflow-x-auto 滚动。
|
||||
*
|
||||
* 节点状态口径来自 lib/pipeline.ts:done / active / failed / pending。
|
||||
* 「当前节点」只有 openNode() 一个算法——以前五个地方各算各的,草稿项目会喊
|
||||
* 「当前 · 导出完整视频」,流程全绿之后还在喊最后一个节点名(明明已经交付)。
|
||||
|
|
@ -48,14 +52,14 @@ export function Step({ node, index, current, compact, onClick, className }: {
|
|||
return (
|
||||
<div role="listitem" title={nodeHint(node)} data-current={current ? '1' : undefined}
|
||||
onClick={onClick ? () => onClick(node) : undefined}
|
||||
className={cn('flex-1 basis-[118px] min-w-[96px] bg-panel border rounded-tile p-[9px_10px] relative min-w-0 transition-colors',
|
||||
className={cn('flex-1 basis-[118px] min-w-[96px] bg-panel border rounded-tile p-[9px_10px] relative transition-colors',
|
||||
onClick && 'cursor-pointer',
|
||||
current && 'shadow-[0_0_0_1px_var(--c-accent-line)]',
|
||||
st === 'done' && 'border-success-line bg-raised',
|
||||
st === 'active' && 'border-success-line bg-accent-tint shadow-[inset_0_0_0_1px_var(--c-success-line)]',
|
||||
st === 'failed' && 'border-danger-line bg-panel',
|
||||
st === 'pending' && 'border-[--c-bg-active] opacity-70', className)}>
|
||||
<div className={cn('flex items-center gap-[6px] text-[10.5px]', st === 'done' ? 'text-success' : 'text-ink-3')}>
|
||||
<div className={cn('flex items-center gap-[6px] text-tiny', st === 'done' ? 'text-success' : 'text-ink-3')}>
|
||||
<span className={cn('grid place-items-center w-4 h-4 rounded-full text-tiny flex-none', NUM[st])}>{stepIcon(node.state, index)}</span>
|
||||
<span className="min-w-0 truncate">{nodeProgress(node)}</span>
|
||||
</div>
|
||||
|
|
@ -70,7 +74,7 @@ export function Step({ node, index, current, compact, onClick, className }: {
|
|||
)
|
||||
}
|
||||
|
||||
export function Steps({ nodes, currentKey, compact, onStep, className, id, scrollSmooth, ref }: {
|
||||
export const Steps = forwardRef<HTMLDivElement, {
|
||||
nodes: any[]
|
||||
currentKey?: string
|
||||
compact?: boolean
|
||||
|
|
@ -78,9 +82,10 @@ export function Steps({ nodes, currentKey, compact, onStep, className, id, scrol
|
|||
className?: string
|
||||
id?: string
|
||||
scrollSmooth?: boolean
|
||||
/** 横向滚动容器:WorkflowBar 需要量它、并把当前节点滚进视野 */
|
||||
ref?: Ref<HTMLDivElement>
|
||||
}) {
|
||||
}>(function Steps({ nodes, currentKey, compact, onStep, className, id, scrollSmooth }, ref) {
|
||||
/* ref 指的就是这块横向滚动容器:WorkflowBar 要量它、并把当前节点滚进视野。
|
||||
React 18 里它必须是 forwardRef 的第二参数——写成普通 prop 会静默拿到 undefined
|
||||
(症状见 lib/ref.ts),流程条就再也不跟着当前节点走,编译器一声不吭。 */
|
||||
const list = nodes || []
|
||||
return (
|
||||
<div ref={ref} id={id} role="list"
|
||||
|
|
@ -91,7 +96,7 @@ export function Steps({ nodes, currentKey, compact, onStep, className, id, scrol
|
|||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
/** 流程条底部那一行「已完成 x / y · 当前:xxx」;全绿时不再报最后一个节点名 */
|
||||
export function FlowCaption({ nodes, current, allDone, className }: {
|
||||
|
|
|
|||
|
|
@ -1,46 +1,62 @@
|
|||
import { type ReactNode } from 'react'
|
||||
import { Segmented } from 'antd'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
/**
|
||||
* 分段页签 / 视图切换。
|
||||
* 分段页签:Ant Design 5 Segmented。
|
||||
*
|
||||
* 旧站 .inspector-tabs>button 与 .view-btn 都是裸 button 靠页面 padding 撑高度,
|
||||
* 量出来 32px(两档之外)。这里统一吃 --ctl-h-md,页面只留配色。
|
||||
* 症状:.inspector-tabs>button 与 .view-btn 都是裸 button 靠页面 padding 撑高度,
|
||||
* 量出来 32px(两档之外),选中态每页各配一种绿。
|
||||
* 做法:交给 Segmented——滑块、圆角、字号、键盘左右键都在标准控件组里,
|
||||
* items 的 hint 落到原生 title,count 直接排在标签后面。
|
||||
*/
|
||||
export function Tabs<T extends string>({ value, onChange, items, className }: {
|
||||
export function Tabs<T extends string>({ value, onChange, items, className, block, size = 'sm', ariaLabel }: {
|
||||
value: T
|
||||
onChange: (next: T) => void
|
||||
items: { value: T; label: ReactNode; hint?: string; count?: number }[]
|
||||
className?: string
|
||||
/** 等分铺满一行(分镜检查器四个页签);不给就按内容收宽 */
|
||||
block?: boolean
|
||||
size?: 'sm' | 'md'
|
||||
/** 无障碍名:一排没有文字说明的分段控件必须给 */
|
||||
ariaLabel?: string
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('inline-flex items-center gap-1 flex-wrap p-1 bg-card border border-line rounded-tile [--ctl-h:var(--ctl-h-md)]', className)}>
|
||||
{items.map((it) => {
|
||||
const on = it.value === value
|
||||
return (
|
||||
<button key={it.value} type="button" title={it.hint} onClick={() => onChange(it.value)}
|
||||
className={cn('inline-flex items-center justify-center gap-1 h-(--ctl-h) px-2 rounded-control text-tiny leading-[1.2] border transition-colors',
|
||||
on ? 'bg-accent-fill border-accent-fill text-on-accent font-bold'
|
||||
: 'bg-transparent border-transparent text-ink-3 hover:bg-hover hover:text-ink')}>
|
||||
<Segmented
|
||||
aria-label={ariaLabel}
|
||||
className={cn('nex-segmented', className)}
|
||||
value={value}
|
||||
block={block}
|
||||
size={size === 'md' ? 'middle' : 'small'}
|
||||
onChange={(next) => onChange(next as T)}
|
||||
options={items.map((it) => ({
|
||||
value: it.value as string,
|
||||
title: it.hint,
|
||||
label: (
|
||||
<span className="inline-flex items-center gap-1.5">
|
||||
{it.label}
|
||||
{it.count !== undefined && <span className={cn('text-caption', on ? 'opacity-75' : 'text-faint')}>{it.count}</span>}
|
||||
</button>
|
||||
{it.count !== undefined && <span className="opacity-65">{it.count}</span>}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
}))}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
/** 网格 / 列表视图切换(.view-btn) */
|
||||
export function ViewBtn({ active, onClick, children, title, className }: {
|
||||
active?: boolean; onClick?: () => void; children: ReactNode; title?: string; className?: string
|
||||
/**
|
||||
* 视图切换(网格 / 列表 / 素材墙 / 看板 / 分镜表):和检查器页签同一只 Segmented。
|
||||
*
|
||||
* 病灶:同一个动作在两页各长一套——外面套一个手写的描边小盒子,
|
||||
* 内边距一页 2px 一页 3px,选中态一页实心绿一页淡底,
|
||||
* 加第四个视图(时间线页的「按片段 / 按镜头」)时又得再抄一套盒子。
|
||||
* 做法:分段控件只留一只,滑块、圆角、字号、键盘左右键都在标准控件组里;
|
||||
* 这里只是给它换个语义名字——切视图和切内容页签是同一只控件的两种用法。
|
||||
*/
|
||||
export function ViewSwitch<T extends string>({ value, onChange, items, className, size = 'sm', label = '切换视图', block }: {
|
||||
value: T; onChange: (next: T) => void; className?: string; size?: 'sm' | 'md'
|
||||
block?: boolean; label?: string
|
||||
items: { value: T; label: ReactNode; hint?: string }[]
|
||||
}) {
|
||||
return (
|
||||
<button type="button" title={title} onClick={onClick}
|
||||
className={cn('inline-flex items-center justify-center gap-[5px] h-(--ctl-h-md) px-[9px] rounded-control border text-tiny leading-[1.2]',
|
||||
active ? 'bg-accent-tint border-accent-line text-accent-bright font-bold'
|
||||
: 'bg-raise border-line-strong text-ink-3 hover:bg-active hover:text-ink', className)}>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
return <Tabs value={value} onChange={onChange} items={items} className={className}
|
||||
size={size} block={block} ariaLabel={label} />
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,123 @@
|
|||
/**
|
||||
* 整块热区:点下去是「打开 / 选中一个东西」,而不是一颗控件。
|
||||
*
|
||||
* 症状:这一族以前全是页面自己写的 <button>——左侧类型导航栏两页各抄一份
|
||||
* (内边距一页 11px 一页 12px、选中态一页实心一页淡底)、项目概况折叠条一份、
|
||||
* 总控台执行流水一份、顶栏账号胶囊一份、资源选择卡一份。加第四个入口时没人知道
|
||||
* 该抄谁,于是同一屏里长出五种「会亮的方块」;体检器也被迫给每份私有皮肤写白名单
|
||||
* (^button\.flex\.items-center\.gap-2\.5 这种正则,一改类名就失效)。
|
||||
* 做法:整块热区只有这一只组件,档位按「它待在哪个容器里、按下去发生什么」命名,
|
||||
* 并统一打 nex-tile 标记类——档位是参数,不是第二套类名。
|
||||
* 高度一律 = 内容(bar/pill 例外:它们本来就该与同排控件同高),
|
||||
* 所以体检器按标记类放行这一族,不再按像素白名单。
|
||||
* 为什么不用 antd Button:Button 的高度是死的,Card 没有选中态,
|
||||
* 而这一族的语义恰恰是「热区形状跟着内容走」。
|
||||
* 标准控件组负责「能按的东西」,这只负责「能整块点的信息」(规范 §0.6 的边界)。
|
||||
*/
|
||||
import { forwardRef, type ReactNode } from 'react'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
||||
export type TileVariant = 'item' | 'pick' | 'bar' | 'pill'
|
||||
|
||||
/** 静止态皮肤:它待在哪个容器里,就长成那个容器的样子 */
|
||||
const BASE: Record<TileVariant, string> = {
|
||||
/** 面板 / 列表里的一行:默认透明,悬停才亮(左侧类型导航、执行流水) */
|
||||
item: 'flex min-w-0 items-center gap-2.5 w-full rounded-tile border border-transparent p-[11px_9px] hover:bg-panel',
|
||||
/** 选择网格里的一张紧凑卡:缩略图 + 名称 + 摘要,勾中后整圈描边 */
|
||||
pick: 'flex min-w-0 items-center gap-[9px] w-full rounded-tile border border-line bg-card p-2 text-left hover:border-line-strong',
|
||||
/** 通栏折叠条:与同排控件同高,右端放「展开 / 收起」 */
|
||||
bar: 'flex min-w-0 items-center gap-2 w-full h-(--ctl-h) rounded-tile border border-line-strong bg-panel px-3 text-left hover:border-accent-line hover:bg-card',
|
||||
/** 顶栏账号胶囊 */
|
||||
pill: 'flex min-w-0 items-center gap-2 h-(--ctl-h) rounded-pill border border-line bg-sunken pl-1 pr-2 text-left hover:border-line-bright hover:bg-hover'
|
||||
}
|
||||
|
||||
/** 命中态:这一块的筛选 / 展开 / 勾选正生效 */
|
||||
const ACTIVE: Record<TileVariant, string> = {
|
||||
item: 'bg-raised border-success-line shadow-[inset_3px_0_0_var(--c-accent)]',
|
||||
pick: 'border-accent shadow-[inset_0_0_0_1px_var(--c-accent)]',
|
||||
bar: 'border-accent-line bg-card',
|
||||
pill: 'border-line-bright bg-hover text-ink'
|
||||
}
|
||||
|
||||
export const Tile = forwardRef<HTMLElement, {
|
||||
children: ReactNode
|
||||
/** 皮肤档位:它待在哪个容器里、按下去发生什么 */
|
||||
variant?: TileVariant
|
||||
/** 整块热区的动作;不传就退化成一块静止的信息(类名不变,皮肤可以复用) */
|
||||
onClick?: () => void
|
||||
/** 强制渲染成 <button>:动作由外部注入的触发器(antd Dropdown 的锚点这类) */
|
||||
as?: 'div' | 'button'
|
||||
/** 当前生效(选中的分类、展开的正文、勾中的卡片) */
|
||||
active?: boolean
|
||||
/** 折叠体:给值就写 aria-expanded,键盘用户才知道按下去会发生什么 */
|
||||
expanded?: boolean
|
||||
/** 点开的是菜单(账号胶囊这类) */
|
||||
popup?: boolean
|
||||
className?: string
|
||||
title?: string
|
||||
ariaLabel?: string
|
||||
}>(function Tile({ children, variant = 'item', as, onClick, active, expanded, popup, className, title, ariaLabel }, ref) {
|
||||
const As: any = as || (onClick ? 'button' : 'div')
|
||||
/* ref 透出去是硬要求:顶栏账号胶囊把 Tile 当 antd Dropdown 的触发器,
|
||||
Dropdown 拿不到 ref 就退回 findDOMNode(React 已宣布废弃)。 */
|
||||
return (
|
||||
<As
|
||||
ref={ref}
|
||||
{...(As === 'button' ? { type: 'button', onClick } : {})}
|
||||
aria-expanded={expanded}
|
||||
{...(popup ? { 'aria-haspopup': 'menu' as const } : {})}
|
||||
aria-pressed={active === undefined || As !== 'button' ? undefined : active}
|
||||
title={title}
|
||||
aria-label={ariaLabel}
|
||||
className={cn('nex-tile group cursor-pointer text-ink transition-colors duration-150',
|
||||
BASE[variant], active && ACTIVE[variant],
|
||||
!onClick && as !== 'button' && 'cursor-default', className)}>
|
||||
{children}
|
||||
</As>
|
||||
)
|
||||
})
|
||||
|
||||
/**
|
||||
* 行内动作提示:写在整块热区右端的「展开执行过程」。
|
||||
*
|
||||
* 它读起来像按钮、又点不动(热区是整行),所以不能借 Button 的皮肤——
|
||||
* 那会让同一行出现两个「能按」的信号。这里给一个跟随整行状态发亮的提示位。
|
||||
*/
|
||||
export const TILE_HINT = 'flex-none px-[11px] py-[5px] rounded-pill border border-line-strong bg-raised '
|
||||
+ 'text-ink-2 text-caption font-medium whitespace-nowrap '
|
||||
+ 'transition-[border-color,background,color] duration-150 group-hover:border-accent-line group-hover:text-accent '
|
||||
+ 'group-[[aria-expanded=true]]:border-accent-fill group-[[aria-expanded=true]]:bg-accent-fill group-[[aria-expanded=true]]:text-on-accent'
|
||||
|
||||
/**
|
||||
* 折叠行:外框(状态色)+ 整行热区 + 展开体。
|
||||
*
|
||||
* 症状:总控台的执行流水把这三层拆着写——外框一个 div 管三种边框状态、
|
||||
* 行内一个裸 <button> 自带 11 条类名、展开体再一个 div,
|
||||
* 「有动静」的黄色描边和「展开了」的灰描边各写一处,别的日志流想复用只能整段抄。
|
||||
* 做法:三层收进一只组件,状态(open / live)是参数;行的排布(可折行、元素垂直居中)
|
||||
* 也归这里,页面只排内容。
|
||||
*/
|
||||
export function DisclosureRow({ open, live, onToggle, header, children, className, title }: {
|
||||
open?: boolean
|
||||
/** 后台正在跑这一条:边框提前变黄,不展开也知道有动静 */
|
||||
live?: boolean
|
||||
/** 点整行的动作;不传就只是一块静止信息(例如历史归档里的旧流水) */
|
||||
onToggle?: () => void
|
||||
header: ReactNode
|
||||
children?: ReactNode
|
||||
className?: string
|
||||
/** 整行的动作说明:默认给「这条记录」,页面可以说到多具体(「这条指令的执行过程」) */
|
||||
title?: string
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('group mt-[5px] min-w-0 rounded-tile border transition-colors duration-150',
|
||||
open ? 'border-line-strong bg-raised' : live ? 'border-warn-line' : 'border-transparent hover:border-line hover:bg-raised',
|
||||
className)}>
|
||||
<Tile expanded={open} onClick={onToggle} title={`${open ? '收起' : '展开'}${title || '这条记录'}`}
|
||||
className="flex-wrap gap-y-[5px] p-[8px_9px] text-tiny text-muted hover:bg-transparent [&>*]:self-center">
|
||||
{header}
|
||||
</Tile>
|
||||
{open && children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* 字段标签的字号/颜色档位(与 styles/app.css 里的 .nf-label 同一份配方)。
|
||||
*
|
||||
* 为什么只有类名没有样式:控件的皮肤全部在 antd token 与 app.css 里,
|
||||
* 这里只导出「页面自己写 <label> 时该挂哪个类」,避免又长出一套行内样式。
|
||||
*/
|
||||
|
||||
/** 行内字段标签(挂在 .nex-field 的标签列上,或页面手写的 <label> 上) */
|
||||
export const LABEL_CLS = 'nf-label'
|
||||
/** 标签在上的字段标签 */
|
||||
export const LABEL_STACK_CLS = 'nf-label nf-label-stack'
|
||||
/** 分组说明(ChipBar / TagGroup 行首那句「筛选:」) */
|
||||
export const fieldGroupLabelCls = 'nf-group-label'
|
||||
/** 只读回显的值(与标签同行时保持同一基线) */
|
||||
export const valueCls = 'nf-value'
|
||||
|
|
@ -1,11 +1,16 @@
|
|||
export * from './Button'
|
||||
export * from './Input'
|
||||
export * from './Checkbox'
|
||||
export * from './Status'
|
||||
export * from './Panel'
|
||||
export * from './Page'
|
||||
export * from './Controls'
|
||||
export * from './Table'
|
||||
export * from './Overlay'
|
||||
export * from './Menu'
|
||||
export * from './Steps'
|
||||
export * from './Rows'
|
||||
export * from './Tabs'
|
||||
export * from './Tile'
|
||||
export * from './Rail'
|
||||
export * from './Slider'
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ export * from './use-async'
|
|||
export * from './use-polling'
|
||||
export * from './use-local-storage'
|
||||
export * from './use-auto-refresh'
|
||||
export * from './use-narrow'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* 窄屏(触摸档)判定:和 theme/css-vars.ts 注入的那条 `@media (max-width:560px)` 同一个断点。
|
||||
*
|
||||
* 为什么非要有这个 hook:控件高度有两条落地路径——
|
||||
* 自绘区域读 CSS 变量(media query 自己会切档);
|
||||
* antd 控件读 ThemeConfig 里的 JS 数字(media query 管不到)。
|
||||
* 只在 CSS 侧切档的话,手机上一屏会同时出现 36/40(自绘)和 31/38(antd)两把尺子——
|
||||
* 这是 430/560 首跑体检量出来的 61 项。所以断点要在 JS 里再判一次,把触摸档喂给 antd。
|
||||
* 两边都从 metrics.breakpoints.narrow / metrics.controlHeight 取数,值不重复定义。
|
||||
*/
|
||||
import { useEffect, useState } from 'react'
|
||||
import { breakpoints } from '../theme/metrics'
|
||||
|
||||
const QUERY = `(max-width:${breakpoints.narrow}px)`
|
||||
|
||||
/** 当前视口是否落在触摸档(≤560px)内 */
|
||||
export function useNarrow(): boolean {
|
||||
const [narrow, setNarrow] = useState(() => window.matchMedia(QUERY).matches)
|
||||
useEffect(() => {
|
||||
const mq = window.matchMedia(QUERY)
|
||||
const sync = () => setNarrow(mq.matches)
|
||||
sync()
|
||||
mq.addEventListener('change', sync)
|
||||
return () => mq.removeEventListener('change', sync)
|
||||
}, [])
|
||||
return narrow
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* 浮层查询:自绘浮层(灯箱)需要知道「上面还压着一层 antd 浮层吗」。
|
||||
*
|
||||
* 症状:分镜检查器里打开下拉时按 Esc,本应只关掉下拉,结果整层抽屉一起没了。
|
||||
* 做法:Esc 之类的快捷键先问这一句,有人就什么都不做。
|
||||
* 为什么查 DOM 而不是 React 状态:antd 的下拉/日期面板挂在 portal 里,
|
||||
* 页面拿不到它们的 open 状态;而它们一定会在自己的节点上留下 open/hidden 类名。
|
||||
*/
|
||||
const OPEN_LAYER = [
|
||||
'.ant-drawer-open',
|
||||
'.ant-modal-wrap:not(.ant-modal-hidden)',
|
||||
'.ant-select-dropdown:not(.ant-select-dropdown-hidden)',
|
||||
'.ant-cascader-dropdown:not(.ant-dropdown-hidden)',
|
||||
'.ant-dropdown:not(.ant-dropdown-hidden)',
|
||||
'.ant-popover:not(.ant-popover-hidden)',
|
||||
'.ant-tooltip:not(.ant-tooltip-hidden)'
|
||||
].join(',')
|
||||
|
||||
export function floatingLayerOpen(root: ParentNode = document): boolean {
|
||||
return !!root.querySelector(OPEN_LAYER)
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* kit 组件的 ref 契约:**只交真实 DOM 节点,不交组件库的句柄**。
|
||||
*
|
||||
* 症状:前端从 React 19 降到 18 之后,四处 `<X ref={...}>` 静默失效——
|
||||
* React 19 允许函数组件把 ref 当普通 prop 收,React 18 必须走 forwardRef,
|
||||
* 编译器不报错(`ref?: Ref<T>` 写在 props 里照样通过),只在运行时打一句
|
||||
* 「Function components cannot be given refs」。代价是:
|
||||
* 登录页不再自动聚焦用户名、分镜「✎ 改文案」不再滚到描述框、
|
||||
* 控制台复用指令不再定位光标、流程条不再把当前节点滚进视野。
|
||||
* 做法:kit 组件一律 forwardRef;组件库句柄(antd 的 InputRef / TextAreaRef 这些)
|
||||
* 在 kit 内部用 passRef 折成 DOM 节点再交出去。
|
||||
* 为什么只给 DOM 节点:页面要做的就是 focus / select / setSelectionRange /
|
||||
* scrollIntoView,全是 DOM 的事;把 antd 的句柄类型漏给页面,
|
||||
* 页面就得 import 组件库的类型,那是 §0.6 的硬边界(R8)明令禁止的。
|
||||
*/
|
||||
import type { Ref } from 'react'
|
||||
|
||||
/** 把值写进调用方的 ref(对象 ref 与回调 ref 都吃) */
|
||||
export function passRef<T>(ref: Ref<T> | undefined, node: T | null) {
|
||||
if (typeof ref === 'function') ref(node)
|
||||
else if (ref) (ref as { current: T | null }).current = node
|
||||
}
|
||||
|
||||
/** antd Input / InputNumber 的句柄 → 里面那颗 <input> */
|
||||
export const domInput = (h: any): HTMLInputElement | null =>
|
||||
h?.input ?? (h?.nativeElement?.querySelector?.('input') ?? null)
|
||||
|
||||
/** antd TextArea 的句柄 → 里面那颗 <textarea> */
|
||||
export const domTextarea = (h: any): HTMLTextAreaElement | null =>
|
||||
h?.resizableTextArea?.textArea ?? h?.nativeElement?.querySelector?.('textarea') ?? null
|
||||
|
|
@ -1,18 +1,33 @@
|
|||
/**
|
||||
* 入口:先把主题落到 <html> 上(index.html 里还有一段同款内联脚本,
|
||||
* 作用是「首帧之前」;这里负责之后用户切换主题的生效),再挂载路由。
|
||||
* 入口顺序是有讲究的:先把 CSS 变量(色板 + 尺子)写进 <head>,再落主题档位,
|
||||
* 最后才挂载 React —— 反过来的话首帧会有一瞬拿到 --c-* 的兜底值(透明底、系统字号)。
|
||||
*
|
||||
* 没套 StrictMode:音频引擎、麦克风、轮询都是模块级单例,
|
||||
* StrictMode 的双调用会在开发模式下把它们启停两次,排查问题时极具迷惑性。
|
||||
*/
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { RouterProvider } from 'react-router-dom'
|
||||
import { injectThemeVars } from './theme/css-vars'
|
||||
import { initTheme } from './stores/theme'
|
||||
import { ThemeProviders } from './app/providers'
|
||||
import { router, warmupRoutes } from './app/router'
|
||||
import './styles/index.css'
|
||||
|
||||
injectThemeVars()
|
||||
initTheme()
|
||||
createRoot(document.getElementById('root')!).render(<RouterProvider router={router} />)
|
||||
|
||||
// ⚠️ 这段说明必须留在 JSX **外面**:写在 <ThemeProviders> 的子节点位置上,
|
||||
// JS 注释不是注释而是 JSX 文本,会被原样渲染到每个页面顶部(一整行斜体小字),
|
||||
// 而它不改任何一个像素——六项判据一条都不会红。词汇表的规则 6 盯的就是这个位置。
|
||||
//
|
||||
// v7_startTransition:状态更新包进 React.startTransition,路由切换不再阻塞输入;
|
||||
// 不开它 React Router 每个页面都打一句 future flag 警告,体检器的 console 闸就被这一句长期占着
|
||||
//(见 docs/UI规范.md §1.3)。
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<ThemeProviders>
|
||||
<RouterProvider router={router} future={{ v7_startTransition: true }} />
|
||||
</ThemeProviders>
|
||||
)
|
||||
|
||||
/* 首屏之后预热相邻页面的 chunk(内部走 requestIdleCallback,不抢首屏带宽) */
|
||||
warmupRoutes()
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ import * as api from '../api/client'
|
|||
import { describeUserAgent, fmtAgo, fmtTime } from '../lib/format'
|
||||
import { useAutoRefresh } from '../hooks/use-auto-refresh'
|
||||
import { SecretInput } from '../components/forms'
|
||||
import {
|
||||
Actions, Button, CardRow, Empty, ErrorText, Field, FormGrid, FormRow, Layout, Notice, PageHead, Panel, PanelHead, Stack, Tag
|
||||
} from '../components/ui'
|
||||
import { Actions, Button, CardRow, Empty, ErrorText, Field, FormGrid, FormRow, Input, Layout, Notice, PageHead, Panel, PanelHead, Stack, Tag } from '../components/ui'
|
||||
import { login, roleLabel, setUser, useAuthStore } from '../stores/auth'
|
||||
|
||||
const RULES_HINT = '至少 8 位,字母 / 数字 / 符号至少两种'
|
||||
|
|
@ -107,28 +105,28 @@ export default function Account() {
|
|||
|
||||
<Layout>
|
||||
<Stack>
|
||||
<FormGrid>
|
||||
<Panel>
|
||||
<PanelHead title="基本资料" />
|
||||
<Panel>
|
||||
<PanelHead title="基本资料" />
|
||||
<FormGrid>
|
||||
<FormRow cols={2}>
|
||||
<Field label="登录名"><input value={auth.user?.username || ''} disabled /></Field>
|
||||
<Field label="登录名"><Input value={auth.user?.username || ''} disabled /></Field>
|
||||
<Field label="显示名">
|
||||
<input value={profile.display_name} maxLength={80} placeholder="同事看到的名字"
|
||||
onChange={(e) => setProfile((p) => ({ ...p, display_name: e.target.value }))} />
|
||||
<Input value={profile.display_name} maxLength={80} placeholder="同事看到的名字" onChange={(e) => setProfile((p) => ({ ...p, display_name: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="邮箱">
|
||||
<input value={profile.email} maxLength={160} placeholder="用于通知,可留空"
|
||||
onChange={(e) => setProfile((p) => ({ ...p, email: e.target.value }))} />
|
||||
<Input value={profile.email} maxLength={160} placeholder="用于通知,可留空" onChange={(e) => setProfile((p) => ({ ...p, email: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="角色"><input value={role + '(由管理员分配)'} disabled /></Field>
|
||||
<Field label="角色"><Input value={role + '(由管理员分配)'} disabled /></Field>
|
||||
</FormRow>
|
||||
<Actions>
|
||||
<Button variant="primary" disabled={!!busy} onClick={saveProfile}>保存资料</Button>
|
||||
</Actions>
|
||||
</Panel>
|
||||
</FormGrid>
|
||||
</Panel>
|
||||
|
||||
<Panel>
|
||||
<PanelHead title="修改密码" />
|
||||
<Panel>
|
||||
<PanelHead title="修改密码" />
|
||||
<FormGrid>
|
||||
<FormRow cols={3}>
|
||||
<Field label="当前密码">
|
||||
<SecretInput value={pwd.current_password} autocomplete="current-password" placeholder="当前密码"
|
||||
|
|
@ -154,8 +152,8 @@ export default function Account() {
|
|||
用新密码重新登录本机
|
||||
</Button>
|
||||
</Actions>
|
||||
</Panel>
|
||||
</FormGrid>
|
||||
</FormGrid>
|
||||
</Panel>
|
||||
</Stack>
|
||||
|
||||
<Stack>
|
||||
|
|
|
|||
|
|
@ -36,16 +36,11 @@ import {
|
|||
} from '../stores/models'
|
||||
import { MultiSelect, Select } from '../components/forms'
|
||||
import { AudioPlay } from '../components/media/AudioPlay'
|
||||
import { MediaThumb } from '../components/media/MediaThumb'
|
||||
import { MediaPick, MediaRemove, MediaThumb, type MediaRadius } from '../components/media/MediaThumb'
|
||||
import { RecordAudio, type RecordPickMeta } from '../components/media/RecordAudio'
|
||||
import { useAutoRefresh } from '../hooks'
|
||||
import { useRecordingBusy } from '../stores/recording'
|
||||
import {
|
||||
BarRight, Between, Button, Chip, ChipBar, Check, Ctlbar, Drawer, Empty, ErrorText, Field, FieldBlock,
|
||||
FilePick, FormGrid, FormRow, Grid, LINK_CLS, Modal, MONO, MUTED, MUTED_MONO, Notice, PageHead, Pager, Panel, PanelHead,
|
||||
Row, SectionTitle, Spinner, Tag, TagGroup, TEXTAREA_TALL, ViewBtn
|
||||
} from '../components/ui'
|
||||
import { Checkbox } from '../components/primitives'
|
||||
import { BarRight, Between, Button, Check, Checkbox, Chip, ChipBar, Ctlbar, Drawer, Empty, ErrorText, Field, FieldBlock, FilePick, FormGrid, FormRow, Grid, Input, LINK_CLS, MONO, MUTED, MUTED_MONO, Modal, Notice, NumberInput, PageHead, Pager, Panel, PanelHead, Row, SearchInput, SectionTitle, Spinner, TEXTAREA_TALL, Tag, TagGroup, TextArea, Rail, RAIL_GRID, RailItem, RailNote, ViewSwitch, Stat, StatGrid } from '../components/ui'
|
||||
|
||||
type AssetType = 'human' | 'scene' | 'voice'
|
||||
type ViewMode = 'grid' | 'list' | 'media'
|
||||
|
|
@ -1006,52 +1001,42 @@ export default function AssetLibrary() {
|
|||
{/* AS-7:四张卡本身就是筛选入口,数字点下去就到对应视角,不用先去翻筛选下拉。
|
||||
窄屏收列走断点变体(4 → ≤1180 两列 → ≤820 一列 → 手机上再并回两列,
|
||||
四行竖条在一屏里等于整页都是统计卡)。 */}
|
||||
<div className="grid min-w-0 gap-[10px] mb-[14px] grid-cols-4 max-mid:grid-cols-2 max-short:grid-cols-1 max-narrow:grid-cols-2">
|
||||
<MetricCard lead label="母版资产" value={totals.human + totals.scene + totals.voice}
|
||||
<StatGrid cols={4} className="mb-[14px]" steps={[{ at: 'mid', cols: 2 }, { at: 'short', cols: 1 }, { at: 'narrow', cols: 2 }]}>
|
||||
<Stat tone="lead" label="母版资产" value={totals.human + totals.scene + totals.voice}
|
||||
title="查看全部母版:清空筛选并回到网格视图"
|
||||
active={view !== 'media' && !filtersActive} onClick={focusMasters}
|
||||
hint={`人物 ${totals.human} · 场景 ${totals.scene} · 声线 ${totals.voice}`} />
|
||||
<MetricCard label="已登记素材" value={totals.media}
|
||||
<Stat label="已登记素材" value={totals.media}
|
||||
title="切换到跨母版的「全部素材」视角,直接翻找图片与音频"
|
||||
active={view === 'media'} onClick={focusWall}
|
||||
hint={`${fmtBytes(stats.media_bytes || 0)} · ${stats.versions || 0} 个版本 · 平均 ${mediaAverageKb} KB/个`} />
|
||||
<MetricCard label="待补素材" value={stats.without_media || 0}
|
||||
<Stat label="待补素材" value={stats.without_media || 0}
|
||||
title="只看还没有任何素材的母版(补齐定妆图 / 试听样本)"
|
||||
active={filters.has_media === 'without' && view !== 'media'} onClick={focusWithout}
|
||||
hint="母版已建档,但一张图 / 一段音都没有" />
|
||||
<MetricCard warn label="疑似重复" value={stats.duplicate_masters || 0}
|
||||
<Stat tone="warn" label="疑似重复" value={stats.duplicate_masters || 0}
|
||||
title="同名或同代号的母版分组,建议人工确认后合并"
|
||||
active={filters.duplicate_only && view !== 'media'} onClick={focusDuplicates}
|
||||
hint={`${stats.duplicate_groups || 0} 组同名 / 同代号 · 已引用母版 ${stats.referenced || 0}`} />
|
||||
</div>
|
||||
</StatGrid>
|
||||
|
||||
<div className="grid min-w-0 items-start gap-[13px] grid-cols-[224px_minmax(0,1fr)] max-short:grid-cols-1 [&>*]:min-w-0">
|
||||
{/* 左侧大分类(.type-rail):新增一类只改 TYPE_META */}
|
||||
<aside className="sticky top-[14px] flex flex-col gap-1.5 p-2 bg-card border border-line rounded-float min-w-0 max-short:static max-short:grid max-short:grid-cols-3">
|
||||
<div className={RAIL_GRID}>
|
||||
{/* 左侧大分类:新增一类只改 TYPE_META。栏本体(外壳 + 窄屏收列)在 kit 的 <Rail> */}
|
||||
<Rail>
|
||||
{TYPE_KEYS.map((key) => (
|
||||
<button key={key} type="button" onClick={() => chooseType(key)}
|
||||
className={cn('flex items-center gap-2.5 w-full min-w-0 p-[12px_9px] text-left text-ink-2 '
|
||||
+ 'border border-transparent rounded-tile bg-transparent hover:bg-panel',
|
||||
type === key && 'bg-raised border-success-line shadow-[inset_3px_0_0_var(--c-accent)]')}>
|
||||
<span className="grid place-items-center w-[31px] h-[31px] flex-none rounded-tile bg-line-soft text-accent text-[16px]">
|
||||
{TYPE_META[key].icon}
|
||||
</span>
|
||||
<span className="min-w-0">
|
||||
<b className="block text-body">{TYPE_META[key].label}</b>
|
||||
<small className="block mt-[3px] text-dim text-tiny leading-[1.35]">{TYPE_META[key].hint}</small>
|
||||
</span>
|
||||
<em className="ml-auto text-success not-italic text-h2">{totals[key]}</em>
|
||||
</button>
|
||||
<RailItem key={key} onClick={() => chooseType(key)} active={type === key}
|
||||
icon={TYPE_META[key].icon} label={TYPE_META[key].label}
|
||||
hint={TYPE_META[key].hint} count={totals[key]}
|
||||
ariaLabel={`${TYPE_META[key].label}分类,共 ${totals[key]} 个`} />
|
||||
))}
|
||||
<div title={`${typeMeta.hint}。资产在此管理母版,进入项目后仍可独立改版`}
|
||||
className="border-t border-active pt-5 pb-[5px] px-[7px] max-short:col-span-3">
|
||||
<RailNote title={`${typeMeta.hint}。资产在此管理母版,进入项目后仍可独立改版`}>
|
||||
{view === 'media' && (
|
||||
<p className="mt-[6px] mb-0 text-dim text-tiny leading-[1.6]">
|
||||
素材墙按 <b>当前类型</b> 过滤:{typeMeta.label}素材 {wall.stats?.by_owner?.[type] || 0} 个。
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
</RailNote>
|
||||
</Rail>
|
||||
|
||||
<section className="min-w-0">
|
||||
<Panel className="bg-shell p-[16px]">
|
||||
|
|
@ -1062,22 +1047,14 @@ export default function AssetLibrary() {
|
|||
: filtersActive
|
||||
? `筛选出 ${resultCount} 个母版,本页 ${rows.length} 个(第 ${summary.page} / ${summary.pages} 页)`
|
||||
: `共 ${resultCount} 个母版`}
|
||||
right={
|
||||
<div role="group" aria-label="切换视图"
|
||||
className="flex gap-[3px] shrink-0 p-[3px] bg-card border border-line rounded-tile max-narrow:w-full max-narrow:[&>button]:flex-1">
|
||||
{VIEW_ITEMS.map((item) => (
|
||||
<ViewBtn key={item.value} active={view === item.value} title={item.hint}
|
||||
onClick={() => chooseView(item.value)}>{item.label}</ViewBtn>
|
||||
))}
|
||||
</div>
|
||||
} />
|
||||
right={<ViewSwitch value={view} onChange={chooseView} items={VIEW_ITEMS}
|
||||
className="shrink-0 max-narrow:w-full" block />} />
|
||||
|
||||
{/* 筛选栏:只有皮肤,布局(等高 / 折行 / 行内标签)全部来自 Ctlbar。
|
||||
「每页」不在这里——分页条是 page_size 唯一的家(UI规范 §5)。 */}
|
||||
<Ctlbar className="px-[10px] py-2 mb-3 border border-emphasis rounded-[10px] bg-card">
|
||||
<Ctlbar className="px-[10px] py-2 mb-3 border border-emphasis rounded-tile bg-card">
|
||||
<Field label="搜索" width="grow" title="跨字段匹配名称、代号、设定、提示词与标签">
|
||||
<input type="search" value={search} onChange={(e) => setSearch(e.target.value)}
|
||||
aria-label="搜索平台资产" placeholder="名称 / 代号 / 设定 / 提示词 / 标签(跨字段)" />
|
||||
<SearchInput value={search} onChange={(e) => setSearch(e.target.value)} aria-label="搜索平台资产" placeholder="名称 / 代号 / 设定 / 提示词 / 标签(跨字段)" />
|
||||
</Field>
|
||||
<Field label="素材类型" title="选项只列当前大分类该有的类型:在「人物」下筛「音色样本」永远 0 条">
|
||||
<Select size="sm" value={filters.kind} ariaLabel="按素材类型筛选"
|
||||
|
|
@ -1185,13 +1162,13 @@ export default function AssetLibrary() {
|
|||
<div className="grid gap-[9px] grid-cols-[repeat(auto-fill,minmax(148px,1fr))] max-narrow:grid-cols-[repeat(auto-fill,minmax(120px,1fr))] min-w-0 [&>*]:min-w-0">
|
||||
{wall.items.map((media: any, idx: number) => (
|
||||
<div key={media.id}
|
||||
className={cn('relative flex flex-col gap-[5px] p-[7px_7px_8px] rounded-[10px] bg-card border border-emphasis',
|
||||
className={cn('relative flex flex-col gap-[5px] p-[7px_7px_8px] rounded-tile bg-card border border-emphasis',
|
||||
selectedMedia.has(media.id) && 'border-accent-line shadow-[0_0_0_1px_var(--c-accent-tint)]')}>
|
||||
<label title="勾选后可批量删除(Shift 范围选择)" className={cn(PICK, 'left-[12px] top-[12px]')}>
|
||||
<MediaPick title="勾选后可批量删除(Shift 范围选择)" className="left-[12px] top-[12px]">
|
||||
<Checkbox checked={selectedMedia.has(media.id)}
|
||||
onClick={(e) => { e.stopPropagation(); toggleMedia(media, idx, e.shiftKey) }} />
|
||||
</label>
|
||||
<MediaThumb item={wallQueue[idx]} size="sm" radius={8} queue={wallQueue} index={idx}
|
||||
</MediaPick>
|
||||
<MediaThumb item={wallQueue[idx]} size="sm" queue={wallQueue} index={idx}
|
||||
title={`${media.name || media.kind_label} · ${media.owner_name}`} />
|
||||
<div className="min-w-0">
|
||||
<b className="block truncate text-ink-2 text-tiny" title={media.name || media.kind_label}>
|
||||
|
|
@ -1230,7 +1207,7 @@ export default function AssetLibrary() {
|
|||
{rows.map((row: any, idx: number) => (
|
||||
<article key={row.id}
|
||||
className={cn('grid items-center gap-3 grid-cols-[auto_auto_minmax(200px,1fr)_auto_auto] '
|
||||
+ 'p-[9px_12px] rounded-[10px] border border-emphasis '
|
||||
+ 'p-[9px_12px] rounded-tile border border-emphasis '
|
||||
+ 'bg-[linear-gradient(145deg,var(--c-bg-panel),var(--c-bg-sunken))] max-short:grid-cols-[auto_minmax(0,1fr)] max-short:[&_.row-media]:hidden',
|
||||
isSelected(row) && 'border-accent-line shadow-[0_0_0_1px_var(--c-accent-tint)]',
|
||||
row.duplicate_of?.length && 'border-warn-line')}>
|
||||
|
|
@ -1254,7 +1231,7 @@ export default function AssetLibrary() {
|
|||
)}
|
||||
{!row.media_count && <Tag tone="warn">待补素材</Tag>}
|
||||
</div>
|
||||
<p className="mt-[3px] mb-1 line-clamp-1 text-[10.5px] leading-[1.45] text-ink-3">
|
||||
<p className="mt-[3px] mb-1 line-clamp-1 text-tiny leading-[1.45] text-ink-3">
|
||||
{row.persona_prompt || row.appearance || row.description || row.prompt || row.voice_profile || '尚未填写设定。'}
|
||||
</p>
|
||||
<TagGroup size="sm" className="mb-0 flex-nowrap overflow-hidden">
|
||||
|
|
@ -1271,7 +1248,7 @@ export default function AssetLibrary() {
|
|||
</div>
|
||||
<div className="row-media flex items-center gap-[5px] shrink-0">
|
||||
{stripOf(row, 5).map((media: any) => (
|
||||
<MediaTile key={media.id} media={media} width="58px" size="xs" radius={6}
|
||||
<MediaTile key={media.id} media={media} width="58px" size="xs"
|
||||
queue={itemsOf(row)} index={mediaIndex(row, media)}
|
||||
onRemove={() => void deleteMedia(media)} />
|
||||
))}
|
||||
|
|
@ -1307,15 +1284,14 @@ export default function AssetLibrary() {
|
|||
const audios = (row.assets || []).filter(isAudio)
|
||||
return (
|
||||
<article key={row.id}
|
||||
className={cn('relative flex flex-col min-w-0 p-[14px] rounded-[11px] border border-emphasis '
|
||||
className={cn('relative flex flex-col min-w-0 p-[14px] rounded-tile border border-emphasis '
|
||||
+ 'bg-[linear-gradient(145deg,var(--c-bg-panel),var(--c-bg-sunken))]',
|
||||
isSelected(row) && 'border-accent-line shadow-[0_0_0_1px_var(--c-accent-tint)]',
|
||||
row.duplicate_of?.length && 'border-warn-line')}>
|
||||
<label className={PICK}
|
||||
title={isSelected(row) ? '取消选择' : '勾选后可批量引入 / 打标签 / 删除(Shift 范围选择)'}>
|
||||
<MediaPick title={isSelected(row) ? '取消选择' : '勾选后可批量引入 / 打标签 / 删除(Shift 范围选择)'}>
|
||||
<Checkbox checked={isSelected(row)}
|
||||
onClick={(e) => { e.stopPropagation(); toggleSelect(row, idx, e.shiftKey) }} />
|
||||
</label>
|
||||
</MediaPick>
|
||||
<div className="flex items-start gap-2.5 pl-[22px] min-w-0">
|
||||
<Portrait name={row.name} />
|
||||
<div className="grow min-w-0">
|
||||
|
|
@ -1362,7 +1338,7 @@ export default function AssetLibrary() {
|
|||
{!!stripOf(row).length && (
|
||||
<div className="mt-[10px] grid grid-cols-4 gap-[5px] max-narrow:grid-cols-2 min-w-0 [&>*]:min-w-0">
|
||||
{stripOf(row).map((media: any) => (
|
||||
<MediaTile key={media.id} media={media} size="sm" radius={7}
|
||||
<MediaTile key={media.id} media={media} size="sm"
|
||||
queue={itemsOf(row)} index={mediaIndex(row, media)}
|
||||
onRemove={() => void deleteMedia(media)} />
|
||||
))}
|
||||
|
|
@ -1396,7 +1372,7 @@ export default function AssetLibrary() {
|
|||
)
|
||||
})}
|
||||
{!row.assets?.length && (
|
||||
<div className="mt-[10px] grid place-items-center min-h-[55px] px-2 rounded-[7px] border border-dashed border-line text-dim text-tiny text-center">
|
||||
<div className="mt-[10px] grid place-items-center min-h-[55px] px-2 rounded-control border border-dashed border-line text-dim text-tiny text-center">
|
||||
暂无素材:用下方「AI 生成」出图 / 出试听,或直接上传现成文件。
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -1464,16 +1440,13 @@ export default function AssetLibrary() {
|
|||
<div className={TEXTAREA_TALL}>
|
||||
<FormRow>
|
||||
<Field label="名称" required>
|
||||
<input value={form.name} placeholder="角色 / 场景 / 声线名称"
|
||||
onChange={(e) => patchForm({ name: e.target.value })} />
|
||||
<Input value={form.name} placeholder="角色 / 场景 / 声线名称" onChange={(e) => patchForm({ name: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="代号">
|
||||
<input value={form.code} placeholder="可留空"
|
||||
onChange={(e) => patchForm({ code: e.target.value })} />
|
||||
<Input value={form.code} placeholder="可留空" onChange={(e) => patchForm({ code: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="标签">
|
||||
<input value={form.tags} placeholder="科幻 主角 冷色"
|
||||
onChange={(e) => patchForm({ tags: e.target.value })} />
|
||||
<Input value={form.tags} placeholder="科幻 主角 冷色" onChange={(e) => patchForm({ tags: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
|
||||
|
|
@ -1485,8 +1458,7 @@ export default function AssetLibrary() {
|
|||
onChange={(next) => patchForm({ role: String(next) })} ariaLabel="角色定位" />
|
||||
</Field>
|
||||
<Field label="造型版本">
|
||||
<input value={form.style_version}
|
||||
onChange={(e) => patchForm({ style_version: e.target.value })} />
|
||||
<Input value={form.style_version} onChange={(e) => patchForm({ style_version: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="默认声线">
|
||||
<Select value={form.default_voice_id}
|
||||
|
|
@ -1497,21 +1469,17 @@ export default function AssetLibrary() {
|
|||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="外观">
|
||||
<textarea value={form.appearance} rows={2} placeholder="五官、发型、体型、服装与配饰"
|
||||
onChange={(e) => patchForm({ appearance: e.target.value })} />
|
||||
<TextArea value={form.appearance} rows={2} placeholder="五官、发型、体型、服装与配饰" onChange={(e) => patchForm({ appearance: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="性格与表演">
|
||||
<textarea value={form.personality} rows={2}
|
||||
onChange={(e) => patchForm({ personality: e.target.value })} />
|
||||
<TextArea value={form.personality} rows={2} onChange={(e) => patchForm({ personality: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="一致性提示词">
|
||||
<textarea value={form.persona_prompt} rows={3}
|
||||
onChange={(e) => patchForm({ persona_prompt: e.target.value })} />
|
||||
<TextArea value={form.persona_prompt} rows={3} onChange={(e) => patchForm({ persona_prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow>
|
||||
<Field label="声音描述">
|
||||
<input value={form.voice_profile}
|
||||
onChange={(e) => patchForm({ voice_profile: e.target.value })} />
|
||||
<Input value={form.voice_profile} onChange={(e) => patchForm({ voice_profile: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
</>
|
||||
|
|
@ -1521,23 +1489,20 @@ export default function AssetLibrary() {
|
|||
<>
|
||||
<FormRow>
|
||||
<Field label="光线">
|
||||
<input value={form.lighting} onChange={(e) => patchForm({ lighting: e.target.value })} />
|
||||
<Input value={form.lighting} onChange={(e) => patchForm({ lighting: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="时间">
|
||||
<input value={form.time_of_day}
|
||||
onChange={(e) => patchForm({ time_of_day: e.target.value })} />
|
||||
<Input value={form.time_of_day} onChange={(e) => patchForm({ time_of_day: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="主色调">
|
||||
<input value={form.palette} onChange={(e) => patchForm({ palette: e.target.value })} />
|
||||
<Input value={form.palette} onChange={(e) => patchForm({ palette: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="场景描述">
|
||||
<textarea value={form.description} rows={2}
|
||||
onChange={(e) => patchForm({ description: e.target.value })} />
|
||||
<TextArea value={form.description} rows={2} onChange={(e) => patchForm({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="一致性提示词">
|
||||
<textarea value={form.prompt} rows={3}
|
||||
onChange={(e) => patchForm({ prompt: e.target.value })} />
|
||||
<TextArea value={form.prompt} rows={3} onChange={(e) => patchForm({ prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</>
|
||||
)}
|
||||
|
|
@ -1546,15 +1511,14 @@ export default function AssetLibrary() {
|
|||
<>
|
||||
<FormRow>
|
||||
<Field label="语言">
|
||||
<input value={form.language} onChange={(e) => patchForm({ language: e.target.value })} />
|
||||
<Input value={form.language} onChange={(e) => patchForm({ language: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="性别">
|
||||
<Select value={form.gender} options={GENDERS}
|
||||
onChange={(next) => patchForm({ gender: String(next ?? '') })} ariaLabel="声线性别" />
|
||||
</Field>
|
||||
<Field label="语速">
|
||||
<input type="number" min={0.5} max={2} step={0.05} value={form.tuning_speed}
|
||||
onChange={(e) => patchForm({ tuning_speed: Number(e.target.value) })} />
|
||||
<NumberInput min={0.5} max={2} step={0.05} value={form.tuning_speed} onChange={ (v) => patchForm({ tuning_speed: v })} />
|
||||
</Field>
|
||||
<Field label="效果" title={EFFECT_HINT}>
|
||||
<Select value={form.tuning_effect} options={EFFECTS}
|
||||
|
|
@ -1567,19 +1531,18 @@ export default function AssetLibrary() {
|
|||
</Check>
|
||||
</FormRow>
|
||||
<FieldBlock label="音色描述">
|
||||
<textarea value={form.description} rows={3}
|
||||
onChange={(e) => patchForm({ description: e.target.value })} />
|
||||
<TextArea value={form.description} rows={3} onChange={(e) => patchForm({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow>
|
||||
<Field label="版本">
|
||||
<input value={form.version} onChange={(e) => patchForm({ version: e.target.value })} />
|
||||
<Input value={form.version} onChange={(e) => patchForm({ version: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
</>
|
||||
)}
|
||||
|
||||
<FieldBlock label="备注">
|
||||
<textarea value={form.notes} rows={2} onChange={(e) => patchForm({ notes: e.target.value })} />
|
||||
<TextArea value={form.notes} rows={2} onChange={(e) => patchForm({ notes: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<ErrorText>{error}</ErrorText>
|
||||
</div>
|
||||
|
|
@ -1592,7 +1555,7 @@ export default function AssetLibrary() {
|
|||
整屏盖住就找不到「刚才那张图长什么样」了。 */}
|
||||
{genDrawer && genTarget && (
|
||||
<Drawer open onClose={() => setGenDrawer(false)} label="生成平台素材"
|
||||
width="w-[min(980px,calc(100vw-64px))] max-mid:w-[min(760px,calc(100vw-24px))] max-short:w-screen"
|
||||
width="min(980px, calc(100vw - 24px))"
|
||||
title={genTarget.name}
|
||||
sub={<span className={MONO}>
|
||||
{genTarget.code || `${type}-${genTarget.id}`} · 现有 {genTarget.media_count || 0} 个素材
|
||||
|
|
@ -1631,10 +1594,7 @@ export default function AssetLibrary() {
|
|||
|
||||
{isVoice && (
|
||||
<FieldBlock label="试听文本" required>
|
||||
<textarea rows={2} value={draft.sample_text}
|
||||
title="这是要念出来的台词,不是声线设定;「音色描述」不会被当成台词。"
|
||||
placeholder="输入一句要让模型朗读的台词,例如:我是俊杰,公司的产品专家。"
|
||||
onChange={(e) => setDraft(genTarget, { sample_text: e.target.value })} />
|
||||
<TextArea rows={2} value={draft.sample_text} title="这是要念出来的台词,不是声线设定;「音色描述」不会被当成台词。" placeholder="输入一句要让模型朗读的台词,例如:我是俊杰,公司的产品专家。" onChange={(e) => setDraft(genTarget, { sample_text: e.target.value })} />
|
||||
</FieldBlock>
|
||||
)}
|
||||
|
||||
|
|
@ -1684,8 +1644,7 @@ export default function AssetLibrary() {
|
|||
</div>
|
||||
|
||||
<FieldBlock label="补充提示" className="mt-[10px]">
|
||||
<textarea rows={2} value={draft.prompt} placeholder="留空则自动使用母版设定"
|
||||
onChange={(e) => setDraft(genTarget, { prompt: e.target.value })} />
|
||||
<TextArea rows={2} value={draft.prompt} placeholder="留空则自动使用母版设定" onChange={(e) => setDraft(genTarget, { prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</>
|
||||
)}
|
||||
|
|
@ -1770,7 +1729,7 @@ export default function AssetLibrary() {
|
|||
</SectionTitle>
|
||||
<Grid gap={6} className="grid-cols-[repeat(auto-fill,minmax(76px,1fr))] items-center">
|
||||
{genTarget.assets.filter((item: any) => isImage(item)).map((media: any) => (
|
||||
<MediaThumb key={media.id} item={fromAsset(media)} size="xs" radius={6}
|
||||
<MediaThumb key={media.id} item={fromAsset(media)} size="xs"
|
||||
title={media.name || media.kind_label}
|
||||
queue={itemsOf(genTarget)} index={mediaIndex(genTarget, media)} />
|
||||
))}
|
||||
|
|
@ -1858,12 +1817,10 @@ export default function AssetLibrary() {
|
|||
</p>
|
||||
<FormRow>
|
||||
<Field label="追加标签">
|
||||
<input value={batchTags.add} placeholder="逗号或空格分隔,例如:科幻 待打磨"
|
||||
onChange={(e) => setBatchTags((prev) => ({ ...prev, add: e.target.value }))} />
|
||||
<Input value={batchTags.add} placeholder="逗号或空格分隔,例如:科幻 待打磨" onChange={(e) => setBatchTags((prev) => ({ ...prev, add: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="移除标签">
|
||||
<input value={batchTags.remove} placeholder="留空即不移除"
|
||||
onChange={(e) => setBatchTags((prev) => ({ ...prev, remove: e.target.value }))} />
|
||||
<Input value={batchTags.remove} placeholder="留空即不移除" onChange={(e) => setBatchTags((prev) => ({ ...prev, remove: e.target.value }))} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
</Modal>
|
||||
|
|
@ -1929,36 +1886,12 @@ export default function AssetLibrary() {
|
|||
「只有资产库会跟着改」的公共 API。皮肤写成模块级常量,JSX 里只剩结构。
|
||||
跨页复用的(Panel / Field / Grid / Tag …)一律走 components/ui。 */
|
||||
|
||||
/** 统计卡:整张卡就是筛选入口,所以它必须是 button 而不是 div(AS-7) */
|
||||
function MetricCard({ label, value, hint, title, active, onClick, lead, warn }: {
|
||||
label: string; value: number | string; hint?: ReactNode; title?: string
|
||||
active?: boolean; onClick?: () => void; lead?: boolean; warn?: boolean
|
||||
}) {
|
||||
return (
|
||||
<button type="button" title={title} onClick={onClick}
|
||||
className={cn('relative overflow-hidden min-w-0 text-left min-h-[104px] p-[14px_16px] rounded-block '
|
||||
+ 'border border-line bg-[linear-gradient(145deg,var(--c-bg-panel),var(--c-bg-card))] '
|
||||
+ 'hover:border-accent-line transition-colors',
|
||||
lead && 'bg-[linear-gradient(145deg,var(--c-bg-raised),var(--c-bg-panel))] border-warn-line',
|
||||
warn && 'border-warn-line',
|
||||
// 命中当前筛选时点亮描边 + 数字,用户才知道「这一屏数字就是现在这批」
|
||||
active && 'border-success-line shadow-[inset_0_0_0_1px_var(--c-success-line)] [&>span:first-of-type]:text-success')}>
|
||||
<span className="pointer-events-none absolute inset-0
|
||||
bg-[radial-gradient(circle_at_106%_132%,var(--c-tint-accent),transparent_58%)]" />
|
||||
<span className="relative block text-faint text-tiny tracking-[.7px]">{label}</span>
|
||||
<strong className={cn('relative block my-[8px_3px] text-h1 leading-[1.05] text-ink',
|
||||
lead && 'text-accent', warn && 'text-warn')}>{value}</strong>
|
||||
{hint && <small className="relative block text-dim text-tiny">{hint}</small>}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/** 头像占位:没有定妆图时至少留一个「这里站着谁」的形体(圆角下宽上窄=肩线) */
|
||||
function Portrait({ name, sm }: { name?: string; sm?: boolean }) {
|
||||
return (
|
||||
<span className={cn('grid place-items-center flex-none border border-accent-line bg-accent-tint text-accent',
|
||||
sm ? 'w-[30px] h-[34px] text-[14px] rounded-[8px_8px_11px_11px]'
|
||||
: 'w-[38px] h-[42px] text-[18px] rounded-[10px_10px_13px_13px]')}>
|
||||
sm ? 'w-[30px] h-[34px] text-title rounded-[8px_8px_11px_11px]'
|
||||
: 'w-[38px] h-[42px] text-h2 rounded-[10px_10px_13px_13px]')}>
|
||||
{name?.slice(0, 1)}
|
||||
</span>
|
||||
)
|
||||
|
|
@ -1975,36 +1908,31 @@ function ScopeTag({ row }: { row: any }) {
|
|||
}
|
||||
|
||||
/** 素材缩略图 + 右上角单独删除叉;图片走预览器队列,文件只有一块说明砖 */
|
||||
function MediaTile({ media, size = 'sm', radius = 7, width, queue, index, onRemove }: {
|
||||
media: any; size?: 'xs' | 'sm'; radius?: number; width?: string
|
||||
function MediaTile({ media, size = 'sm', radius, width, queue, index, onRemove }: {
|
||||
media: any; size?: 'xs' | 'sm'; radius?: MediaRadius; width?: string
|
||||
queue?: MediaItem[]; index?: number; onRemove: () => void
|
||||
}) {
|
||||
/* 单独删除此媒体(含全部历史版本)——这句话两边都要说一次,
|
||||
因为删图片和删文件走的是同一个接口,差别只在缩略图长什么样 */
|
||||
const removeTitle = '单独删除此媒体(含全部历史版本)'
|
||||
return (
|
||||
<div className="relative min-w-0" style={width ? { width } : undefined}>
|
||||
{isImage(media)
|
||||
? <MediaThumb item={fromAsset(media)} size={size} radius={radius}
|
||||
title={media.name || media.kind_label} queue={queue} index={index} />
|
||||
title={media.name || media.kind_label} queue={queue} index={index}
|
||||
onRemove={onRemove} removeTitle={removeTitle} />
|
||||
: <div className={cn(FILE_TILE, size === 'xs' ? 'min-h-[34px]' : 'min-h-[55px]')}>
|
||||
<b>{media.kind_label}</b>
|
||||
<span>{fmtBytes(media.size_bytes)}{size === 'sm' && ` · v${media.version}`}</span>
|
||||
<MediaRemove onClick={onRemove} title={removeTitle} />
|
||||
</div>}
|
||||
<button type="button" className={MEDIA_REMOVE} title="单独删除此媒体(含全部历史版本)"
|
||||
aria-label="删除这个素材" onClick={(e) => { e.stopPropagation(); onRemove() }}>×</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 缩略图左上角的勾选框:压在图上,所以自带一层半透明底板 */
|
||||
const PICK = 'absolute left-2 top-2 z-[3] grid place-items-center w-[21px] h-[21px] m-0 p-0 rounded-[6px] '
|
||||
+ 'bg-[color-mix(in_srgb,var(--c-bg-shell)_74%,transparent)] '
|
||||
+ '[&>[role=checkbox]]:w-[13px] [&>[role=checkbox]]:h-[13px]'
|
||||
/** 缩略图右上角的删除叉:不能压住 MediaThumb 左下的版本角标 */
|
||||
const MEDIA_REMOVE = 'absolute right-[3px] top-[3px] grid place-items-center w-5 h-5 p-0 rounded-full '
|
||||
+ 'border border-danger-line text-danger-bright text-[15px] leading-none hover:bg-danger-line '
|
||||
+ 'bg-[color-mix(in_srgb,var(--c-danger-tint2)_91%,transparent)]'
|
||||
const FILE_TILE = 'flex flex-col justify-between p-[6px] rounded-[6px] bg-hover '
|
||||
const FILE_TILE = 'flex flex-col justify-between p-[6px] rounded-control bg-hover '
|
||||
+ '[&>b]:text-ink-2 [&>b]:text-tiny [&>span]:text-dim [&>span]:text-tiny'
|
||||
const SUMMARY = 'line-clamp-3 min-h-[46px] mt-[10px] mb-[7px] text-[10.5px] leading-[1.55] text-muted'
|
||||
const SUMMARY = 'line-clamp-3 min-h-[46px] mt-[10px] mb-[7px] text-tiny leading-[1.55] text-muted'
|
||||
/** 卡片右下角的「哪一版 / 什么时候改的」:等宽 + 截断,不参与挤压标题 */
|
||||
const STAMP = 'ml-auto min-w-0 max-w-[140px] truncate font-mono text-tiny text-dim'
|
||||
/** 确认框里那段「动的是什么」:左边一条重色竖线,比整块描边更像一个引用块 */
|
||||
|
|
@ -2013,7 +1941,7 @@ const IMPORT_SUBJECT = 'my-4 p-[11px_12px] border-l-2 border-l-accent-deep bg-ca
|
|||
/** 批量影响面清单:最多 258px 高,超出内部滚动,避免长列表把按钮顶出屏幕 */
|
||||
const DIALOG_LIST = 'flex flex-col gap-[5px] max-h-[258px] overflow-y-auto m-0 p-0 list-none '
|
||||
+ '[&>li]:flex [&>li]:items-center [&>li]:gap-[6px] [&>li]:flex-wrap [&>li]:p-[6px_8px] '
|
||||
+ '[&>li]:border [&>li]:border-emphasis [&>li]:rounded-[7px] [&>li]:bg-card [&>li>b]:text-tiny'
|
||||
+ '[&>li]:border [&>li]:border-emphasis [&>li]:rounded-control [&>li]:bg-card [&>li>b]:text-tiny'
|
||||
const PROVIDER_WARN = 'block mt-[7px] p-[6px_7px] border border-warn-line rounded-chip bg-raised text-warn '
|
||||
+ 'text-tiny leading-[1.5]'
|
||||
/**
|
||||
|
|
@ -2029,8 +1957,8 @@ const REF_PICK = 'justify-center border-accent-line text-success'
|
|||
const REF_HINT = 'basis-full text-dim text-tiny leading-[1.5]'
|
||||
/** 参考区里的整行元素(状态盒) */
|
||||
const REF_FULL = 'basis-full'
|
||||
const REF_STATUS = 'grid gap-1 p-[7px_8px] rounded-[6px] border border-line-strong bg-card text-[9.5px] '
|
||||
+ '[&>b]:text-[10.5px] [&>b]:leading-[1.5] [&>small]:text-faint [&>small]:leading-[1.5]'
|
||||
const REF_STATUS = 'grid gap-1 p-[7px_8px] rounded-control border border-line-strong bg-card text-tiny '
|
||||
+ '[&>b]:text-tiny [&>b]:leading-[1.5] [&>small]:text-faint [&>small]:leading-[1.5]'
|
||||
const REF_WARN = 'border-warn-line bg-warn-tint [&>b]:text-warn-bright'
|
||||
const REF_BAD = 'border-danger-line bg-danger-tint [&>b]:text-danger'
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,7 @@ import { useAutoRefresh } from '../hooks'
|
|||
import { Select } from '../components/forms'
|
||||
import { MediaThumb } from '../components/media/MediaThumb'
|
||||
import { WorkflowBar } from '../components/media/WorkflowBar'
|
||||
import {
|
||||
Actions, Button, buttonCls, Chip, ChipBar, Ctlbar, Divider, Empty, ErrorText, Field,
|
||||
FieldBlock, FormGrid, FormRow, Grid, LINK_CLS, Loading, LogBox, LogRow, MONO, MUTED, PageHead, Panel,
|
||||
PanelHead, ProgressBar, Row, SectionTitle, Stat, StatGrid, Status, TabStack, Table, TableBox,
|
||||
Tag, TagChip, TagGroup, Value, cellRight, cellWrap
|
||||
} from '../components/ui'
|
||||
import { Actions, Button, Chip, ChipBar, Ctlbar, Divider, Empty, ErrorText, Field, FieldBlock, FormGrid, FormRow, Grid, Input, LINK_CLS, LinkButton, Loading, LogBox, LogRow, MONO, MUTED, NumberInput, PageHead, Panel, PanelHead, ProgressBar, Row, SectionTitle, Stat, StatGrid, Status, TabStack, Tile, Table, TableBox, Tag, TagChip, TagGroup, TextArea, Value, cellRight, cellWrap } from '../components/ui'
|
||||
import {
|
||||
capabilityHint, capsOf, defaultFor, deliveryResolutions, fpsChoices, isMock, loadModels,
|
||||
modelsOf, parseRef, refOf, resolutionChoices, useRegistry
|
||||
|
|
@ -63,8 +58,8 @@ const LIB_TYPES: { value: LibType; label: string }[] = [
|
|||
/** 表格里不许折行的列(数字、状态、动作),长文本列另用 cellWrap */
|
||||
const NOWRAP = 'whitespace-nowrap'
|
||||
/** 没有封面时的占位格:有镜头却没画面 ≠ 没导入分镜,两种情况图标要说清楚 */
|
||||
const COVER_NONE = 'grid h-[41px] w-[72px] place-items-center rounded-[6px] border border-dashed '
|
||||
+ 'border-line-strong bg-panel text-muted text-[14px]'
|
||||
const COVER_NONE = 'grid h-[41px] w-[72px] place-items-center rounded-control border border-dashed '
|
||||
+ 'border-line-strong bg-panel text-muted text-title'
|
||||
|
||||
const coverOf = (row: any) => (row?.assets || []).find((m: any) => isImage(m.url, m.kind, m.mime)) || null
|
||||
const audioOfRow = (row: any) => (row?.assets || []).find((m: any) => isAudio(m.url, m.kind, m.mime)) || null
|
||||
|
|
@ -337,21 +332,21 @@ export default function Dashboard() {
|
|||
{creating && (
|
||||
<form onSubmit={submit} className="min-w-0">
|
||||
<Panel>
|
||||
<FormGrid>
|
||||
{/* 标签列锁 92px:这一表单里最长的是「目标总时长(秒)」92px。
|
||||
不锁的话标签列宽 = minmax(66, max-content),这一格控件会被长标题顶右 15px,
|
||||
整表就长出两条控件左边界(体检 misaligned 唯一报红的表单)。 */}
|
||||
<FormGrid labelWidth={92}>
|
||||
<h3 className="mb-3" title="流程第 ① 步:创建视频项目">新建长视频项目</h3>
|
||||
|
||||
<FormRow>
|
||||
<Field label="项目名称" required>
|
||||
<input value={form.name} placeholder="例如:星海纪元 · 第一集"
|
||||
onChange={(e) => setForm({ name: e.target.value })} />
|
||||
<Input value={form.name} placeholder="例如:星海纪元 · 第一集" onChange={(e) => setForm({ name: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="题材">
|
||||
<input value={form.genre} placeholder="科幻 / 悬疑 / 都市"
|
||||
onChange={(e) => setForm({ genre: e.target.value })} />
|
||||
<Input value={form.genre} placeholder="科幻 / 悬疑 / 都市" onChange={(e) => setForm({ genre: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="目标总时长(秒)">
|
||||
<input type="number" min={1} value={form.target_duration} title={durationRule}
|
||||
onChange={(e) => setForm({ target_duration: Number(e.target.value) })} />
|
||||
<NumberInput min={1} value={form.target_duration} title={durationRule} onChange={ (v) => setForm({ target_duration: v })} />
|
||||
</Field>
|
||||
<Field label="默认转场">
|
||||
<Select value={form.default_transition} options={meta?.options?.transition || []}
|
||||
|
|
@ -377,19 +372,16 @@ export default function Dashboard() {
|
|||
onChange={(v) => setForm({ fps: Number(v) })} />
|
||||
</Field>
|
||||
<Field label="全局负面提示词">
|
||||
<input value={form.global_negative_prompt} placeholder="文字水印,画面抖动,肢体畸变"
|
||||
onChange={(e) => setForm({ global_negative_prompt: e.target.value })} />
|
||||
<Input value={form.global_negative_prompt} placeholder="文字水印,画面抖动,肢体畸变" onChange={(e) => setForm({ global_negative_prompt: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
|
||||
<FormRow cols={2}>
|
||||
<FieldBlock label="项目简介">
|
||||
<textarea rows={2} value={form.description}
|
||||
onChange={(e) => setForm({ description: e.target.value })} />
|
||||
<TextArea rows={2} value={form.description} onChange={(e) => setForm({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="全局风格指南(拼接到每个镜头提示词)">
|
||||
<textarea rows={2} value={form.style_guide} placeholder="赛博朋克国风,冷色调,电影质感"
|
||||
onChange={(e) => setForm({ style_guide: e.target.value })} />
|
||||
<TextArea rows={2} value={form.style_guide} placeholder="赛博朋克国风,冷色调,电影质感" onChange={(e) => setForm({ style_guide: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</FormRow>
|
||||
|
||||
|
|
@ -428,8 +420,7 @@ export default function Dashboard() {
|
|||
<PanelHead title="项目列表" right={
|
||||
<Ctlbar className="mb-0 w-full">
|
||||
<Field label="搜索" width="grow">
|
||||
<input value={keyword} aria-label="搜索项目" placeholder="名称 / 简介 / 题材"
|
||||
onChange={(e) => setKeyword(e.target.value)} />
|
||||
<Input value={keyword} aria-label="搜索项目" placeholder="名称 / 简介 / 题材" onChange={(e) => setKeyword(e.target.value)} />
|
||||
</Field>
|
||||
<Field label="状态" width="narrow">
|
||||
<Select size="sm" value={statusFilter} ariaLabel="项目状态筛选" onChange={setStatusFilter}
|
||||
|
|
@ -460,7 +451,7 @@ export default function Dashboard() {
|
|||
<div className="flex min-w-0 items-center gap-[10px]">
|
||||
<div className="w-[72px] flex-none">
|
||||
{p.cover_url
|
||||
? <MediaThumb src={p.cover_url} size="xs" width="72px" radius={6} title={`${p.name} 首帧`} />
|
||||
? <MediaThumb src={p.cover_url} size="xs" width="72px" title={`${p.name} 首帧`} />
|
||||
: <span className={COVER_NONE}
|
||||
title={p.shot_count ? '已有镜头,但还没有生成任何画面' : '还没有导入分镜'}>
|
||||
{p.shot_count ? '▷' : '+'}
|
||||
|
|
@ -532,8 +523,7 @@ export default function Dashboard() {
|
|||
</Chip>
|
||||
))}
|
||||
<Field label="搜索" width="grow" className="max-w-[260px]">
|
||||
<input value={eventKeyword} aria-label="搜索事件" placeholder="事件内容 / 动作"
|
||||
onChange={(e) => setEventKeyword(e.target.value)} />
|
||||
<Input value={eventKeyword} aria-label="搜索事件" placeholder="事件内容 / 动作" onChange={(e) => setEventKeyword(e.target.value)} />
|
||||
</Field>
|
||||
</ChipBar>
|
||||
<LogBox>
|
||||
|
|
@ -596,7 +586,7 @@ function LibraryPicker({ open, type, onType, query, onQuery, rows, loading, erro
|
|||
</Row>
|
||||
|
||||
{open && (
|
||||
<div className="mt-[10px] rounded-[10px] border border-emphasis bg-panel p-3">
|
||||
<div className="mt-[10px] rounded-tile border border-emphasis bg-panel p-3">
|
||||
<div className="mb-[10px] flex min-w-0 flex-wrap items-center gap-2">
|
||||
{LIB_TYPES.map((t) => (
|
||||
<Chip key={t.value} active={type === t.value} onClick={() => onType(t.value)}>
|
||||
|
|
@ -606,8 +596,7 @@ function LibraryPicker({ open, type, onType, query, onQuery, rows, loading, erro
|
|||
</Chip>
|
||||
))}
|
||||
<Field label="搜索" width="grow" className="max-w-[260px]">
|
||||
<input value={query} placeholder="名称 / 编号 / 标签"
|
||||
onChange={(e) => onQuery(e.target.value)} />
|
||||
<Input value={query} placeholder="名称 / 编号 / 标签" onChange={(e) => onQuery(e.target.value)} />
|
||||
</Field>
|
||||
<Button variant="outline" size="sm" disabled={loading} onClick={onRefresh}>刷新</Button>
|
||||
</div>
|
||||
|
|
@ -649,16 +638,13 @@ function LibraryPicker({ open, type, onType, query, onQuery, rows, loading, erro
|
|||
function LibCard({ row, on, onToggle }: { row: any; on: boolean; onToggle: () => void }) {
|
||||
const cover = coverOf(row)
|
||||
return (
|
||||
<button type="button" onClick={onToggle}
|
||||
className={cn('flex min-w-0 cursor-pointer items-center gap-[9px] rounded-tile border bg-card '
|
||||
+ 'p-2 text-left text-ink',
|
||||
on ? 'border-accent shadow-[inset_0_0_0_1px_var(--c-accent)]' : 'border-line hover:border-line-strong')}>
|
||||
<span className="grid h-10 w-[52px] flex-none place-items-center overflow-hidden rounded-[6px] bg-emphasis">
|
||||
{cover ? <MediaThumb item={fromAsset(cover)} size="xs" width="52px" radius={6} />
|
||||
: <b className="text-muted text-[17px]">{audioOfRow(row) ? '♪' : '◻'}</b>}
|
||||
<Tile variant="pick" onClick={onToggle} active={on} ariaLabel={`选择《${row.name}》`}>
|
||||
<span className="grid h-10 w-[52px] flex-none place-items-center overflow-hidden rounded-control bg-emphasis">
|
||||
{cover ? <MediaThumb item={fromAsset(cover)} size="xs" width="52px" />
|
||||
: <b className="text-muted text-h2">{audioOfRow(row) ? '♪' : '◻'}</b>}
|
||||
</span>
|
||||
<span className="grid min-w-0 flex-1 gap-px">
|
||||
<b className="block truncate text-[12px]">{row.name}</b>
|
||||
<b className="block truncate text-body">{row.name}</b>
|
||||
<small className={cn(MUTED, 'block truncate text-tiny')}>{subLabel(row) || row.type_label}</small>
|
||||
<small className={cn(MUTED, 'block truncate text-tiny')}>
|
||||
{(row.assets || []).length} 个素材
|
||||
|
|
@ -666,16 +652,16 @@ function LibCard({ row, on, onToggle }: { row: any; on: boolean; onToggle: () =>
|
|||
</small>
|
||||
</span>
|
||||
<span className="w-[18px] flex-none text-accent font-bold">{on ? '✓' : ''}</span>
|
||||
</button>
|
||||
</Tile>
|
||||
)
|
||||
}
|
||||
|
||||
/** 窄屏项目卡:表格里那些列,在手机上换成一张卡逐项列出 */
|
||||
function ProjectCard({ p, onRemove }: { p: any; onRemove: (p: any) => void }) {
|
||||
return (
|
||||
<article className="min-w-0 rounded-[10px] border border-emphasis bg-card p-3">
|
||||
<article className="min-w-0 rounded-tile border border-emphasis bg-card p-3">
|
||||
<div className="mb-[5px] flex min-w-0 flex-wrap items-start justify-between gap-2">
|
||||
{p.cover_url && <MediaThumb src={p.cover_url} size="xs" width="56px" radius={6} title={`${p.name} 首帧`} />}
|
||||
{p.cover_url && <MediaThumb src={p.cover_url} size="xs" width="56px" title={`${p.name} 首帧`} />}
|
||||
<Link to={`/projects/${p.id}/overview`} className={cn(LINK_CLS, 'min-w-0 flex-1 text-ink')}>
|
||||
<b>{p.name}</b>
|
||||
</Link>
|
||||
|
|
@ -696,8 +682,7 @@ function ProjectCard({ p, onRemove }: { p: any; onRemove: (p: any) => void }) {
|
|||
<ProgressBar className="w-full" value={Math.round((p.stats?.progress_ratio || 0) * 100)} />
|
||||
|
||||
<div className="mt-[10px] flex min-w-0 flex-wrap items-center gap-[10px] [--ctl-h:var(--ctl-h-md)]">
|
||||
<Link to={`/projects/${p.id}/overview`}
|
||||
className={buttonCls({ variant: 'outline', size: 'sm', className: 'no-underline' })}>进入项目 →</Link>
|
||||
<LinkButton to={`/projects/${p.id}/overview`} variant="outline" size="sm">进入项目 →</LinkButton>
|
||||
<Button variant="del" title="删除这个项目" onClick={() => onRemove(p)}>删除</Button>
|
||||
</div>
|
||||
</article>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import { ExtLink } from '../components/ui'
|
|||
|
||||
/** 页面外壳:行内强调、代码、链接的皮肤统一给一次,正文不重复贴类名 */
|
||||
const SHELL = 'min-w-0 [&_b]:font-semibold [&_b]:text-ink [&_a_code]:text-success [&_pre]:m-0'
|
||||
const PRE = 'mt-4 overflow-x-auto rounded-block border border-line bg-sunken p-[13px] text-[11.5px] leading-[1.8] text-ink-2 font-mono'
|
||||
const PRE = 'mt-4 overflow-x-auto rounded-block border border-line bg-sunken p-[13px] text-label leading-[1.8] text-ink-2 font-mono'
|
||||
const TOC_NAV = 'sticky top-[8px] z-[5] mb-7 flex flex-wrap items-center gap-2 rounded-block '
|
||||
+ 'border border-line bg-panel p-[11px] backdrop-blur'
|
||||
const TOC_LINK = 'rounded-chip border border-line-strong bg-sunken px-[10px] py-[5px] '
|
||||
|
|
@ -32,7 +32,7 @@ const TAG_H1 = 'text-display font-bold mt-0 mb-[9px] text-ink tracking-[-.03em]'
|
|||
const TAG_P = 'text-body text-dim leading-[1.85] max-w-[76ch] m-0 mt-[9px]'
|
||||
const TAG_SECTION = 'scroll-mt-[88px] mt-[46px] min-w-0 first:mt-0'
|
||||
const TAG_H2 = 'text-lg font-bold mt-[3px] mb-0 text-ink tracking-[-.02em]'
|
||||
const TAG_CODE = 'rounded-chip border border-line bg-sunken px-[5px] py-px text-[11px] text-accent-bright '
|
||||
const TAG_CODE = 'rounded-chip border border-line bg-sunken px-[5px] py-px text-caption text-accent-bright '
|
||||
+ 'font-mono'
|
||||
const TAG_A = 'text-success no-underline hover:underline'
|
||||
const TAG_IMG = 'block w-full rounded-tile border border-line-strong'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
import { useEffect, useRef, useState, type FormEvent } from 'react'
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import { SecretInput } from '../components/forms'
|
||||
import { Button } from '../components/ui'
|
||||
import { Button, Input, ToolButton } from '../components/ui'
|
||||
import { login, useAuthStore } from '../stores/auth'
|
||||
import { setTheme, useAppliedTheme } from '../stores/theme'
|
||||
|
||||
|
|
@ -57,35 +57,36 @@ export default function Login() {
|
|||
|
||||
return (
|
||||
<div className="grid min-h-screen place-items-center bg-[radial-gradient(900px_420px_at_50%_-8%,var(--c-accent-tint2),transparent_70%),var(--c-bg-app)] p-6">
|
||||
<button type="button" onClick={() => setTheme(isLight ? 'dark' : 'light')}
|
||||
{/* 和顶栏那颗是同一个动作、同一只控件(ui/Button 的 ToolButton),
|
||||
页面只负责把它钉在右上角 */}
|
||||
<ToolButton onClick={() => setTheme(isLight ? 'dark' : 'light')}
|
||||
className="fixed right-5 top-[18px]"
|
||||
aria-label={'切换明暗主题,当前为' + (isLight ? '浅色' : '深色')}
|
||||
className="fixed right-5 top-[18px] inline-flex h-(--ctl-h-md) items-center rounded-[8px] border border-line bg-sunken px-[11px] text-caption text-ink-2">
|
||||
{isLight ? '☀ 浅色' : '☾ 深色'}
|
||||
</button>
|
||||
title={'显示模式:' + (isLight ? '浅色' : '深色')}>
|
||||
<i aria-hidden="true" className="not-italic">{isLight ? '☀' : '☾'}</i><span>{isLight ? '浅色' : '深色'}</span>
|
||||
</ToolButton>
|
||||
|
||||
<form className="w-[min(392px,100%)] rounded-float border border-line bg-panel px-6 pb-[22px] pt-[26px] shadow-[0_24px_60px_var(--c-shade-3)]" onSubmit={submit}>
|
||||
<div className="flex items-center gap-2.5 pb-[18px] text-caption font-bold tracking-[1px] text-ink-2">
|
||||
<b aria-hidden="true" className="grid h-[37px] w-[37px] place-items-center rounded-[11px] bg-accent-fill text-[22px] text-on-accent">N</b>
|
||||
<b aria-hidden="true" className="grid h-[37px] w-[37px] place-items-center rounded-tile bg-accent-fill text-num-sm text-on-accent">N</b>
|
||||
<span>长视频编导平台</span>
|
||||
</div>
|
||||
|
||||
<h1 className="mb-[18px] mt-0 text-h2 font-bold" title="账号决定你能做什么:管理员管模型与账号,制作可以跑生产,观摩只读。">登录以继续</h1>
|
||||
|
||||
{params.get('loggedOut') === '1' && (
|
||||
<p className="mb-1 rounded-[8px] border border-line bg-info-tint px-[10px] py-[9px] text-caption text-info">已退出登录。</p>
|
||||
<p className="mb-1 rounded-tile border border-line bg-info-tint px-[10px] py-[9px] text-caption text-info">已退出登录。</p>
|
||||
)}
|
||||
{offline && (
|
||||
<p className="mb-1 rounded-[8px] border border-danger-line bg-danger-tint px-[10px] py-[9px] text-caption text-danger">后端连接不上:{connError || '请确认服务已启动'}</p>
|
||||
<p className="mb-1 rounded-tile border border-danger-line bg-danger-tint px-[10px] py-[9px] text-caption text-danger">后端连接不上:{connError || '请确认服务已启动'}</p>
|
||||
)}
|
||||
{error && (
|
||||
<p className="mb-1 rounded-[8px] border border-danger-line bg-danger-tint px-[10px] py-[9px] text-caption text-danger">{error}</p>
|
||||
<p className="mb-1 rounded-tile border border-danger-line bg-danger-tint px-[10px] py-[9px] text-caption text-danger">{error}</p>
|
||||
)}
|
||||
|
||||
<label className="mb-[10px] flex flex-col gap-[5px] text-caption">
|
||||
<span className="text-muted">用户名</span>
|
||||
<input id="login-user" ref={userRef} value={form.username} autoComplete="username" spellCheck={false}
|
||||
placeholder={'如 ' + (user?.username || 'admin')}
|
||||
onChange={(e) => setForm((f) => ({ ...f, username: e.target.value }))} />
|
||||
<Input id="login-user" ref={userRef} value={form.username} autoComplete="username" spellCheck={false} placeholder={'如 ' + (user?.username || 'admin')} onChange={(e) => setForm((f) => ({ ...f, username: e.target.value }))} />
|
||||
</label>
|
||||
<label className="mb-[10px] flex flex-col gap-[5px] text-caption">
|
||||
<span className="text-muted">密码</span>
|
||||
|
|
@ -98,7 +99,7 @@ export default function Login() {
|
|||
<Button type="submit" variant="primary" size="lg" disabled={busy} className="mt-4 w-full">
|
||||
{busy ? '正在验证…' : '登录'}
|
||||
</Button>
|
||||
<p className="mt-[14px] mb-0 text-center text-[10.5px] text-faint">忘记密码请联系平台管理员在「用户管理」里重置。</p>
|
||||
<p className="mt-[14px] mb-0 text-center text-tiny text-faint">忘记密码请联系平台管理员在「用户管理」里重置。</p>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,16 +13,12 @@
|
|||
*/
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import * as api from '../api/client'
|
||||
import { fmtAgo, fmtSeconds } from '../lib/format'
|
||||
import { useAutoRefresh } from '../hooks'
|
||||
import { cn } from '../lib/cn'
|
||||
import { EyeIcon, SecretInput, Select } from '../components/forms'
|
||||
import {
|
||||
Between, Button, Check, Chip, ChipBar, Ctlbar, Drawer, Empty, Field, FieldBlock, FormGrid, FormRow, Grid, MONO,
|
||||
MUTED, Notice, PageHead, Panel, PanelHead, Row, SectionTitle, Slider, Spinner, Tag, TagGroup, buttonCls
|
||||
} from '../components/ui'
|
||||
import { Between, Button, Check, Chip, ChipBar, Ctlbar, Drawer, Empty, Field, FieldBlock, FormGrid, FormRow, Grid, Input, LinkButton, MONO, MUTED, Notice, NumberInput, PageHead, Panel, PanelHead, Row, SectionTitle, Slider, Spinner, Stat, StatGrid, Tag, TagGroup, TextArea, IconSpot, Rail, RAIL_GRID, RailItem, RailNote } from '../components/ui'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import { useProjectStore } from '../stores/project'
|
||||
|
||||
|
|
@ -43,7 +39,7 @@ const TOKEN_OPTIONS = [4096, 8192, 16384, 32768]
|
|||
const QWEN_SIGMAS = '1.0, 0.978453, 0.95418, 0.926626, 0.89508, 0.845148, 0.704534, 0.414568, 0'
|
||||
|
||||
/** 卡片上的等宽小字(.model-id / .sub-id / .file-chip 三档只差字号与颜色) */
|
||||
const ID_MONO = cn(MONO, 'text-[11.5px] leading-[1.45] [overflow-wrap:anywhere]')
|
||||
const ID_MONO = cn(MONO, 'text-label leading-[1.45] [overflow-wrap:anywhere]')
|
||||
|
||||
/** 抽屉底部动作条挂在 Drawer 的 footer 上,用 form 关联回正文里的 <form>,回车仍是保存 */
|
||||
const FORM_ID = 'model-register-form'
|
||||
|
|
@ -518,7 +514,7 @@ export default function ModelCenter() {
|
|||
title={<span title="本地 H3、Qwen-Image 与 IndexTTS2 共用一张 GPU;大模型通过 OpenAI 兼容接口接入。配置按能力拆分,密钥只加密保存并以掩码回显。">模型控制台</span>}
|
||||
actions={<>
|
||||
{dispatchLink && (
|
||||
<Link to={dispatchLink} className={buttonCls({ variant: 'outline', className: 'no-underline' })}>任务调度 →</Link>
|
||||
<LinkButton to={dispatchLink} variant="outline">任务调度 →</LinkButton>
|
||||
)}
|
||||
<Button variant="primary" onClick={addModel}>+ 添加{rail(selectedType).label}</Button>
|
||||
</>}
|
||||
|
|
@ -528,19 +524,20 @@ export default function ModelCenter() {
|
|||
{notice && <Notice onClose={() => setNotice('')}>{notice}</Notice>}
|
||||
|
||||
{/* 全库口径的四张卡:这张注册表与「当前项目」无关,所以汇总也不能跟着项目走 */}
|
||||
<div className="grid min-w-0 gap-[10px] mb-[14px] grid-cols-4 max-mid:grid-cols-2 max-short:grid-cols-1 max-narrow:grid-cols-2 [&>*]:min-w-0">
|
||||
<SummaryCell label="全库模型配置" value={providers.length}
|
||||
hint={`${types.length} 类能力 · 所有项目共用,与当前项目无关`} />
|
||||
<SummaryCell label="已启用" value={<>{enabledCount}<i>/{providers.length}</i></>}
|
||||
hint="只有启用项会被工作流与调度选用" />
|
||||
<SummaryCell warn={availableCount < enabledCount} label="启用且可达"
|
||||
value={<>{availableCount}<i>/{enabledCount}</i></>}
|
||||
hint={availableCount < enabledCount
|
||||
? `另有 ${enabledCount - availableCount} 个启用模型探测失败,见卡片状态`
|
||||
: '全部启用模型均通过连接探测'} />
|
||||
<SummaryCell accent label={`当前默认 · ${rail(selectedType).label}`} value={defaultRow?.display_name || '未设置'}
|
||||
hint={`台账累计 ${usageTotal.calls} 次调用 · ${usageTotal.assets} 个素材 · ${fmtSeconds(usageTotal.seconds)}`} />
|
||||
</div>
|
||||
<StatGrid cols={4} className="mb-[14px]" steps={[{ at: 'mid', cols: 2 }, { at: 'short', cols: 1 }, { at: 'narrow', cols: 2 }]}>
|
||||
<Stat label="全库模型配置" value={providers.length}
|
||||
hint={`${types.length} 类能力 · 所有项目共用,与当前项目无关`} />
|
||||
<Stat label="已启用" value={<>{enabledCount}<i>/{providers.length}</i></>}
|
||||
hint="只有启用项会被工作流与调度选用" />
|
||||
<Stat tone={availableCount < enabledCount ? 'warn' : undefined} label="启用且可达"
|
||||
value={<>{availableCount}<i>/{enabledCount}</i></>}
|
||||
hint={availableCount < enabledCount
|
||||
? `另有 ${enabledCount - availableCount} 个启用模型探测失败,见卡片状态`
|
||||
: '全部启用模型均通过连接探测'} />
|
||||
<Stat tone="lead" valueSize="title" label={`当前默认 · ${rail(selectedType).label}`}
|
||||
value={defaultRow?.display_name || '未设置'}
|
||||
hint={`台账累计 ${usageTotal.calls} 次调用 · ${usageTotal.assets} 个素材 · ${fmtSeconds(usageTotal.seconds)}`} />
|
||||
</StatGrid>
|
||||
|
||||
{faultInjected.length > 0 && (
|
||||
<Notice>
|
||||
|
|
@ -550,31 +547,22 @@ export default function ModelCenter() {
|
|||
</Notice>
|
||||
)}
|
||||
|
||||
<div className="grid min-w-0 items-start gap-[13px] grid-cols-[236px_minmax(0,1fr)] max-mid:grid-cols-[190px_minmax(0,1fr)] max-short:grid-cols-1 [&>*]:min-w-0">
|
||||
<aside className="sticky top-[14px] flex flex-col gap-1.5 p-2 bg-card border border-line rounded-float min-w-0 max-short:static max-short:grid max-short:grid-cols-2">
|
||||
<div className={RAIL_GRID}>
|
||||
<Rail>
|
||||
{types.map((type: string) => {
|
||||
const meta = rail(type)
|
||||
return (
|
||||
<button key={type} type="button" onClick={() => chooseType(type)}
|
||||
className={cn('flex items-center gap-2.5 w-full min-w-0 text-left text-ink-3 border border-transparent '
|
||||
+ 'bg-transparent rounded-tile p-[11px_9px] hover:bg-panel',
|
||||
selectedType === type && 'bg-raised border-success-line shadow-[inset_3px_0_0_var(--c-accent)]')}>
|
||||
<span className={cn('grid place-items-center w-[29px] h-[29px] shrink-0 rounded-control bg-line-soft text-[15px]', meta.color)}>
|
||||
{meta.icon}
|
||||
</span>
|
||||
<span className="min-w-0">
|
||||
<b className="block text-body">{meta.label}</b>
|
||||
<small className="block text-dim text-tiny mt-[3px] leading-[1.3]">{meta.hint}</small>
|
||||
</span>
|
||||
<em className="ml-auto text-warn-bright not-italic text-h2">{countOf(type)}</em>
|
||||
</button>
|
||||
<RailItem key={type} onClick={() => chooseType(type)} active={selectedType === type}
|
||||
icon={meta.icon} iconClass={meta.color} label={meta.label}
|
||||
hint={meta.hint} count={countOf(type)} tone="warn"
|
||||
ariaLabel={`${meta.label}分类,共 ${countOf(type)} 个模型`} />
|
||||
)
|
||||
})}
|
||||
<div className="border-t border-active pt-[19px] pb-[5px] px-[7px] max-short:col-span-2">
|
||||
<RailNote>
|
||||
<b title="H3 / Qwen-Image / IndexTTS2 统一归属 comfyui:9200 ,平台会在模型适配器层持有 GPU 锁,避免显存争抢。"
|
||||
className="text-accent text-tiny">同卡串行</b>
|
||||
</div>
|
||||
</aside>
|
||||
</RailNote>
|
||||
</Rail>
|
||||
|
||||
<section className="min-w-0">
|
||||
<Panel className="bg-shell">
|
||||
|
|
@ -583,8 +571,7 @@ export default function ModelCenter() {
|
|||
right={
|
||||
<Ctlbar className="mb-0">
|
||||
<Field label="搜索" width="grow">
|
||||
<input value={keyword} aria-label="搜索模型" placeholder="名称 / 模型标识 / 编码"
|
||||
onChange={(e) => setKeyword(e.target.value)} />
|
||||
<Input value={keyword} aria-label="搜索模型" placeholder="名称 / 模型标识 / 编码" onChange={(e) => setKeyword(e.target.value)} />
|
||||
</Field>
|
||||
</Ctlbar>
|
||||
} />
|
||||
|
|
@ -605,7 +592,7 @@ export default function ModelCenter() {
|
|||
)}
|
||||
|
||||
{probe && (
|
||||
<div className="mt-3 p-[13px] rounded-[10px] border border-accent-line bg-card min-w-0">
|
||||
<div className="mt-3 p-[13px] rounded-tile border border-accent-line bg-card min-w-0">
|
||||
<Between>
|
||||
<Row>
|
||||
<Tag tone={(probe.reachable ?? probe.available) ? 'ok' : 'bad'}>
|
||||
|
|
@ -659,13 +646,14 @@ export default function ModelCenter() {
|
|||
{busy && <span className={cn('inline-flex items-center gap-1.5', MUTED)}><Spinner /> {busy}…</span>}
|
||||
</>}>
|
||||
<form id={FORM_ID} className="min-w-0" onSubmit={(e) => { e.preventDefault(); void save() }}>
|
||||
<FormGrid>
|
||||
{/* 锁 76px:这张表同时有 FieldBlock(标签在上)和行内 Field(Temperature / 并发 / RPM)。
|
||||
行内标签只要有一个超过 66px 下限,整表控件左边界就错开(900px 实测 2px)。 */}
|
||||
<FormGrid labelWidth={76}>
|
||||
{form.media_type === 'llm' && (
|
||||
<>
|
||||
<DrawerSection first title="供应商连接" note="OpenAI 兼容协议">
|
||||
<FieldBlock label="Base URL" required>
|
||||
<input value={form.base_url} placeholder="https://coding.dashscope.aliyuncs.com/v1"
|
||||
onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
<Input value={form.base_url} placeholder="https://coding.dashscope.aliyuncs.com/v1" onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="API Key">
|
||||
<SecretInput title="列表只回显掩码;点右侧图标会向后端取一次真实密钥并显示(仅管理员,留痕)。"
|
||||
|
|
@ -708,52 +696,47 @@ export default function ModelCenter() {
|
|||
title={form.media_type === 'video' ? 'ComfyUI 视频工作流' : 'Qwen-Image 本地工作流'}
|
||||
note="9200 单卡">
|
||||
<FieldBlock label="ComfyUI Base URL">
|
||||
<input value={form.base_url} placeholder="http://10.100.53.199:9200"
|
||||
onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
<Input value={form.base_url} placeholder="http://10.100.53.199:9200" onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow cols={2} stack>
|
||||
<Field label={form.media_type === 'video' ? '扩散模型(UNET GGUF)' : 'GGUF 扩散模型'}>
|
||||
<input value={form.unet} onChange={(e) => patch({ unet: e.target.value })} />
|
||||
<Input value={form.unet} onChange={(e) => patch({ unet: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="文本编码器">
|
||||
<input value={form.clip} onChange={(e) => patch({ clip: e.target.value })} />
|
||||
<Input value={form.clip} onChange={(e) => patch({ clip: e.target.value })} />
|
||||
</Field>
|
||||
<Field label={form.media_type === 'video' ? '视频 VAE' : '图像 VAE'}>
|
||||
<input value={form.vae} onChange={(e) => patch({ vae: e.target.value })} />
|
||||
<Input value={form.vae} onChange={(e) => patch({ vae: e.target.value })} />
|
||||
</Field>
|
||||
{form.media_type === 'video' && (
|
||||
<Field label="音频 VAE">
|
||||
<input value={form.audio_vae} onChange={(e) => patch({ audio_vae: e.target.value })} />
|
||||
<Input value={form.audio_vae} onChange={(e) => patch({ audio_vae: e.target.value })} />
|
||||
</Field>
|
||||
)}
|
||||
<Field label="CLIP 类型">
|
||||
<input value={form.clip_type} onChange={(e) => patch({ clip_type: e.target.value })} />
|
||||
<Input value={form.clip_type} onChange={(e) => patch({ clip_type: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="工作流模板">
|
||||
<input value={form.workflow} onChange={(e) => patch({ workflow: e.target.value })} />
|
||||
<Input value={form.workflow} onChange={(e) => patch({ workflow: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="采样器">
|
||||
<input value={form.sampler} onChange={(e) => patch({ sampler: e.target.value })} />
|
||||
<Input value={form.sampler} onChange={(e) => patch({ sampler: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="步数">
|
||||
<input type="number" min={1} value={form.steps}
|
||||
onChange={(e) => patch({ steps: numOf(e.target.value) })} />
|
||||
<NumberInput min={1} value={form.steps} onChange={ (v) => patch({ steps: v })} />
|
||||
</Field>
|
||||
{form.media_type === 'image' && (
|
||||
<Field label="CFG">
|
||||
<input type="number" step={0.1} value={form.cfg}
|
||||
onChange={(e) => patch({ cfg: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.1} value={form.cfg} onChange={ (v) => patch({ cfg: v })} />
|
||||
</Field>
|
||||
)}
|
||||
<Field label="FPS">
|
||||
<input type="number" min={1} value={form.fps}
|
||||
onChange={(e) => patch({ fps: numOf(e.target.value) })} />
|
||||
<NumberInput min={1} value={form.fps} onChange={ (v) => patch({ fps: v })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
{form.media_type === 'image' && (
|
||||
<FieldBlock label="固定 Sigma 序列">
|
||||
<textarea rows={2} className={MONO} value={form.sigmas}
|
||||
onChange={(e) => patch({ sigmas: e.target.value })} />
|
||||
<TextArea rows={2} className={MONO} value={form.sigmas} onChange={(e) => patch({ sigmas: e.target.value })} />
|
||||
</FieldBlock>
|
||||
)}
|
||||
</DrawerSection>
|
||||
|
|
@ -762,12 +745,11 @@ export default function ModelCenter() {
|
|||
{form.media_type === 'tts' && (
|
||||
<DrawerSection first title="IndexTTS2 本地推理" note="Zero-shot 音色克隆">
|
||||
<FieldBlock label="ComfyUI Base URL">
|
||||
<input value={form.base_url} placeholder="http://10.100.53.199:9200"
|
||||
onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
<Input value={form.base_url} placeholder="http://10.100.53.199:9200" onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow cols={2} stack>
|
||||
<Field label="模型目录标识">
|
||||
<input value={form.tts_model} onChange={(e) => patch({ tts_model: e.target.value })} />
|
||||
<Input value={form.tts_model} onChange={(e) => patch({ tts_model: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="模型来源">
|
||||
<Select value={form.download_from} onChange={(v) => patch({ download_from: v })}
|
||||
|
|
@ -776,11 +758,11 @@ export default function ModelCenter() {
|
|||
{ value: 'local', label: '仅本地' }]} />
|
||||
</Field>
|
||||
<Field label="工作流模板">
|
||||
<input value={form.workflow} onChange={(e) => patch({ workflow: e.target.value })} />
|
||||
<Input value={form.workflow} onChange={(e) => patch({ workflow: e.target.value })} />
|
||||
</Field>
|
||||
<Field title="声线资产中的「供应商音色 ID」可填 ComfyUI input 文件名,或客户端本地音频路径;平台会自动上传本地参考音频。"
|
||||
label="参考音频">
|
||||
<input value={form.reference_audio} onChange={(e) => patch({ reference_audio: e.target.value })} />
|
||||
<Input value={form.reference_audio} onChange={(e) => patch({ reference_audio: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
</DrawerSection>
|
||||
|
|
@ -789,11 +771,10 @@ export default function ModelCenter() {
|
|||
{!['llm', 'video', 'image', 'tts'].includes(form.media_type) && (
|
||||
<DrawerSection first title="旧版文本接口" note="兼容保留">
|
||||
<FieldBlock label="Base URL">
|
||||
<input value={form.base_url} onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
<Input value={form.base_url} onChange={(e) => patch({ base_url: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="自定义端点">
|
||||
<input value={form.endpoint} placeholder="可留空,默认 /chat/completions"
|
||||
onChange={(e) => patch({ endpoint: e.target.value })} />
|
||||
<Input value={form.endpoint} placeholder="可留空,默认 /chat/completions" onChange={(e) => patch({ endpoint: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</DrawerSection>
|
||||
)}
|
||||
|
|
@ -801,10 +782,10 @@ export default function ModelCenter() {
|
|||
<DrawerSection title="模型身份与调度" note="所有能力通用,仅在此处填写一次">
|
||||
<FormRow cols={3} stack>
|
||||
<Field label="显示名称" required>
|
||||
<input value={form.display_name} onChange={(e) => patch({ display_name: e.target.value })} />
|
||||
<Input value={form.display_name} onChange={(e) => patch({ display_name: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="供应商标识">
|
||||
<input value={form.provider} onChange={(e) => patch({ provider: e.target.value })} />
|
||||
<Input value={form.provider} onChange={(e) => patch({ provider: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="适配器">
|
||||
{/* 能力由左栏决定,抽屉里不切换媒体类型,所以适配器下拉只需要给出本能力的候选 */}
|
||||
|
|
@ -812,34 +793,29 @@ export default function ModelCenter() {
|
|||
options={adapters[form.media_type] || []} />
|
||||
</Field>
|
||||
<Field label="模型标识" required>
|
||||
<input value={form.model} onChange={(e) => patch({ model: e.target.value })} />
|
||||
<Input value={form.model} onChange={(e) => patch({ model: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="模型编码" required>
|
||||
<input value={form.model_code} onChange={(e) => patch({ model_code: e.target.value })} />
|
||||
<Input value={form.model_code} onChange={(e) => patch({ model_code: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="超时(秒)">
|
||||
<input type="number" min={1} value={form.timeout_seconds}
|
||||
onChange={(e) => patch({ timeout_seconds: numOf(e.target.value) })} />
|
||||
<NumberInput min={1} value={form.timeout_seconds} onChange={ (v) => patch({ timeout_seconds: v })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<FormRow cols={4} stack tight>
|
||||
<Field label="并发">
|
||||
<input type="number" min={1} value={form.max_concurrency}
|
||||
onChange={(e) => patch({ max_concurrency: numOf(e.target.value) })} />
|
||||
<NumberInput min={1} value={form.max_concurrency} onChange={ (v) => patch({ max_concurrency: v })} />
|
||||
</Field>
|
||||
<Field label="RPM">
|
||||
<input type="number" min={1} value={form.requests_per_minute}
|
||||
onChange={(e) => patch({ requests_per_minute: numOf(e.target.value) })} />
|
||||
<NumberInput min={1} value={form.requests_per_minute} onChange={ (v) => patch({ requests_per_minute: v })} />
|
||||
</Field>
|
||||
{form.media_type !== 'llm' && form.media_type !== 'image' && (
|
||||
<>
|
||||
<Field label="最短时长">
|
||||
<input type="number" step={0.5} value={form.min_duration}
|
||||
onChange={(e) => patch({ min_duration: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.5} value={form.min_duration} onChange={ (v) => patch({ min_duration: v })} />
|
||||
</Field>
|
||||
<Field label="最长时长">
|
||||
<input type="number" step={0.5} value={form.max_duration}
|
||||
onChange={(e) => patch({ max_duration: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.5} value={form.max_duration} onChange={ (v) => patch({ max_duration: v })} />
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
|
|
@ -849,8 +825,7 @@ export default function ModelCenter() {
|
|||
<Check checked={form.is_default} onChange={(v) => patch({ is_default: v })}>设为该能力默认</Check>
|
||||
</Row>
|
||||
<FieldBlock label="备注">
|
||||
<textarea rows={2} placeholder="模型约束、显存策略或接入说明" value={form.notes}
|
||||
onChange={(e) => patch({ notes: e.target.value })} />
|
||||
<TextArea rows={2} placeholder="模型约束、显存策略或接入说明" value={form.notes} onChange={(e) => patch({ notes: e.target.value })} />
|
||||
</FieldBlock>
|
||||
|
||||
<Button variant="outline" onClick={toggleAdvanced}
|
||||
|
|
@ -861,12 +836,10 @@ export default function ModelCenter() {
|
|||
/* 两块的比例是本页特有的(config 比 default_params 长得多),栅格本身仍是栅格 */
|
||||
<div className="grid gap-[10px] grid-cols-[1.3fr_1fr] max-short:grid-cols-1 mt-3 min-w-0 [&>*]:min-w-0">
|
||||
<FieldBlock label="config JSON">
|
||||
<textarea rows={8} spellCheck={false} className={MONO} value={form.extra_config}
|
||||
onChange={(e) => patch({ extra_config: e.target.value })} />
|
||||
<TextArea rows={8} spellCheck={false} className={MONO} value={form.extra_config} onChange={(e) => patch({ extra_config: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="default_params JSON">
|
||||
<textarea rows={6} spellCheck={false} className={MONO} value={form.extra_params}
|
||||
onChange={(e) => patch({ extra_params: e.target.value })} />
|
||||
<TextArea rows={6} spellCheck={false} className={MONO} value={form.extra_params} onChange={(e) => patch({ extra_params: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -898,33 +871,6 @@ function DrawerSection({ title, note, first, children }: {
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 顶部汇总卡(.summary > div)。
|
||||
*
|
||||
* 比共享 <Stat> 多的只有「渐变底 + 右上角一层青柠光晕」:这四张说的是整张注册表的
|
||||
* 健康度,要压过页面里其它指标一档。这属于本页特例,就没去改全站共用的 Stat。
|
||||
*/
|
||||
function SummaryCell({ label, value, hint, warn, accent }: {
|
||||
label: ReactNode; value: ReactNode; hint?: ReactNode; warn?: boolean; accent?: boolean
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('relative overflow-hidden rounded-block p-[14px_16px] min-h-[92px] min-w-0',
|
||||
'bg-[linear-gradient(145deg,var(--c-bg-panel),var(--c-bg-shell))] border border-line max-narrow:p-3 max-narrow:min-h-[82px]',
|
||||
accent && 'border-success-line bg-[linear-gradient(145deg,var(--c-bg-raised),var(--c-bg-panel))]',
|
||||
warn && 'border-warn-line bg-[linear-gradient(145deg,var(--c-warn-tint),var(--c-bg-shell))]')}>
|
||||
<span className="pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_106%_132%,var(--c-tint-accent),transparent_58%)]" />
|
||||
<span className="relative block text-faint text-tiny tracking-[.4px]">{label}</span>
|
||||
<b className={cn('relative block text-ink text-num mt-[7px] mb-[2px] leading-[1.1] '
|
||||
+ '[&_i]:text-faint [&_i]:text-[14px] [&_i]:not-italic [&_i]:font-medium [&_i]:ml-[3px]',
|
||||
accent && 'text-accent-bright text-h2 overflow-hidden text-ellipsis whitespace-nowrap',
|
||||
warn && 'text-warn-bright')}>
|
||||
{value}
|
||||
</b>
|
||||
{hint && <small className="relative block text-dim text-tiny">{hint}</small>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型卡:标识与就绪状态 → 密钥/资源地址 → 权重文件 → 能力标签 → 台账用量 → 四个动作。
|
||||
*
|
||||
|
|
@ -954,12 +900,12 @@ function ModelCard({ row, rail, busy, canReveal, revealed, revealing, probing,
|
|||
const shown = revealed || keyLabel(row)
|
||||
const eyeTitle = revealed ? '隐藏密钥' : !canReveal ? '密钥明文仅管理员可查看' : '显示密钥:读取已保存的明文'
|
||||
return (
|
||||
<article className={cn('flex flex-col min-h-[230px] p-[14px] min-w-0 rounded-[11px] border border-emphasis',
|
||||
<article className={cn('flex flex-col min-h-[230px] p-[14px] min-w-0 rounded-tile border border-emphasis',
|
||||
'bg-[linear-gradient(145deg,var(--c-bg-panel),var(--c-bg-sunken))] '
|
||||
+ 'transition-[border-color,transform] duration-150 hover:border-line-bright hover:-translate-y-px',
|
||||
!row.enabled && 'opacity-60')}>
|
||||
<div className="flex items-start gap-2.5 min-w-0">
|
||||
<div className={cn('grid place-items-center w-9 h-9 flex-none rounded-tile bg-line-soft text-[17px]', meta.color)}>
|
||||
<div className={cn('grid place-items-center w-9 h-9 flex-none rounded-tile bg-line-soft text-h2', meta.color)}>
|
||||
{meta.icon}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
|
|
@ -992,14 +938,11 @@ function ModelCard({ row, rail, busy, canReveal, revealed, revealing, probing,
|
|||
revealed && 'whitespace-normal overflow-visible text-ink [overflow-wrap:anywhere]')}>
|
||||
{shown}
|
||||
</b>
|
||||
{/* 24px 图标位(比控件小一档):皮肤在 ui/Button 的 IconSpot 里 */}
|
||||
{row.has_api_key && (
|
||||
<button type="button" onClick={onReveal} disabled={revealing} title={eyeTitle} aria-label={eyeTitle}
|
||||
className={cn('grid place-items-center w-6 h-6 flex-none p-0 cursor-pointer border border-line '
|
||||
+ 'rounded-[6px] bg-raise text-ink-3 hover:text-ink hover:border-line-strong '
|
||||
+ 'disabled:opacity-60 disabled:cursor-progress',
|
||||
revealed && 'text-accent-bright border-accent-line bg-accent-tint-2')}>
|
||||
<IconSpot onClick={onReveal} disabled={revealing} label={eyeTitle} active={!!revealed}>
|
||||
<EyeIcon shown={!!revealed} loading={revealing} />
|
||||
</button>
|
||||
</IconSpot>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ import * as api from '../api/client'
|
|||
import { allNodesDone, stageNote } from '../lib/pipeline'
|
||||
import { fmtMoney, pct, statusLabel } from '../lib/format'
|
||||
import { cn } from '../lib/cn'
|
||||
import {
|
||||
Button, Empty, ErrorText, Loading, Notice, Panel, PanelHead, Stat, StatGrid, Status, Tag, Value
|
||||
} from '../components/ui'
|
||||
import { Button, Empty, ErrorText, Loading, Notice, Panel, PanelHead, Stat, StatGrid, Status, Tag, Tile, Value } from '../components/ui'
|
||||
import { WorkflowBar } from '../components/media/WorkflowBar'
|
||||
import { loadProject, startPolling, stopPolling, useBriefStore, useProjectStore } from '../stores/project'
|
||||
|
||||
|
|
@ -103,9 +101,9 @@ export default function ProjectDetail() {
|
|||
)}
|
||||
|
||||
{/* 折叠条在所有断点都可用:收起后这一行本身就是紧凑摘要,正文直接顶到首屏 */}
|
||||
<button aria-expanded={summaryOpen} onClick={() => setSummaryOpen(!summaryOpen)}
|
||||
className="mb-[14px] flex w-full items-center gap-2 rounded-tile border border-line-strong bg-panel px-3 py-[10px] text-left text-ink-2 hover:border-accent-line hover:bg-card">
|
||||
<span className="flex-none text-[11px] font-bold">项目概况</span>
|
||||
<Tile variant="bar" onClick={() => setSummaryOpen(!summaryOpen)} expanded={summaryOpen}
|
||||
className="mb-[14px] text-ink-2">
|
||||
<span className="flex-none text-caption font-bold">项目概况</span>
|
||||
<small className="min-w-0 flex-1 truncate text-muted text-tiny">
|
||||
{statusLabel(project.status)} · 镜头 {st.shots_approved || 0}/{st.shots || 0} · 合格 {pct(st.progress_ratio)}
|
||||
{' '}· 任务 {st.tasks_active || 0}/{st.tasks || 0} · 成本 {fmtMoney(st.cost?.total_cost, st.cost?.currency)}
|
||||
|
|
@ -113,7 +111,7 @@ export default function ProjectDetail() {
|
|||
<b className="flex-none whitespace-nowrap text-accent text-tiny">
|
||||
{summaryOpen ? '收起概况 ⌃' : '展开概况 ⌄'}
|
||||
</b>
|
||||
</button>
|
||||
</Tile>
|
||||
|
||||
<div className={cn('min-w-0', summaryOpen ? 'mb-[18px]' : 'hidden')}>
|
||||
<StatGrid cols={4}>
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ import * as api from '../api/client'
|
|||
import { fmtAgo, fmtTime } from '../lib/format'
|
||||
import { useAutoRefresh } from '../hooks'
|
||||
import { SecretInput, Select } from '../components/forms'
|
||||
import {
|
||||
Actions, Badge, Button, Check, Ctlbar, Empty, ErrorText, Field, FieldBlock, FormRow, Layout, MUTED,
|
||||
MUTED_MONO, PageHead, Panel, PanelHead, Stack, Stat, StatGrid, Sub, Table, TableBox, Tag, cellRight
|
||||
} from '../components/ui'
|
||||
import { Actions, Badge, Button, Check, Ctlbar, Empty, ErrorText, Field, FieldBlock, FormRow, Input, Layout, MUTED, MUTED_MONO, PageHead, Panel, PanelHead, Stack, Stat, StatGrid, Sub, Table, TableBox, Tag, TextArea, cellRight } from '../components/ui'
|
||||
import { notify, notifyBad } from '../stores/notice'
|
||||
import { roleLabel, useAuthStore } from '../stores/auth'
|
||||
|
||||
|
|
@ -176,7 +173,7 @@ export default function UserAdmin() {
|
|||
<PanelHead title="账号列表" right={<Badge>{visible.length}</Badge>} />
|
||||
<Ctlbar>
|
||||
<Field label="搜索" width="grow">
|
||||
<input value={keyword} placeholder="用户名 / 姓名 / 邮箱 / 备注" onChange={(e) => setKeyword(e.target.value)} />
|
||||
<Input value={keyword} placeholder="用户名 / 姓名 / 邮箱 / 备注" onChange={(e) => setKeyword(e.target.value)} />
|
||||
</Field>
|
||||
<Field label="角色" width="narrow">
|
||||
<Select size="sm" ariaLabel="按角色筛选" value={roleFilter} onChange={setRoleFilter}
|
||||
|
|
@ -217,15 +214,13 @@ export default function UserAdmin() {
|
|||
<PanelHead title="新建账号" />
|
||||
<FormRow cols={2}>
|
||||
<Field label="用户名" required hint="登录用,小写字母或数字,创建后不可改">
|
||||
<input value={create.username} maxLength={60} placeholder="例如 zhangsan"
|
||||
onChange={(e) => setCreate((f) => ({ ...f, username: e.target.value }))} />
|
||||
<Input value={create.username} maxLength={60} placeholder="例如 zhangsan" onChange={(e) => setCreate((f) => ({ ...f, username: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="显示名">
|
||||
<input value={create.display_name} maxLength={80} onChange={(e) => setCreate((f) => ({ ...f, display_name: e.target.value }))} />
|
||||
<Input value={create.display_name} maxLength={80} onChange={(e) => setCreate((f) => ({ ...f, display_name: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="邮箱">
|
||||
<input value={create.email} maxLength={160} placeholder="用于通知,可留空"
|
||||
onChange={(e) => setCreate((f) => ({ ...f, email: e.target.value }))} />
|
||||
<Input value={create.email} maxLength={160} placeholder="用于通知,可留空" onChange={(e) => setCreate((f) => ({ ...f, email: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="角色">
|
||||
<Select value={create.role} onChange={(v) => setCreate((f) => ({ ...f, role: v }))} options={roleOptions} />
|
||||
|
|
@ -235,8 +230,7 @@ export default function UserAdmin() {
|
|||
onChange={(v) => setCreate((f) => ({ ...f, password: v }))} />
|
||||
</Field>
|
||||
<Field label="备注">
|
||||
<input value={create.note} maxLength={200} placeholder="例如:外包配音,仅本项目"
|
||||
onChange={(e) => setCreate((f) => ({ ...f, note: e.target.value }))} />
|
||||
<Input value={create.note} maxLength={200} placeholder="例如:外包配音,仅本项目" onChange={(e) => setCreate((f) => ({ ...f, note: e.target.value }))} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Actions><Button variant="primary" disabled={!!busy} onClick={createUser}>创建账号</Button></Actions>
|
||||
|
|
@ -268,11 +262,10 @@ export default function UserAdmin() {
|
|||
right={<Tag tone="mono">#{selected.id}</Tag>} />
|
||||
<FormRow cols={2} stack>
|
||||
<Field label="显示名">
|
||||
<input value={edit.display_name} maxLength={80} onChange={(e) => setEdit((f) => ({ ...f, display_name: e.target.value }))} />
|
||||
<Input value={edit.display_name} maxLength={80} onChange={(e) => setEdit((f) => ({ ...f, display_name: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="邮箱">
|
||||
<input value={edit.email} maxLength={160} placeholder="用于通知,可留空"
|
||||
onChange={(e) => setEdit((f) => ({ ...f, email: e.target.value }))} />
|
||||
<Input value={edit.email} maxLength={160} placeholder="用于通知,可留空" onChange={(e) => setEdit((f) => ({ ...f, email: e.target.value }))} />
|
||||
</Field>
|
||||
<Field label="角色">
|
||||
<Select value={edit.role} disabled={selected.id === auth.user?.id}
|
||||
|
|
@ -284,7 +277,7 @@ export default function UserAdmin() {
|
|||
<Check checked={edit.is_active} onChange={(v) => setEdit((f) => ({ ...f, is_active: v }))}>允许登录</Check>
|
||||
</Ctlbar>
|
||||
<FieldBlock label="备注">
|
||||
<textarea rows={2} maxLength={200} value={edit.note} onChange={(e) => setEdit((f) => ({ ...f, note: e.target.value }))} />
|
||||
<TextArea rows={2} maxLength={200} value={edit.note} onChange={(e) => setEdit((f) => ({ ...f, note: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<Actions>
|
||||
<Button variant="primary" disabled={!!busy} onClick={saveEdit}>保存</Button>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
* 现在服务端拒绝(409)或记录已终结时,展开成一段常驻说明 + 「把这条指令重新下达」。
|
||||
*/
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import * as api from '../../api/client'
|
||||
import { fmtAgo, fmtTime } from '../../lib/format'
|
||||
import { cn } from '../../lib/cn'
|
||||
|
|
@ -22,9 +21,7 @@ import { notify } from '../../stores/notice'
|
|||
import { useProjectStore } from '../../stores/project'
|
||||
import { loadModels } from '../../stores/models'
|
||||
import { Select } from '../../components/forms'
|
||||
import {
|
||||
BarRight, Between, Button, buttonCls, Check, Ctlbar, ErrorText, Field, MONO, Mono, MUTED, Row, Tag, Value
|
||||
} from '../../components/ui'
|
||||
import { BarRight, Between, Button, Check, Chip, Ctlbar, DisclosureRow, ErrorText, Field, LinkButton, MONO, MUTED, Mono, Row, Tag, TextArea, TILE_HINT, Value } from '../../components/ui'
|
||||
|
||||
/** 计划里的一步(白名单动作),status: pending/running/succeeded/skipped/failed */
|
||||
type AgentStep = {
|
||||
|
|
@ -98,11 +95,11 @@ const STATUS_TONES: Record<string, 'default' | 'ok' | 'bad' | 'warn' | 'info'> =
|
|||
}
|
||||
|
||||
/** 阻塞 / 风险 / 提示三种配色的说明块共用一套骨架 */
|
||||
const CALLOUT = 'mt-[10px] p-[10px_12px] border border-accent-line rounded-[8px] bg-raised'
|
||||
const CALLOUT = 'mt-[10px] p-[10px_12px] border border-accent-line rounded-tile bg-raised'
|
||||
const CALLOUT_TITLE = 'text-tiny tracking-[.7px]'
|
||||
const CALLOUT_TEXT = 'mt-[5px] mb-0 text-ink-3 text-[10.5px] leading-[1.5]'
|
||||
const CALLOUT_EMPTY = 'p-[18px] border border-dashed border-line-strong rounded-[10px] text-faint '
|
||||
+ 'text-[11px] leading-[1.65] text-center'
|
||||
const CALLOUT_TEXT = 'mt-[5px] mb-0 text-ink-3 text-tiny leading-[1.5]'
|
||||
const CALLOUT_EMPTY = 'p-[18px] border border-dashed border-line-strong rounded-tile text-faint '
|
||||
+ 'text-caption leading-[1.65] text-center'
|
||||
|
||||
/** planning 记录的起点时间:刷新页面后计时要继续接着走,不能从 0 重来 */
|
||||
function planningSeconds(row: AgentRun | null) {
|
||||
|
|
@ -218,11 +215,11 @@ function Thinking({ planSeconds, thinking, thinkingLabel, autoExecute, planMarks
|
|||
{ text: autoExecute ? '生成完立即开始执行' : '等待你点击「确认并一键执行」', on: autoExecute }
|
||||
]
|
||||
return (
|
||||
<div className={cn('relative overflow-hidden p-[18px_16px] border border-accent-line rounded-[10px]', THINKING_BG)}>
|
||||
<div className={cn('relative overflow-hidden p-[18px_16px] border border-accent-line rounded-tile', THINKING_BG)}>
|
||||
<Scanline />
|
||||
<b className="block text-ink-2 text-title">
|
||||
LLM 正在盘点项目
|
||||
<Mono className="ml-1.5 text-accent-fill text-[12px]">{planSeconds}s</Mono>
|
||||
<Mono className="ml-1.5 text-accent-fill text-body">{planSeconds}s</Mono>
|
||||
<Mono className="ml-1.5 px-1.5 py-px border border-current rounded-pill text-tiny font-medium opacity-75">
|
||||
{thinkingLabel}
|
||||
</Mono>
|
||||
|
|
@ -527,7 +524,7 @@ export default function AgentConsole() {
|
|||
}
|
||||
|
||||
return (
|
||||
<section className={cn('animate-agent-in relative min-w-0 overflow-hidden mb-5 rounded-[16px] border border-line-strong p-5 shadow-[0_18px_55px_var(--c-shade-2)] max-[620px]:p-[14px] max-[620px]:rounded-[12px]', CONSOLE_BG)}>
|
||||
<section className={cn('animate-agent-in relative min-w-0 overflow-hidden mb-5 rounded-float border border-line-strong p-5 shadow-[0_18px_55px_var(--c-shade-2)] max-[620px]:p-[14px] max-[620px]:rounded-block', CONSOLE_BG)}>
|
||||
{/* 控制台底纹(旧 .agent-console::before):mask 要带 -webkit 前缀,
|
||||
用内联样式一次写清,比在类名里叠四条 arbitrary 好读。 */}
|
||||
<div aria-hidden className="pointer-events-none absolute inset-0 opacity-[.16]"
|
||||
|
|
@ -541,7 +538,7 @@ export default function AgentConsole() {
|
|||
|
||||
<div className="relative z-[1] flex items-start justify-between gap-[18px] border-b border-hairline pb-[17px] min-w-0 max-[620px]:flex-col max-[620px]:items-start">
|
||||
<div className="flex items-center gap-[13px] min-w-0">
|
||||
<div className={cn('grid place-items-center w-[45px] h-[45px] flex-none rounded-[13px] text-on-accent text-[23px] font-extrabold', MARK_BG, MARK_GLOW)}>
|
||||
<div className={cn('grid place-items-center w-[45px] h-[45px] flex-none rounded-float text-on-accent text-num font-extrabold', MARK_BG, MARK_GLOW)}>
|
||||
N
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
|
|
@ -551,7 +548,7 @@ export default function AgentConsole() {
|
|||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 text-muted text-[10.5px] whitespace-nowrap max-[620px]:whitespace-normal">
|
||||
<div className="flex items-center gap-2 text-muted text-tiny whitespace-nowrap max-[620px]:whitespace-normal">
|
||||
{latest
|
||||
? <Tag tone="info" className="font-mono">{latest.provider}/{latest.model}</Tag>
|
||||
: <Tag>读取默认 LLM</Tag>}
|
||||
|
|
@ -564,24 +561,15 @@ export default function AgentConsole() {
|
|||
<div className="relative z-[1] grid min-w-0 grid-cols-[minmax(290px,.82fr)_minmax(0,1.45fr)] gap-5 pt-[18px] max-nav:grid-cols-1">
|
||||
{/* ── 左:下达指令 ─────────────────────────────────────────── */}
|
||||
<div className="min-w-0 pr-5 border-r border-hairline max-nav:pr-0 max-nav:pb-[18px] max-nav:border-r-0 max-nav:border-b max-nav:border-hairline">
|
||||
<label className="block m-0 mb-2 text-ink-2 text-[10px] font-bold tracking-[1.2px]" htmlFor="agent-command">
|
||||
<label className="block m-0 mb-2 text-ink-2 text-tiny font-bold tracking-[1.2px]" htmlFor="agent-command">
|
||||
任务指令
|
||||
</label>
|
||||
<textarea
|
||||
id="agent-command"
|
||||
ref={taRef}
|
||||
rows={5}
|
||||
value={message}
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
<TextArea id="agent-command" ref={taRef} rows={5} value={message} onChange={(e) => setMessage(e.target.value)} onKeyDown={(e) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
||||
e.preventDefault()
|
||||
void planAgent()
|
||||
}
|
||||
}}
|
||||
placeholder="例如:把当前分镜完整生成到成片;质检合格后自动放行,已有产物不要重复生成。"
|
||||
className="w-full min-h-[118px] resize-y px-[14px] py-[13px] border-accent-line bg-sunken leading-[1.65]"
|
||||
/>
|
||||
}} placeholder="例如:把当前分镜完整生成到成片;质检合格后自动放行,已有产物不要重复生成。" className="w-full min-h-[118px] resize-y px-[14px] py-[13px] border-accent-line bg-sunken leading-[1.65]" />
|
||||
<div className="flex flex-wrap gap-1.5 mt-2 min-w-0">
|
||||
{PRESETS.map((text) => (
|
||||
<Button key={text} variant="outline" size="sm" className="max-w-full overflow-hidden text-ellipsis text-muted"
|
||||
|
|
@ -592,22 +580,18 @@ export default function AgentConsole() {
|
|||
</div>
|
||||
|
||||
<Ctlbar className="mt-3 mb-2 gap-x-4">
|
||||
<Check checked={autoExecute} onChange={setAutoExecute} className="text-ink-2 text-[11px]">
|
||||
<Check checked={autoExecute} onChange={setAutoExecute} className="text-ink-2">
|
||||
计划生成后立即执行
|
||||
</Check>
|
||||
<Check checked={autoApprove} onChange={setAutoApprove} className="text-ink-2 text-[11px]">
|
||||
<Check checked={autoApprove} onChange={setAutoApprove} className="text-ink-2">
|
||||
质检合格后允许 AI 代审
|
||||
</Check>
|
||||
<BarRight className="gap-[10px]">
|
||||
<Field label="深度思考" width="narrow">
|
||||
{/* 旧站 .agent-options :deep(.fselect-trigger){padding-inline:8px}:
|
||||
紧凑档下拉的 10px 内边距在 122px 字段里会把「有限思考」顶出格子 */}
|
||||
<Select value={thinking} onChange={(v) => setThinking(v)} options={THINKING_OPTIONS}
|
||||
className="[&>button]:px-2" />
|
||||
<Select size="sm" value={thinking} onChange={(v) => setThinking(v)} options={THINKING_OPTIONS} />
|
||||
</Field>
|
||||
<Field label="单步超时" width="narrow">
|
||||
<Select value={timeoutSec} onChange={(v) => setTimeoutSec(v)} options={TIMEOUT_OPTIONS}
|
||||
className="[&>button]:px-2" />
|
||||
<Select size="sm" value={timeoutSec} onChange={(v) => setTimeoutSec(v)} options={TIMEOUT_OPTIONS} />
|
||||
</Field>
|
||||
</BarRight>
|
||||
</Ctlbar>
|
||||
|
|
@ -639,7 +623,7 @@ export default function AgentConsole() {
|
|||
{/* ── 右:指令列表 + 展开的执行过程 ─────────────────────────── */}
|
||||
<div className="min-w-0 max-h-[min(760px,78vh)] overflow-auto pr-[3px] scrollbar-slim max-nav:max-h-none">
|
||||
{planning && !planningRun && (
|
||||
<p className={cn('relative overflow-hidden m-0 mb-[9px] p-[9px_11px] border border-accent-line rounded-[10px] text-muted text-[10.5px]', THINKING_BG)}>
|
||||
<p className={cn('relative overflow-hidden m-0 mb-[9px] p-[9px_11px] border border-accent-line rounded-tile text-muted text-tiny', THINKING_BG)}>
|
||||
LLM 正在盘点项目 <Mono className="ml-[5px] text-accent-fill">{planSeconds}s</Mono>
|
||||
,计划生成后挂在对应的指令下,点开即可查看。
|
||||
</p>
|
||||
|
|
@ -648,16 +632,15 @@ export default function AgentConsole() {
|
|||
{!!runs.length && (
|
||||
<>
|
||||
<div className="flex flex-wrap items-center gap-[9px] pb-2 border-b border-line text-muted text-tiny min-w-0">
|
||||
<b className="text-ink-2 text-[10.5px] tracking-[.4px]" title="执行过程默认收拢,点任意一行即可展开">
|
||||
<b className="text-ink-2 text-tiny tracking-[.4px]" title="执行过程默认收拢,点任意一行即可展开">
|
||||
指令 · 共 {Math.max(runsTotal, runs.length)} 条
|
||||
</b>
|
||||
{runs.length > HISTORY_PAGE && (
|
||||
<button type="button" onClick={() => setHistoryExpanded((on) => !on)}
|
||||
className="px-[7px] py-[2px] border border-line rounded-pill bg-transparent text-ink-2 text-tiny hover:border-line-strong hover:bg-raised">
|
||||
<Chip size="sm" onClick={() => setHistoryExpanded((on) => !on)}>
|
||||
{historyExpanded ? `只看最近 ${HISTORY_PAGE} 条` : `全部 ${runs.length} 条`}
|
||||
</button>
|
||||
</Chip>
|
||||
)}
|
||||
{runsTotal > runs.length && <Value className="text-faint text-[10px]">这里显示最近 {runs.length} 条</Value>}
|
||||
{runsTotal > runs.length && <Value className="text-faint text-tiny">这里显示最近 {runs.length} 条</Value>}
|
||||
</div>
|
||||
|
||||
{visibleRuns.map((row) => {
|
||||
|
|
@ -665,14 +648,10 @@ export default function AgentConsole() {
|
|||
const live = row.status === 'running' || row.status === 'planning'
|
||||
const step = runningStep(row)
|
||||
return (
|
||||
<div key={row.id}
|
||||
className={cn('group mt-[5px] rounded-[9px] border transition-colors duration-150',
|
||||
open ? 'border-line-strong bg-raised'
|
||||
: live ? 'border-warn-line'
|
||||
: 'border-transparent hover:border-line hover:bg-raised')}>
|
||||
<button type="button" aria-expanded={open} onClick={() => toggleRun(row.id)}
|
||||
title={open ? '收起这条指令的执行过程' : '展开这条指令的执行过程'}
|
||||
className="flex w-full items-center gap-[9px] p-[8px_9px] rounded-[9px] border-0 bg-transparent text-left text-tiny text-muted cursor-pointer [&>*]:self-center max-[620px]:flex-wrap max-[620px]:gap-y-[5px]">
|
||||
<DisclosureRow key={row.id} open={open} live={live}
|
||||
onToggle={() => toggleRun(row.id)}
|
||||
title="这条指令的执行过程"
|
||||
header={<>
|
||||
<Caret open={open} />
|
||||
<Mono className={cn('flex-none', open ? 'text-ink-3' : 'text-faint')}>#{row.id}</Mono>
|
||||
<span className="flex flex-col gap-[3px] min-w-[120px] flex-1 max-[620px]:order-5 max-[620px]:min-w-0 max-[620px]:flex-[1_1_100%]">
|
||||
|
|
@ -682,12 +661,12 @@ export default function AgentConsole() {
|
|||
{row.request_text || '(这条没有留下指令原文)'}
|
||||
</span>
|
||||
{row.status === 'planning' && (
|
||||
<span className={cn('inline-flex items-center gap-[5px] text-warn-bright text-[10px]', 'before:content-[""] before:flex-none before:w-[5px] before:h-[5px] before:rounded-full before:bg-current', live && 'before:animate-agent-pulse')}>
|
||||
<span className={cn('inline-flex items-center gap-[5px] text-warn-bright text-tiny', 'before:content-[""] before:flex-none before:w-[5px] before:h-[5px] before:rounded-full before:bg-current', live && 'before:animate-agent-pulse')}>
|
||||
LLM 正在盘点项目 <Mono className="ml-[3px]">{planSeconds}s</Mono>
|
||||
</span>
|
||||
)}
|
||||
{row.status !== 'planning' && step && (
|
||||
<span className="inline-flex items-center gap-[5px] text-warn-bright text-[10px] before:content-[''] before:flex-none before:w-[5px] before:h-[5px] before:rounded-full before:bg-current before:animate-agent-pulse">
|
||||
<span className="inline-flex items-center gap-[5px] text-warn-bright text-tiny before:content-[''] before:flex-none before:w-[5px] before:h-[5px] before:rounded-full before:bg-current before:animate-agent-pulse">
|
||||
正在执行第 {handledSteps(row) + 1}/{row.steps?.length} 步:{step.label}
|
||||
</span>
|
||||
)}
|
||||
|
|
@ -704,14 +683,9 @@ export default function AgentConsole() {
|
|||
className={cn('flex-none', row.status === 'cancelled' && 'text-danger-bright')}>
|
||||
{STATUS_LABELS[row.status] || row.status}
|
||||
</Tag>
|
||||
<span className={cn('flex-none px-[11px] py-[5px] rounded-pill border bg-raised text-ink-2 text-caption font-medium whitespace-nowrap transition-[border-color,background,color] duration-150',
|
||||
open ? 'border-accent-fill bg-accent-fill text-on-accent font-semibold'
|
||||
: 'border-line-strong group-hover:border-accent-line group-hover:text-accent')}>
|
||||
{open ? '收起执行过程' : '展开执行过程'}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{open && (
|
||||
<span className={TILE_HINT}>{open ? '收起执行过程' : '展开执行过程'}</span>
|
||||
</>}
|
||||
>
|
||||
<div className="mt-0 mr-[9px] mb-[9px] ml-[19px] p-[2px_6px_4px_15px] border-l border-dashed border-line-strong min-w-0 max-[620px]:ml-[7px] max-[620px]:pl-[10px]">
|
||||
{row.status === 'planning'
|
||||
? <Thinking planSeconds={planSeconds} thinking={thinking} thinkingLabel={thinkingLabel}
|
||||
|
|
@ -721,7 +695,7 @@ export default function AgentConsole() {
|
|||
<>
|
||||
<div className="flex items-start justify-between gap-3 min-w-0">
|
||||
<div className="min-w-0">
|
||||
<h3 className="mt-[2px] mb-0 text-[13.5px] font-bold">{row.summary || '执行计划'}</h3>
|
||||
<h3 className="mt-[2px] mb-0 text-ui font-bold">{row.summary || '执行计划'}</h3>
|
||||
{/* 旧站这里写的是 var(--muted,#8b93a7),令牌表里没有 --c-muted,
|
||||
取不到值时永远走硬编码灰:改成真令牌,深浅主题才会跟着翻。 */}
|
||||
{!!planStat(row) && (
|
||||
|
|
@ -764,7 +738,7 @@ export default function AgentConsole() {
|
|||
<div className="flex flex-col gap-[7px] mt-[11px] min-w-0">
|
||||
{row.steps.map((stepItem, index) => (
|
||||
<div key={stepItem.action}
|
||||
className={cn('grid grid-cols-[28px_minmax(0,1fr)] gap-[10px] p-[10px_11px] rounded-[9px] border border-line bg-card min-w-0',
|
||||
className={cn('grid grid-cols-[28px_minmax(0,1fr)] gap-[10px] p-[10px_11px] rounded-tile border border-line bg-card min-w-0',
|
||||
(stepItem.status === 'succeeded' || stepItem.status === 'running') && 'border-success-line bg-raised',
|
||||
stepItem.status === 'failed' && 'border-danger-line bg-raised',
|
||||
stepItem.status === 'skipped' && 'opacity-[.68]')}>
|
||||
|
|
@ -784,7 +758,7 @@ export default function AgentConsole() {
|
|||
{stepStatusLabel(stepItem.status)}
|
||||
</Tag>
|
||||
</Between>
|
||||
<p className="mt-1 mb-0 text-faint text-[10.5px] leading-[1.45]">{stepItem.reason}</p>
|
||||
<p className="mt-1 mb-0 text-faint text-tiny leading-[1.45]">{stepItem.reason}</p>
|
||||
{!!stepDetail(stepItem, row) && (
|
||||
<small className="block mt-[5px] text-ink-3 text-tiny leading-[1.5]">
|
||||
{stepDetail(stepItem, row)}
|
||||
|
|
@ -810,16 +784,13 @@ export default function AgentConsole() {
|
|||
</Button>
|
||||
)}
|
||||
{row.status === 'waiting_review' && (
|
||||
<Link className={cn(buttonCls({ variant: 'secondary' }), 'no-underline')}
|
||||
to={`/projects/${projectId}/review`}>逐镜人工审核 →</Link>
|
||||
<LinkButton to={`/projects/${projectId}/review`} variant="secondary">逐镜人工审核 →</LinkButton>
|
||||
)}
|
||||
{row.status === 'blocked' && (
|
||||
<Link className={cn(buttonCls({ variant: 'secondary' }), 'no-underline')}
|
||||
to={`/projects/${projectId}/storyboard`}>去分镜工作台 →</Link>
|
||||
<LinkButton to={`/projects/${projectId}/storyboard`} variant="secondary">去分镜工作台 →</LinkButton>
|
||||
)}
|
||||
{row.status === 'failed' && (
|
||||
<Link className={cn(buttonCls({ variant: 'secondary' }), 'no-underline')}
|
||||
to={failurePath(row)}>打开失败节点 →</Link>
|
||||
<LinkButton to={failurePath(row)} variant="secondary">打开失败节点 →</LinkButton>
|
||||
)}
|
||||
</Row>
|
||||
{!!row.steps?.length && (
|
||||
|
|
@ -832,8 +803,7 @@ export default function AgentConsole() {
|
|||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</DisclosureRow>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
|
|
@ -842,7 +812,7 @@ export default function AgentConsole() {
|
|||
{!runs.length && (
|
||||
<div className={cn(CALLOUT_EMPTY, 'relative flex min-h-[250px] flex-col items-center justify-center overflow-hidden p-[38px] border-solid max-[620px]:min-h-[190px] max-[620px]:p-[22px]', HERO_BG)}>
|
||||
<Scanline />
|
||||
<b className="text-ink-2 text-[15px]">还没有调度记录</b>
|
||||
<b className="text-ink-2 text-title">还没有调度记录</b>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ import { fromExport } from '../../lib/media'
|
|||
import { useAutoRefresh } from '../../hooks'
|
||||
import { Select } from '../../components/forms'
|
||||
import { MediaThumb } from '../../components/media/MediaThumb'
|
||||
import {
|
||||
Actions, Button, Chip, ChipBar, ErrorText, Field, Grid, LINK_CLS, LineHint, MONO, MUTED, MUTED_MONO,
|
||||
Panel, PanelHead, Row, Spinner, Stat, StatGrid, Status, TabStack, Table, TableBox, Tag, cellCenter, cellRight
|
||||
} from '../../components/ui'
|
||||
import { Actions, Button, Chip, ChipBar, ErrorText, Field, FormGrid, FormRow, Grid, Input, LINK_CLS, LineHint, MONO, MUTED, MUTED_MONO, NumberInput, Panel, PanelHead, Spinner, Stat, StatGrid, Status, TabStack, Table, TableBox, Tag, TagGroup, cellCenter, cellRight } from '../../components/ui'
|
||||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { presetLabel, presets as FALLBACK_PRESETS, useSystemStore } from '../../stores/system'
|
||||
import { notify } from '../../stores/notice'
|
||||
|
|
@ -155,13 +152,14 @@ export default function Delivery() {
|
|||
return (
|
||||
<TabStack>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 min-w-0 mb-3 [--ctl-h:var(--ctl-h-md)]">
|
||||
<Row tight>
|
||||
<Chip>成片 {succeeded.length} / {exportList.length}</Chip>
|
||||
<Chip>累计成本 {fmtMoney(costs?.total_cost, currency)}</Chip>
|
||||
<Chip>生成 {costs?.generations?.count ?? 0} 次 / {(costs?.generations?.seconds ?? 0).toFixed(1)}s</Chip>
|
||||
<Chip>待结算预估 {fmtMoney(costs?.estimated_pending, currency)}</Chip>
|
||||
{/* 这四个数不能点,是回显:按规范 §2.0 走标签族,不借可点 chip 的皮肤 */}
|
||||
<TagGroup className="mb-0">
|
||||
<Tag>成片 {succeeded.length} / {exportList.length}</Tag>
|
||||
<Tag>累计成本 {fmtMoney(costs?.total_cost, currency)}</Tag>
|
||||
<Tag>生成 {costs?.generations?.count ?? 0} 次 / {(costs?.generations?.seconds ?? 0).toFixed(1)}s</Tag>
|
||||
<Tag>待结算预估 {fmtMoney(costs?.estimated_pending, currency)}</Tag>
|
||||
{report && <Tag tone={report.ready ? 'ok' : 'bad'}>{report.ready ? '时间线可导出' : '时间线有阻塞'}</Tag>}
|
||||
</Row>
|
||||
</TagGroup>
|
||||
<span className={MUTED}>{busy && <><Spinner className="mr-1" /> {busy}…</>}</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -186,6 +184,7 @@ export default function Delivery() {
|
|||
))}
|
||||
</ChipBar>
|
||||
<FormGrid>
|
||||
<FormRow cols={2}>
|
||||
<Field label="时间线">
|
||||
<Select value={form.timeline_id} onChange={(v) => setForm((f) => ({ ...f, timeline_id: v }))}
|
||||
options={[{ value: '', label: '当前时间线' },
|
||||
|
|
@ -194,14 +193,15 @@ export default function Delivery() {
|
|||
<Field label="字幕">
|
||||
<Select value={form.subtitle_mode} onChange={(v) => setForm((f) => ({ ...f, subtitle_mode: v }))} options={SUBTITLE_MODES} />
|
||||
</Field>
|
||||
<Field label="优先级" width="narrow">
|
||||
<input type="number" min={0} max={9} value={form.priority}
|
||||
onChange={(e) => setForm((f) => ({ ...f, priority: Number(e.target.value) }))} />
|
||||
</FormRow>
|
||||
<FormRow cols={2}>
|
||||
<Field label="优先级">
|
||||
<NumberInput min={0} max={9} value={form.priority} onChange={ (v) => setForm((f) => ({ ...f, priority: v }))} />
|
||||
</Field>
|
||||
<Field label="成片名称(可选)">
|
||||
<input value={form.name} placeholder="留空自动命名:项目名-时间线-时间戳"
|
||||
onChange={(e) => setForm((f) => ({ ...f, name: e.target.value }))} />
|
||||
<Input value={form.name} placeholder="留空自动命名:项目名-时间线-时间戳" onChange={(e) => setForm((f) => ({ ...f, name: e.target.value }))} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
</FormGrid>
|
||||
<Actions>
|
||||
<Button variant="primary" disabled={!!busy || !report || !report.ready || !form.presets.length}
|
||||
|
|
@ -283,7 +283,7 @@ export default function Delivery() {
|
|||
<td className={`${cellCenter} ${MONO}`}>{rec.id}</td>
|
||||
<td>
|
||||
<div className="flex items-start gap-[9px] flex-nowrap min-w-0">
|
||||
<MediaThumb item={exportItems[at]} size="xs" width="60px" radius={5}
|
||||
<MediaThumb item={exportItems[at]} size="xs" width="60px" radius="chip"
|
||||
queue={exportItems} index={at < 0 ? 0 : at} />
|
||||
<div className="flex-1 min-w-0">
|
||||
<b>{rec.name}</b>
|
||||
|
|
@ -399,7 +399,3 @@ export default function Delivery() {
|
|||
)
|
||||
}
|
||||
|
||||
/** 面板里的短字段栅格(.frow):一行四列,窄列自动降列 */
|
||||
function FormGrid({ children }: { children: React.ReactNode }) {
|
||||
return <div className="grid grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-[10px] mb-[10px] min-w-0 max-mid:grid-cols-2 [&>*]:min-w-0">{children}</div>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,20 +3,16 @@
|
|||
* 清单怎么算、队列怎么排、心跳谁断了:后端是权威,这一页只负责说人话 + 给按钮。
|
||||
*/
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Link, useSearchParams } from 'react-router-dom'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import * as api from '../../api/client'
|
||||
import { fmtAgo, fmtMoney, statusLabel } from '../../lib/format'
|
||||
import { useAutoRefresh } from '../../hooks'
|
||||
import { Select } from '../../components/forms'
|
||||
import {
|
||||
Actions, Between, Button, buttonCls, Check, Ctlbar, Divider, ErrorText, Field,
|
||||
Layout, MONO, MUTED, MUTED_MONO, Panel, PanelHead, ProgressBar, Row, Spinner, Status, TabStack,
|
||||
Table, TableBox, Tag, TagGroup, cellCenter, cellRight, cellWrap
|
||||
} from '../../components/ui'
|
||||
import { Actions, Between, Button, Check, Ctlbar, Divider, ErrorText, Field, Layout, LinkButton, MONO, MUTED, MUTED_MONO, NumberInput, Panel, PanelHead, ProgressBar, Row, Spinner, Status, TabStack, Table, TableBox, Tag, TagGroup, cellCenter, cellRight, cellWrap } from '../../components/ui'
|
||||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { useSystemStore } from '../../stores/system'
|
||||
import { notify } from '../../stores/notice'
|
||||
import { Checkbox } from '../../components/primitives'
|
||||
import { Checkbox } from '../../components/ui'
|
||||
|
||||
const QUEUE_STATUSES = ['planned', 'queued', 'running', 'retrying', 'succeeded', 'failed', 'cancelled', 'skipped']
|
||||
const QUEUE_KINDS = ['generate_shot', 'voiceover', 'qc_shot', 'compose', 'import', 'asset']
|
||||
|
|
@ -274,8 +270,7 @@ export default function Dispatch() {
|
|||
<Check title="忽略「产物已存在 / 已审核合格 / 已在队列」这三类跳过判定,也忽略幂等键。要单独重做某一镜就得勾它"
|
||||
checked={switches.force} onChange={(v) => setSwitches((s) => ({ ...s, force: v }))}>强制重建任务(忽略幂等,可重做已生成的镜头)</Check>
|
||||
<Field label="优先级" width="narrow">
|
||||
<input type="number" min={0} max={9} aria-label="任务优先级"
|
||||
value={priority} onChange={(e) => setPriority(Number(e.target.value))} />
|
||||
<NumberInput min={0} max={9} aria-label="任务优先级" value={priority} onChange={ (v) => setPriority(v)} />
|
||||
</Field>
|
||||
</Ctlbar>
|
||||
<Divider />
|
||||
|
|
@ -283,12 +278,10 @@ export default function Dispatch() {
|
|||
<Check title="勾选「派发后同步排空」会一直等到任务执行结束再返回,适合小批量验证;不勾选时任务留在队列后台执行,页面自动刷新进度。"
|
||||
checked={drain} onChange={setDrain}>派发后同步排空(等任务跑完再返回)</Check>
|
||||
<Field label="单次派发上限" width="narrow">
|
||||
<input type="number" min={1} max={256} aria-label="单次派发上限"
|
||||
value={limit} onChange={(e) => setLimit(Number(e.target.value))} />
|
||||
<NumberInput min={1} max={256} aria-label="单次派发上限" value={limit} onChange={ (v) => setLimit(v)} />
|
||||
</Field>
|
||||
<Field label="排空等待(秒)" width="narrow">
|
||||
<input type="number" min={30} max={7200} aria-label="排空等待秒数"
|
||||
value={timeout_} onChange={(e) => setTimeout_(Number(e.target.value))} />
|
||||
<NumberInput min={30} max={7200} aria-label="排空等待秒数" value={timeout_} onChange={ (v) => setTimeout_(v)} />
|
||||
</Field>
|
||||
</Ctlbar>
|
||||
<Actions>
|
||||
|
|
@ -396,7 +389,7 @@ export default function Dispatch() {
|
|||
<td><Status value={t.status} />
|
||||
<div className={MUTED}>{fmtAgo(t.updated_at)}</div>
|
||||
{t.stale
|
||||
? <div className="mt-1 max-w-[190px] text-[11px] leading-[1.45] text-warn-bright">⚠ 心跳已停止 {fmtAge(t.heartbeat_age_seconds)}:可能已中断,不会永远转圈</div>
|
||||
? <div className="mt-1 max-w-[190px] text-caption leading-[1.45] text-warn-bright">⚠ 心跳已停止 {fmtAge(t.heartbeat_age_seconds)}:可能已中断,不会永远转圈</div>
|
||||
: null}
|
||||
</td>
|
||||
<td className={cellWrap}>
|
||||
|
|
@ -427,8 +420,7 @@ export default function Dispatch() {
|
|||
<div className="min-w-0">
|
||||
<h2 className="mt-0 mb-0 text-h2 font-bold">模型配置已迁移至独立管理中心</h2>
|
||||
</div>
|
||||
<Link to="/models" title="统一维护大模型、图像、视频与声音模型的适配器、默认项、并发、限流、价格、能力与连接探测。调度中心只负责项目任务编排与执行。"
|
||||
className={buttonCls({ variant: 'primary', className: 'no-underline' })}>打开模型管理中心 →</Link>
|
||||
<LinkButton to="/models" variant="primary" title="统一维护大模型、图像、视频与声音模型的适配器、默认项、并发、限流、价格、能力与连接探测。调度中心只负责项目任务编排与执行。">打开模型管理中心 →</LinkButton>
|
||||
</Panel>
|
||||
</TabStack>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,16 +21,11 @@ import { Select } from '../../components/forms'
|
|||
import { AudioPlay } from '../../components/media/AudioPlay'
|
||||
import { MediaThumb } from '../../components/media/MediaThumb'
|
||||
import { RecordAudio, type RecordPickMeta } from '../../components/media/RecordAudio'
|
||||
import {
|
||||
Actions, BarRight, Between, buttonCls, Button, CARD_ROW, Check, Chip, ChipBar, Ctlbar, Divider, Drawer,
|
||||
Empty, ErrorText, Field, FieldBlock, FilePick, FormGrid, FormRow, LineHint, LINK_CLS, MONO, MUTED, MUTED_MONO, Panel,
|
||||
PanelHead,
|
||||
Row, SectionTitle, Spinner, TabStack, Table, TableBox, Tag, TagGroup, TEXTAREA_TALL, cellRight, cellWrap
|
||||
} from '../../components/ui'
|
||||
import { Actions, BarRight, Between, Button, CARD_ROW, CardActions, Check, Chip, ChipBar, Ctlbar, Divider, Drawer, Empty, ErrorText, Field, FieldBlock, FilePick, FormGrid, FormRow, Input, LINK_CLS, LineHint, LinkButton, MONO, MUTED, MUTED_MONO, NumberInput, Panel, PanelHead, Row, SearchInput, SectionTitle, Spinner, TEXTAREA_TALL, TabStack, Table, TableBox, Tag, TagGroup, TextArea, cellRight, cellWrap } from '../../components/ui'
|
||||
import { useSystemStore } from '../../stores/system'
|
||||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { notify } from '../../stores/notice'
|
||||
import { Checkbox } from '../../components/primitives'
|
||||
import { Checkbox } from '../../components/ui'
|
||||
|
||||
type GenType = 'human' | 'scene' | 'voice'
|
||||
type PanelKey = GenType | 'project'
|
||||
|
|
@ -84,7 +79,6 @@ const EFFECT_OPTIONS = [
|
|||
const IMAGE_REF_ACCEPT = 'image/*'
|
||||
|
||||
const assetKindLabel = (kind: string) => opt('asset_kinds', kind)
|
||||
const numOf = (v: string | number) => Number(v) || 0
|
||||
const draftKey = (type: GenType, id: number | null | undefined) => `${type}:${id}`
|
||||
|
||||
function isImageAsset(asset: any) {
|
||||
|
|
@ -752,7 +746,7 @@ export default function Library() {
|
|||
const projectMediaQueue = projectAssets
|
||||
.map((a: any) => fromAsset(a, { group: '项目素材' }))
|
||||
.filter(Boolean) as any[]
|
||||
const linkCls = buttonCls({ variant: 'outline', size: 'sm' })
|
||||
const linkCls = { variant: 'outline' as const, size: 'sm' as const }
|
||||
|
||||
return (
|
||||
<TabStack>
|
||||
|
|
@ -764,8 +758,8 @@ export default function Library() {
|
|||
</h2>
|
||||
</div>
|
||||
<Row tight>
|
||||
<Link to="/assets" className={linkCls}>平台资产库 →</Link>
|
||||
<Link to="/models" className={linkCls}>配置生成模型 →</Link>
|
||||
<LinkButton to="/assets" {...linkCls}>平台资产库 →</LinkButton>
|
||||
<LinkButton to="/models" {...linkCls}>配置生成模型 →</LinkButton>
|
||||
</Row>
|
||||
</Between>
|
||||
|
||||
|
|
@ -790,11 +784,9 @@ export default function Library() {
|
|||
</Between>
|
||||
|
||||
{/* 工具栏:跨字段搜索 + 筛选 + 批量,和平台资产库一套动作 */}
|
||||
<Ctlbar className="px-[10px] py-2 border border-emphasis rounded-[10px] bg-card">
|
||||
<Ctlbar className="px-[10px] py-2 border border-emphasis rounded-tile bg-card">
|
||||
<Field label="搜索" width="grow">
|
||||
<input type="search" aria-label="搜索当前面板" value={keyword}
|
||||
placeholder={panel === 'project' ? '搜索项目素材名称 / 类型 / 文件名…' : '搜索名称 / 代号 / 设定 / 标签 / 素材文件名…'}
|
||||
onChange={(e) => setKeyword(e.target.value)} />
|
||||
<SearchInput aria-label="搜索当前面板" value={keyword} placeholder={panel === 'project' ? '搜索项目素材名称 / 类型 / 文件名…' : '搜索名称 / 代号 / 设定 / 标签 / 素材文件名…'} onChange={(e) => setKeyword(e.target.value)} />
|
||||
</Field>
|
||||
<Chip active={onlyMissing} disabled={panel === 'project'}
|
||||
title={panel === 'project' ? '项目素材面板暂不支持该筛选' : '只看还没有任何素材的资产'}
|
||||
|
|
@ -850,19 +842,22 @@ export default function Library() {
|
|||
<p>造型版本 {c.style_version || 'v1'} · 默认声线 {c.default_voice_name || '未绑定'}
|
||||
{c.tags?.length ? ` · ${c.tags.join(' / ')}` : ''}</p>
|
||||
<UsageLine type="human" id={c.id} usage={use} projectId={projectId} />
|
||||
<Row className="mt-2 gap-1">
|
||||
{/* 素材行 = 卡片动作行:容器声明紧凑档(--ctl-h:31),
|
||||
于是 ↺ 与 ✕ 都是 31×31 同圆角,标签走只读标签的 sm 档,
|
||||
一行里不再出现「38 宽的按钮配 31 高、圆角一个 7 一个 8」。 */}
|
||||
<CardActions className="mt-2 gap-[6px]">
|
||||
{assetsOf(c).map((a: any, ai: number) => (
|
||||
<div key={a.id} className="flex items-center gap-1 min-w-0">
|
||||
<MediaThumb width="34px" radius={6} src={a.url} kind={a.kind} size="xs" inlineAudio={false}
|
||||
<div key={a.id} className="flex items-center gap-[6px] min-w-0">
|
||||
<MediaThumb width="34px" src={a.url} kind={a.kind} size="xs" inlineAudio={false}
|
||||
queue={mediaQueue(c)} index={ai}
|
||||
title={`${assetKindLabel(a.kind)} · ${a.name} · v${a.version}`} />
|
||||
<Tag>{assetKindLabel(a.kind)} v{a.version}</Tag>
|
||||
{a.metadata?.model && <Tag tone="info">{a.metadata.provider}/{a.metadata.model}</Tag>}
|
||||
<Tag size="sm">{assetKindLabel(a.kind)} v{a.version}</Tag>
|
||||
{a.metadata?.model && <Tag size="sm" tone="info">{a.metadata.provider}/{a.metadata.model}</Tag>}
|
||||
<Button variant="outline" size="sm" square title="登记新版本" onClick={() => refreshAsset(a)}>↺</Button>
|
||||
<Button variant="del" square title="删除素材" aria-label="删除素材" onClick={() => dropAsset(a)}>✕</Button>
|
||||
<Button variant="del" size="sm" square title="删除素材" aria-label="删除素材" onClick={() => dropAsset(a)}>✕</Button>
|
||||
</div>
|
||||
))}
|
||||
</Row>
|
||||
</CardActions>
|
||||
<AiBar title="定妆图 / 三视图 / 服装 / 表情 → 自动登记新版本并作为镜头参考图"
|
||||
icon="▧" label="AI 资产生成"
|
||||
last={gens && <Tag tone="ok">最近:{gens.provider}/{gens.model}</Tag>}
|
||||
|
|
@ -928,7 +923,7 @@ export default function Library() {
|
|||
<td>
|
||||
<div className="flex items-center gap-[6px] flex-wrap min-w-0">
|
||||
{assetsOf(s).map((a: any, ai: number) => (
|
||||
<MediaThumb key={a.id} width="34px" radius={6} src={a.url} kind={a.kind}
|
||||
<MediaThumb key={a.id} width="34px" src={a.url} kind={a.kind}
|
||||
size="xs" inlineAudio={false} queue={mediaQueue(s)} index={ai} title={a.name} />
|
||||
))}
|
||||
{!assetsOf(s).length && <span className={MUTED}>未上传</span>}
|
||||
|
|
@ -1045,7 +1040,7 @@ export default function Library() {
|
|||
? <AudioPlay src={a.url} label={a.name} durationMs={a.duration_ms} size="sm" />
|
||||
: isImageAsset(a) || isVideoAsset(a)
|
||||
? (
|
||||
<MediaThumb width="34px" radius={6} src={a.url} kind={a.kind}
|
||||
<MediaThumb width="34px" src={a.url} kind={a.kind}
|
||||
size="xs" inlineAudio={false} queue={projectMediaQueue} index={ai} title={a.name} />
|
||||
)
|
||||
: <a className={cn(MUTED, 'text-success no-underline hover:underline')} href={a.url} target="_blank" rel="noreferrer">打开 ↗</a>}
|
||||
|
|
@ -1079,31 +1074,29 @@ export default function Library() {
|
|||
</>}>
|
||||
<FormGrid>
|
||||
<FormRow>
|
||||
<Field label="名称" required><input value={char.name} placeholder="例如:林澈" onChange={(e) => patchChar({ name: e.target.value })} /></Field>
|
||||
<Field label="代号"><input value={char.code} placeholder="linche" onChange={(e) => patchChar({ code: e.target.value })} /></Field>
|
||||
<Field label="名称" required><Input value={char.name} placeholder="例如:林澈" onChange={(e) => patchChar({ name: e.target.value })} /></Field>
|
||||
<Field label="代号"><Input value={char.code} placeholder="linche" onChange={(e) => patchChar({ code: e.target.value })} /></Field>
|
||||
<Field label="定位">
|
||||
<Select value={char.role} onChange={(v) => patchChar({ role: String(v) })} options={ROLE_OPTIONS} />
|
||||
</Field>
|
||||
<Field label="造型版本"><input value={char.style_version} onChange={(e) => patchChar({ style_version: e.target.value })} /></Field>
|
||||
<Field label="造型版本"><Input value={char.style_version} onChange={(e) => patchChar({ style_version: e.target.value })} /></Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="外观描述(定妆图 + 镜头提示词)">
|
||||
<textarea rows={2} value={char.appearance} placeholder="黑色短发,深蓝战术服,左眼下方有疤——只写看得见的特征,气质/妆容类抽象词不会进入视频提示词"
|
||||
onChange={(e) => patchChar({ appearance: e.target.value })} />
|
||||
<TextArea rows={2} value={char.appearance} placeholder="黑色短发,深蓝战术服,左眼下方有疤——只写看得见的特征,气质/妆容类抽象词不会进入视频提示词" onChange={(e) => patchChar({ appearance: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="性格设定">
|
||||
<textarea rows={2} value={char.personality} onChange={(e) => patchChar({ personality: e.target.value })} />
|
||||
<TextArea rows={2} value={char.personality} onChange={(e) => patchChar({ personality: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="一致性提示词(仅用于生成定妆图/关键帧)">
|
||||
<textarea rows={2} value={char.persona_prompt} placeholder="同一张脸,五官比例保持一致——音画一体模型会把这段话当台词念出来,已不再注入镜头提示词"
|
||||
onChange={(e) => patchChar({ persona_prompt: e.target.value })} />
|
||||
<TextArea rows={2} value={char.persona_prompt} placeholder="同一张脸,五官比例保持一致——音画一体模型会把这段话当台词念出来,已不再注入镜头提示词" onChange={(e) => patchChar({ persona_prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow>
|
||||
<Field label="声音描述"><input value={char.voice_profile} placeholder="低沉、克制的青年男声" onChange={(e) => patchChar({ voice_profile: e.target.value })} /></Field>
|
||||
<Field label="声音描述"><Input value={char.voice_profile} placeholder="低沉、克制的青年男声" onChange={(e) => patchChar({ voice_profile: e.target.value })} /></Field>
|
||||
<Field label="默认声线">
|
||||
<Select value={char.default_voice_id} onChange={(v) => patchChar({ default_voice_id: v === null ? null : Number(v) })}
|
||||
options={[{ value: null, label: '不绑定' }, ...voices.map((v) => ({ value: v.id, label: `${v.name} · ${v.provider}` }))]} />
|
||||
</Field>
|
||||
<Field label="标签(逗号分隔)"><input value={char.tags} placeholder="人类, 一号角色" onChange={(e) => patchChar({ tags: e.target.value })} /></Field>
|
||||
<Field label="标签(逗号分隔)"><Input value={char.tags} placeholder="人类, 一号角色" onChange={(e) => patchChar({ tags: e.target.value })} /></Field>
|
||||
</FormRow>
|
||||
</FormGrid>
|
||||
</Drawer>
|
||||
|
|
@ -1119,22 +1112,22 @@ export default function Library() {
|
|||
</>}>
|
||||
<FormGrid>
|
||||
<FormRow>
|
||||
<Field label="名称" required><input value={scene.name} placeholder="例如:雨夜巷口" onChange={(e) => patchScene({ name: e.target.value })} /></Field>
|
||||
<Field label="代号"><input value={scene.code} placeholder="alley-rain" onChange={(e) => patchScene({ code: e.target.value })} /></Field>
|
||||
<Field label="名称" required><Input value={scene.name} placeholder="例如:雨夜巷口" onChange={(e) => patchScene({ name: e.target.value })} /></Field>
|
||||
<Field label="代号"><Input value={scene.code} placeholder="alley-rain" onChange={(e) => patchScene({ code: e.target.value })} /></Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="场景描述">
|
||||
<textarea rows={2} value={scene.description} onChange={(e) => patchScene({ description: e.target.value })} />
|
||||
<TextArea rows={2} value={scene.description} onChange={(e) => patchScene({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="提示词">
|
||||
<textarea rows={2} value={scene.prompt} onChange={(e) => patchScene({ prompt: e.target.value })} />
|
||||
<TextArea rows={2} value={scene.prompt} onChange={(e) => patchScene({ prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow cols={3}>
|
||||
<Field label="光线"><input value={scene.lighting} onChange={(e) => patchScene({ lighting: e.target.value })} /></Field>
|
||||
<Field label="时间"><input value={scene.time_of_day} onChange={(e) => patchScene({ time_of_day: e.target.value })} /></Field>
|
||||
<Field label="色调"><input value={scene.palette} onChange={(e) => patchScene({ palette: e.target.value })} /></Field>
|
||||
<Field label="光线"><Input value={scene.lighting} onChange={(e) => patchScene({ lighting: e.target.value })} /></Field>
|
||||
<Field label="时间"><Input value={scene.time_of_day} onChange={(e) => patchScene({ time_of_day: e.target.value })} /></Field>
|
||||
<Field label="色调"><Input value={scene.palette} onChange={(e) => patchScene({ palette: e.target.value })} /></Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="标签(逗号分隔)">
|
||||
<input value={scene.tags} onChange={(e) => patchScene({ tags: e.target.value })} />
|
||||
<Input value={scene.tags} onChange={(e) => patchScene({ tags: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</FormGrid>
|
||||
</Drawer>
|
||||
|
|
@ -1150,21 +1143,20 @@ export default function Library() {
|
|||
</>}>
|
||||
<FormGrid>
|
||||
<FormRow>
|
||||
<Field label="名称" required><input value={voice.name} placeholder="例如:低沉男声" onChange={(e) => patchVoice({ name: e.target.value })} /></Field>
|
||||
<Field label="Provider"><input value={voice.provider} placeholder="从下方选择真实模型" onChange={(e) => patchVoice({ provider: e.target.value })} /></Field>
|
||||
<Field label="名称" required><Input value={voice.name} placeholder="例如:低沉男声" onChange={(e) => patchVoice({ name: e.target.value })} /></Field>
|
||||
<Field label="Provider"><Input value={voice.provider} placeholder="从下方选择真实模型" onChange={(e) => patchVoice({ provider: e.target.value })} /></Field>
|
||||
{voice.provider === 'macos-say'
|
||||
? <Field label="macOS 系统声音">
|
||||
<Select value={voice.provider_voice_id} onChange={(v) => patchVoice({ provider_voice_id: String(v) })} options={sayVoiceOptions} />
|
||||
</Field>
|
||||
: <Field label="Provider voice_id"><input value={voice.provider_voice_id} placeholder="填写供应商 voice_id" onChange={(e) => patchVoice({ provider_voice_id: e.target.value })} /></Field>}
|
||||
<Field label="语言"><input value={voice.language} onChange={(e) => patchVoice({ language: e.target.value })} /></Field>
|
||||
: <Field label="Provider voice_id"><Input value={voice.provider_voice_id} placeholder="填写供应商 voice_id" onChange={(e) => patchVoice({ provider_voice_id: e.target.value })} /></Field>}
|
||||
<Field label="语言"><Input value={voice.language} onChange={(e) => patchVoice({ language: e.target.value })} /></Field>
|
||||
<Field label="性别">
|
||||
<Select value={voice.gender} onChange={(v) => patchVoice({ gender: String(v) })} options={GENDER_OPTIONS} />
|
||||
</Field>
|
||||
<Field label="版本"><input value={voice.version} onChange={(e) => patchVoice({ version: e.target.value })} /></Field>
|
||||
<Field label="版本"><Input value={voice.version} onChange={(e) => patchVoice({ version: e.target.value })} /></Field>
|
||||
<Field label="语速">
|
||||
<input type="number" min={0.5} max={2} step={0.05} value={voiceSpeed}
|
||||
onChange={(e) => setVoiceSpeed(numOf(e.target.value))} />
|
||||
<NumberInput min={0.5} max={2} step={0.05} value={voiceSpeed} onChange={ (v) => setVoiceSpeed(v)} />
|
||||
</Field>
|
||||
{voice.provider === 'macos-say' && (
|
||||
<Field label="声音效果">
|
||||
|
|
@ -1173,7 +1165,7 @@ export default function Library() {
|
|||
)}
|
||||
</FormRow>
|
||||
<FieldBlock label="音色描述">
|
||||
<textarea rows={2} value={voice.description} onChange={(e) => patchVoice({ description: e.target.value })} />
|
||||
<TextArea rows={2} value={voice.description} onChange={(e) => patchVoice({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<Check checked={!!voice.is_default} onChange={(v) => patchVoice({ is_default: v })}>设为项目默认声线</Check>
|
||||
<Divider />
|
||||
|
|
@ -1231,9 +1223,7 @@ export default function Library() {
|
|||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="试听文本" required className="mb-0">
|
||||
<textarea rows={2} title="这是要念出来的台词,不是声线设定。" value={genDraft.sample_text}
|
||||
placeholder="输入一句要让模型朗读的台词,例如:在下郭靖,初次见面,请多指教。"
|
||||
onChange={(e) => patchDraft(genType, genOwner, { sample_text: e.target.value })} />
|
||||
<TextArea rows={2} title="这是要念出来的台词,不是声线设定。" value={genDraft.sample_text} placeholder="输入一句要让模型朗读的台词,例如:在下郭靖,初次见面,请多指教。" onChange={(e) => patchDraft(genType, genOwner, { sample_text: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<GenerationReference>
|
||||
<Field label="参考音色" width="wide">
|
||||
|
|
@ -1292,9 +1282,7 @@ export default function Library() {
|
|||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label={`生成描述(留空自动使用${genLabel}设定)`} className="mb-0">
|
||||
<textarea rows={3} value={genDraft.prompt}
|
||||
placeholder={genType === 'human' ? '电影级角色定妆照,冷色侧光,正面清晰' : '广角场景概念图,晨雾,冷色调,强透视'}
|
||||
onChange={(e) => patchDraft(genType, genOwner, { prompt: e.target.value })} />
|
||||
<TextArea rows={3} value={genDraft.prompt} placeholder={genType === 'human' ? '电影级角色定妆照,冷色侧光,正面清晰' : '广角场景概念图,晨雾,冷色调,强透视'} onChange={(e) => patchDraft(genType, genOwner, { prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<GenerationReference>
|
||||
<Field label="参考图" width="wide">
|
||||
|
|
@ -1343,15 +1331,16 @@ export default function Library() {
|
|||
* ========================================================================== */
|
||||
|
||||
/** 勾选态(.cardrow.picked):左沿压一道强调色竖条 + 整块淡底,行首不再靠背景色单独说话 */
|
||||
const PICKED = 'border-l-2 border-l-accent-line -ml-[12px] pl-[10px] rounded-[6px] bg-accent-tint'
|
||||
const PICKED = 'border-l-2 border-l-accent-line -ml-[12px] pl-[10px] rounded-control bg-accent-tint'
|
||||
|
||||
/**
|
||||
* 卡片 / 表格行首的勾选框(.lib-pick):primitives/Checkbox。
|
||||
* 卡片 / 表格行首的勾选框(.lib-pick):kit 的 Checkbox(antd 5 封装)。
|
||||
*
|
||||
* 不放可见文字,选的是谁由 aria-label 说明;Shift 连选读的是**鼠标事件**的 shiftKey,
|
||||
* 而 Radix 的 onCheckedChange 不带事件(键盘 Space 也会走到它),所以 Shift 判定挂在
|
||||
* onClick 上——Radix 先调用我们的 onClick 再决定翻转,中间 stopPropagation 不影响它切换。
|
||||
* 尺寸来自 --check-size,不再是 accent-color 染出来的系统绿块。
|
||||
* 不放可见文字,选的是谁由 aria-label 说明。Shift 连选要读 shiftKey,而它只在
|
||||
* **事件**上:kit 的 onChange 给的是已经翻好的布尔值(键盘 Space 也走它,拿不到事件),
|
||||
* 所以判定挂在 onClick 上——antd 的 onClick 落在 label 外壳,先于 input 的 change 触发,
|
||||
* 中间 stopPropagation 只挡住往卡片冒泡(否则会连带选中镜头),不影响勾选本身翻转。
|
||||
* 尺寸/圆角/深色底来自 theme/antd.ts 的 Checkbox token,不再是 accent-color 染出来的系统绿块。
|
||||
*/
|
||||
function PickBox({ checked, label, className, onToggle }: {
|
||||
checked: boolean; label: string; className?: string; onToggle: (ev?: { shiftKey?: boolean }) => void
|
||||
|
|
@ -1366,7 +1355,7 @@ function PickBox({ checked, label, className, onToggle }: {
|
|||
/** 人物头像位(.avatar):只有名字首字母,真定妆图在下方缩略图里 */
|
||||
function Avatar({ name, children }: { name?: string; children: ReactNode }) {
|
||||
return (
|
||||
<div title={name} className="grid place-items-center w-[33px] h-[33px] shrink-0 rounded-[8px] bg-accent-tint-2 text-success">
|
||||
<div title={name} className="grid place-items-center w-[33px] h-[33px] shrink-0 rounded-tile bg-accent-tint-2 text-success">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
|
@ -1401,7 +1390,7 @@ function SelectAll({ checked, onChange, label }: {
|
|||
checked: boolean; onChange: () => void; label: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('flex items-center justify-between gap-[10px] mb-[6px] px-[10px] py-[6px]', 'border border-dashed border-line-strong rounded-[8px] bg-card')}>
|
||||
<div className={cn('flex items-center justify-between gap-[10px] mb-[6px] px-[10px] py-[6px]', 'border border-dashed border-line-strong rounded-tile bg-card')}>
|
||||
<Check checked={checked} onChange={onChange} title="勾选后可批量上架 / 删除;按住 Shift 连选">{label}</Check>
|
||||
</div>
|
||||
)
|
||||
|
|
@ -1418,7 +1407,7 @@ function AiBar({ icon, label, title, last, disabled, disabledHint, onOpen }: {
|
|||
disabled?: boolean; disabledHint?: string; onOpen: () => void
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] flex items-center flex-wrap gap-2 mt-[10px] px-[10px] py-[8px]', 'border border-line-strong rounded-[8px] bg-card')}>
|
||||
<div className={cn('[--ctl-h:var(--ctl-h-md)] flex items-center flex-wrap gap-2 mt-[10px] px-[10px] py-[8px]', 'border border-line-strong rounded-tile bg-card')}>
|
||||
<b className="text-caption text-ink-2">{icon} {label}</b>
|
||||
{last}
|
||||
<Button variant="primary" size="sm" className="ml-auto" disabled={disabled}
|
||||
|
|
@ -1443,7 +1432,7 @@ function GenerationReference({ children }: { children: ReactNode }) {
|
|||
*/
|
||||
function RefStatus({ ready, borrowed, note }: { ready: boolean; borrowed: boolean; note?: string }) {
|
||||
return (
|
||||
<p className={cn('flex-[1_1_100%] mt-[2px] mb-0 px-[9px] py-[6px] rounded-[8px] border '
|
||||
<p className={cn('flex-[1_1_100%] mt-[2px] mb-0 px-[9px] py-[6px] rounded-tile border '
|
||||
+ 'text-caption leading-[1.55] text-ink',
|
||||
!ready ? 'border-danger-line bg-danger-tint'
|
||||
: borrowed ? 'border-warn-line bg-warn-tint'
|
||||
|
|
@ -1468,8 +1457,8 @@ function SuggestionBox({ text, busy, onApply, onDismiss }: {
|
|||
text: string; busy: boolean; onApply: () => void; onDismiss: () => void
|
||||
}) {
|
||||
return (
|
||||
<div className="p-[9px] bg-raised border border-success-line rounded-[7px]">
|
||||
<p className="m-0 mb-[6px] text-[10.5px] leading-[1.65] text-ink-2">{text}</p>
|
||||
<div className="p-[9px] bg-raised border border-success-line rounded-control">
|
||||
<p className="m-0 mb-[6px] text-tiny leading-[1.65] text-ink-2">{text}</p>
|
||||
<Actions className="mt-0">
|
||||
<Button variant="primary" size="sm" disabled={busy} onClick={onApply}>采用为一致性提示词</Button>
|
||||
<Button variant="outline" size="sm" onClick={onDismiss}>放弃</Button>
|
||||
|
|
|
|||
|
|
@ -24,11 +24,7 @@ import { refresh, useProjectStore } from '../../stores/project'
|
|||
import { notify } from '../../stores/notice'
|
||||
import { useAutoRefresh } from '../../hooks'
|
||||
import { Select } from '../../components/forms'
|
||||
import {
|
||||
Actions, Button, CardRow, Chip, Ctlbar, Divider, ErrorText, Field, FieldBlock, FormGrid, FormRow, Grid,
|
||||
Layout, LINK_CLS, LogBox, LogRow, MONO, MUTED, MUTED_MONO, Panel, PanelHead, Row, Stack, Stat,
|
||||
TabStack, Table, TableBox, Tag, TagGroup, Value, buttonCls, cellCenter, cellWrap
|
||||
} from '../../components/ui'
|
||||
import { Actions, Button, CardRow, Chip, Ctlbar, Divider, ErrorText, Field, FieldBlock, FormGrid, FormRow, Grid, Input, LINK_CLS, Layout, LinkButton, LogBox, LogRow, MONO, MUTED, MUTED_MONO, NumberInput, Panel, PanelHead, Row, Stack, Stat, TabStack, Table, TableBox, Tag, TagGroup, TextArea, Value, cellCenter, cellWrap } from '../../components/ui'
|
||||
import type { GridStep } from '../../components/ui'
|
||||
import AgentConsole from './AgentConsole'
|
||||
|
||||
|
|
@ -360,15 +356,13 @@ export default function Overview() {
|
|||
<>
|
||||
<FormRow>
|
||||
<Field label="名称">
|
||||
<input value={form.name} onChange={(e) => patch({ name: e.target.value })} />
|
||||
<Input value={form.name} onChange={(e) => patch({ name: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="题材">
|
||||
<input value={form.genre} placeholder="科幻 / 悬疑 / 公路"
|
||||
onChange={(e) => patch({ genre: e.target.value })} />
|
||||
<Input value={form.genre} placeholder="科幻 / 悬疑 / 公路" onChange={(e) => patch({ genre: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="目标总时长(秒)" title={durationRule}>
|
||||
<input type="number" min={1} value={form.target_duration}
|
||||
onChange={(e) => patch({ target_duration: Number(e.target.value) })} />
|
||||
<NumberInput min={1} value={form.target_duration} onChange={ (v) => patch({ target_duration: v })} />
|
||||
</Field>
|
||||
<Field label="默认转场">
|
||||
<Select value={form.default_transition} options={options('transition')}
|
||||
|
|
@ -411,17 +405,15 @@ export default function Overview() {
|
|||
{modelWarnings.map((w, i) => <ErrorText key={`mw${i}`}>{w}</ErrorText>)}
|
||||
|
||||
<FieldBlock label="简介">
|
||||
<textarea rows={2} value={form.description} onChange={(e) => patch({ description: e.target.value })} />
|
||||
<TextArea rows={2} value={form.description} onChange={(e) => patch({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="全局风格指南"
|
||||
title="只写画面感风格;音画一体模型会自动过滤画幅、水印、一致性这类元指令。">
|
||||
<textarea rows={2} value={form.style_guide} placeholder="只写画面风格:写实电影质感,35mm 浅景深……(音画一体模型会自动过滤画幅/水印/一致性等元指令)"
|
||||
onChange={(e) => patch({ style_guide: e.target.value })} />
|
||||
<TextArea rows={2} value={form.style_guide} placeholder="只写画面风格:写实电影质感,35mm 浅景深……(音画一体模型会自动过滤画幅/水印/一致性等元指令)" onChange={(e) => patch({ style_guide: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow>
|
||||
<Field label="全局负面提示词(音画一体模型不下发)">
|
||||
<input value={form.global_negative_prompt} placeholder="字幕,水印,角色变形,多手多指"
|
||||
onChange={(e) => patch({ global_negative_prompt: e.target.value })} />
|
||||
<Input value={form.global_negative_prompt} placeholder="字幕,水印,角色变形,多手多指" onChange={(e) => patch({ global_negative_prompt: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Actions>
|
||||
|
|
@ -460,10 +452,9 @@ export default function Overview() {
|
|||
<PanelHead title="下一步建议" right={<span className={MUTED}>{flowNote}</span>} />
|
||||
<Actions>
|
||||
{suggestions.map((a) => (
|
||||
<Link key={a.to} className={cn(buttonCls({ variant: 'secondary' }), 'no-underline')}
|
||||
to={`/projects/${id}/${a.to}`}>
|
||||
<LinkButton key={a.to} to={`/projects/${id}/${a.to}`} variant="secondary">
|
||||
{a.label} <span className={MUTED}>· {a.hint}</span>
|
||||
</Link>
|
||||
</LinkButton>
|
||||
))}
|
||||
</Actions>
|
||||
</Panel>
|
||||
|
|
@ -504,8 +495,7 @@ export default function Overview() {
|
|||
</Chip>
|
||||
))}
|
||||
<Field label="搜索" width="narrow">
|
||||
<input value={eventKeyword} aria-label="搜索项目事件" placeholder="事件内容 / 动作"
|
||||
onChange={(e) => setEventKeyword(e.target.value)} />
|
||||
<Input value={eventKeyword} aria-label="搜索项目事件" placeholder="事件内容 / 动作" onChange={(e) => setEventKeyword(e.target.value)} />
|
||||
</Field>
|
||||
</Ctlbar>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,9 @@ import { useAutoRefresh } from '../../hooks'
|
|||
import { Select } from '../../components/forms'
|
||||
import { AudioPlay } from '../../components/media/AudioPlay'
|
||||
import { MediaThumb } from '../../components/media/MediaThumb'
|
||||
import {
|
||||
Actions, Between, Button, Check, ChipBar, Ctlbar, Divider, Empty, ErrorText, Field, FieldBlock,
|
||||
FormRow, Grid, Layout, LineHint, MONO, MUTED, MUTED_MONO, Panel, PanelHead, ProgressBar, Row,
|
||||
Spinner, Status, TabStack, Table, TableBox, Tag, TagGroup, cellCenter, cellRight, cellWrap
|
||||
} from '../../components/ui'
|
||||
import { Actions, Between, Button, Check, ChipBar, Ctlbar, Divider, Empty, ErrorText, Field, FieldBlock, FormRow, Grid, Input, Layout, LineHint, MONO, MUTED, MUTED_MONO, NumberInput, Panel, PanelHead, ProgressBar, Row, Spinner, Status, TabStack, Table, TableBox, Tag, TagGroup, TextArea, cellCenter, cellRight, cellWrap } from '../../components/ui'
|
||||
import { refresh, useProjectStore } from '../../stores/project'
|
||||
import { notify } from '../../stores/notice'
|
||||
import { openPreview } from '../../stores/preview'
|
||||
|
||||
const KIND_OPTIONS = [
|
||||
{ value: '', label: '全部记录' },
|
||||
|
|
@ -242,10 +237,12 @@ export default function Review() {
|
|||
title={<span title="质检项由 QC_THRESHOLD 与镜头目标时长/分辨率决定;不合格项会阻塞时间线,需驳回重做。">自动质检清单</span>}
|
||||
right={<span className={MUTED}>产物 {generated.length} / 镜头 {shots.length}</span>} />
|
||||
<TableBox maxHeight={520}>
|
||||
<Table pickable minWidth={820}>
|
||||
{/* 六列里三列有固定职责:# 只放序号、状态放两行标签、得分放数字+条。
|
||||
不给它们显式宽度,浏览器会把宽度全给「问题」那列,标签被压到断字。 */}
|
||||
<Table pickable minWidth={960}>
|
||||
<thead>
|
||||
<tr><th className={`${cellCenter} w-[34px]`}>#</th><th>镜头</th><th>状态</th>
|
||||
<th className={cellRight}>得分</th><th>问题</th><th className={cellRight}>操作</th></tr>
|
||||
<tr><th className={`${cellCenter} w-[34px]`}>#</th><th>镜头</th><th className="w-[96px]">状态</th>
|
||||
<th className={`${cellRight} w-[126px]`}>得分</th><th>问题</th><th className={cellRight}>操作</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((r: any) => {
|
||||
|
|
@ -257,7 +254,7 @@ export default function Review() {
|
|||
<td>{r.title}
|
||||
<div className={MUTED_MONO}>shot#{r.shot_id} · {r.probe?.width || '?'}×{r.probe?.height || '?'} · {r.probe?.duration ? `${r.probe.duration.toFixed(2)}s` : '—'}</div>
|
||||
</td>
|
||||
<td><Status value={r.status} />
|
||||
<td className="whitespace-nowrap"><Status value={r.status} />
|
||||
{r.review_state && r.review_state !== 'pending'
|
||||
? <div className="mt-1">
|
||||
<Tag tone={(mark?.tone as any) || (r.review_state === 'pass' ? 'ok' : 'bad')}
|
||||
|
|
@ -267,12 +264,18 @@ export default function Review() {
|
|||
</div>
|
||||
: null}
|
||||
</td>
|
||||
{/* 得分列固定宽:数字 + 条在一行里各占自己的轨道,
|
||||
副结论单独一行且不换行——列一窄「画面 35 / 技术 100」会拐成两行压到进度条上。 */}
|
||||
<td className={cellRight}>
|
||||
<b className={MONO}>{r.score === null ? '—' : r.score}</b>
|
||||
<ProgressBar className="mt-1" value={Math.max(0, Math.min(100, Number(r.score || 0)))} bad={!r.passed} />
|
||||
{r.probe?.visual_score !== null && r.probe?.visual_score !== undefined
|
||||
? <div className={`${MUTED_MONO} text-[10px]`}>画面 {r.probe.visual_score} / 技术 {techOf(r) ?? '—'}</div>
|
||||
: <div className={`${MUTED} text-[10px]`}>画面未检</div>}
|
||||
<div className="ml-auto w-[114px]">
|
||||
<div className="flex items-center gap-2">
|
||||
<b className={`${MONO} flex-none tabular-nums`}>{r.score === null ? '—' : r.score}</b>
|
||||
<ProgressBar className="min-w-0 flex-1" value={Math.max(0, Math.min(100, Number(r.score || 0)))} bad={!r.passed} />
|
||||
</div>
|
||||
{r.probe?.visual_score !== null && r.probe?.visual_score !== undefined
|
||||
? <div className={`${MUTED_MONO} mt-1 whitespace-nowrap text-tiny`}>画面 {r.probe.visual_score} / 技术 {techOf(r) ?? '—'}</div>
|
||||
: <div className={`${MUTED} mt-1 text-tiny`}>画面未检</div>}
|
||||
</div>
|
||||
</td>
|
||||
<td className={cellWrap}>
|
||||
{!r.issues?.length && !r.warnings?.length ? <span className={MUTED}>无</span> : null}
|
||||
|
|
@ -301,7 +304,7 @@ export default function Review() {
|
|||
{!current ? <Empty>在左侧选择一个镜头开始审核。</Empty> : (
|
||||
<>
|
||||
{current.output_url
|
||||
? <MediaThumb item={currentQueue[0]} size="lg" queue={currentQueue} index={0} radius={10}
|
||||
? <MediaThumb item={currentQueue[0]} size="lg" queue={currentQueue} index={0}
|
||||
title={current.preview_url ? '审片预览(平台配音)' : '成片预览'} />
|
||||
: <Empty>该镜头还没有生成产物,请先在调度中心生成。</Empty>}
|
||||
|
||||
|
|
@ -325,11 +328,10 @@ export default function Review() {
|
|||
{evidenceStrips.length > 1
|
||||
? <div className="mt-[10px] flex flex-wrap gap-2">
|
||||
{evidenceStrips.map(({ m, i }: any) => (
|
||||
<button key={m.key} type="button" onClick={() => openPreview(currentQueue, i)}
|
||||
className="group flex w-24 flex-col gap-1 border-0 bg-transparent p-0 text-left hover:[&_span]:text-accent-bright">
|
||||
<MediaThumb item={m} size="sm" clickable={false} radius={6} />
|
||||
<span className="text-[10px] text-faint">{m.kindLabel}</span>
|
||||
</button>
|
||||
<div key={m.key} className="flex w-24 flex-col gap-1 text-left">
|
||||
<MediaThumb item={m} size="sm" queue={currentQueue} index={i} />
|
||||
<span className="text-tiny text-faint">{m.kindLabel}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
: null}
|
||||
|
|
@ -380,38 +382,34 @@ export default function Review() {
|
|||
<div>
|
||||
<h3 className="m-0 mb-2 text-ui">✓ 合格</h3>
|
||||
<FormRow stack>
|
||||
<Field label="审核人"><input value={approve.reviewer} onChange={(e) => setApprove((f) => ({ ...f, reviewer: e.target.value }))} /></Field>
|
||||
<Field label="审核人"><Input value={approve.reviewer} onChange={(e) => setApprove((f) => ({ ...f, reviewer: e.target.value }))} /></Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="备注">
|
||||
<textarea rows={2} placeholder="例如:构图与角色一致性合格"
|
||||
value={approve.notes} onChange={(e) => setApprove((f) => ({ ...f, notes: e.target.value }))} />
|
||||
<TextArea rows={2} placeholder="例如:构图与角色一致性合格" value={approve.notes} onChange={(e) => setApprove((f) => ({ ...f, notes: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<Actions><Button variant="primary" size="sm" disabled={!!busy || !current.output_exists} onClick={approveShot}>标记合格</Button></Actions>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="m-0 mb-2 text-ui">✕ 不合格(可改提示词重做)</h3>
|
||||
<FormRow stack>
|
||||
<Field label="审核人"><input value={reject.reviewer} onChange={(e) => setReject((f) => ({ ...f, reviewer: e.target.value }))} /></Field>
|
||||
<Field label="审核人"><Input value={reject.reviewer} onChange={(e) => setReject((f) => ({ ...f, reviewer: e.target.value }))} /></Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="问题描述">
|
||||
<textarea rows={2} placeholder="例如:角色发型与原画不一致"
|
||||
value={reject.notes} onChange={(e) => setReject((f) => ({ ...f, notes: e.target.value }))} />
|
||||
<TextArea rows={2} placeholder="例如:角色发型与原画不一致" value={reject.notes} onChange={(e) => setReject((f) => ({ ...f, notes: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="覆盖提示词(可选)">
|
||||
<textarea rows={2} placeholder="留空则沿用原提示词"
|
||||
value={reject.prompt} onChange={(e) => setReject((f) => ({ ...f, prompt: e.target.value }))} />
|
||||
<TextArea rows={2} placeholder="留空则沿用原提示词" value={reject.prompt} onChange={(e) => setReject((f) => ({ ...f, prompt: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<FormRow stack>
|
||||
<Field label="覆盖负面提示词(可选)" width="full">
|
||||
<input value={reject.negative_prompt} onChange={(e) => setReject((f) => ({ ...f, negative_prompt: e.target.value }))} />
|
||||
<Input value={reject.negative_prompt} onChange={(e) => setReject((f) => ({ ...f, negative_prompt: e.target.value }))} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Check checked={reject.regenerate} onChange={(v) => setReject((f) => ({ ...f, regenerate: v }))}>立即重新入队生成</Check>
|
||||
{reject.regenerate
|
||||
? <FormRow stack className="mt-[10px]">
|
||||
<Field label={<span title="数字越小越先派发;重做会强制覆盖已有产物,配音任务排在生成之前">任务优先级</span>}>
|
||||
<input type="number" min={0} max={9} value={reject.priority}
|
||||
onChange={(e) => setReject((f) => ({ ...f, priority: Number(e.target.value) }))} />
|
||||
<NumberInput min={0} max={9} value={reject.priority} onChange={ (v) => setReject((f) => ({ ...f, priority: v }))} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
: null}
|
||||
|
|
@ -469,7 +467,7 @@ function VisualQc({ probe, checks, frames, frameItems, note }: {
|
|||
probe: any; checks: any[]; frames: string[]; frameItems: any[]; note: string
|
||||
}) {
|
||||
return (
|
||||
<div className="mb-1 rounded-[10px] bg-tint-info p-[10px]">
|
||||
<div className="mb-1 rounded-tile bg-tint-info p-[10px]">
|
||||
<div className="flex items-center justify-between gap-3 flex-wrap">
|
||||
<b className="text-caption">👁 画面质检(大模型看图)</b>
|
||||
<span className={MUTED}>{probe.visual_frames ? `${probe.visual_frames.length} 张判定帧` : ''}</span>
|
||||
|
|
@ -479,11 +477,10 @@ function VisualQc({ probe, checks, frames, frameItems, note }: {
|
|||
{frames.length
|
||||
? <div className="mt-2 flex flex-wrap gap-2">
|
||||
{frames.map((u, i) => (
|
||||
<button key={u} type="button" onClick={() => openPreview(frameItems, i)}
|
||||
className="group flex w-[108px] flex-col gap-1 border-0 bg-transparent p-0 text-left hover:[&_span]:text-accent-bright">
|
||||
<MediaThumb src={u} kind="image" size="sm" clickable={false} radius={6} />
|
||||
<span className="text-[10px] text-faint">第 {i + 1} 帧</span>
|
||||
</button>
|
||||
<div key={u} className="flex w-[108px] flex-col gap-1 text-left">
|
||||
<MediaThumb src={u} kind="image" size="sm" queue={frameItems} index={i} />
|
||||
<span className="text-tiny text-faint">第 {i + 1} 帧</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
: null}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
* 几十上百个镜头也不会把首屏压垮。
|
||||
*/
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { Link, useSearchParams } from 'react-router-dom'
|
||||
import * as api from '../../api/client'
|
||||
import { canvasFor, fmtAgo, fmtTime, opt, reviewBadge, statusLabel } from '../../lib/format'
|
||||
|
|
@ -28,14 +27,8 @@ import { refresh, useBriefStore, useProjectStore } from '../../stores/project'
|
|||
import { options, useSystemStore } from '../../stores/system'
|
||||
import { notify } from '../../stores/notice'
|
||||
import { openPreview, usePreviewOpen } from '../../stores/preview'
|
||||
import {
|
||||
Actions, BarRight, Between, Button, CARD_ROW, Check, Chip, ChipBar, Ctlbar, Divider, Empty, ErrorText,
|
||||
ExtLink, Field, FieldBlock, FilePick, FormGrid, FormRow, LINK_CLS, Loading, Mono, MUTED, MUTED_MONO, Notice,
|
||||
Panel, PanelHead, Row, SectionTitle, Spinner, Status, TabStack, Table, TableBox, Tabs, Tag, TAG_DENSE, TagGroup, ViewBtn,
|
||||
buttonCls, cellCenter, cellRight, cellWrap, CloseButton, DRAWER_ACTIONS, DRAWER_BODY,
|
||||
DRAWER_HEAD
|
||||
} from '../../components/ui'
|
||||
import { Checkbox, floatingLayerOpen } from '../../components/primitives'
|
||||
import { Actions, BarRight, Between, Button, CARD_ROW, Check, Checkbox, Chip, ChipBar, CloseButton, Ctlbar, DRAWER_ACTIONS, DRAWER_BODY, DRAWER_HEAD, Divider, Empty, ErrorText, ExtLink, Field, FieldBlock, FilePick, FormGrid, FormRow, Input, LINK_CLS, LinkButton, Loading, MUTED, MUTED_MONO, MaybeNumberInput, Mono, Notice, NumberInput, Panel, PanelHead, Row, Scrim, SectionTitle, Spinner, Status, TAG_DENSE, TabStack, Table, TableBox, Tabs, Tag, TagGroup, TextArea, ExportMenu, Stat, StatRow, ViewSwitch, cellCenter, cellRight, cellWrap } from '../../components/ui'
|
||||
import { floatingLayerOpen } from '../../lib/layers'
|
||||
|
||||
type ViewMode = 'grid' | 'table'
|
||||
type InspectorTab = 'shot' | 'assets' | 'prompt' | 'output'
|
||||
|
|
@ -85,7 +78,7 @@ const EMPTY_KEYFRAME = {
|
|||
否则换视图会让人怀疑「是不是选中丢了」。 */
|
||||
|
||||
/** 看板卡(.card):整张卡就是镜头入口,勾选框与缩略图预览各自拦截点击 */
|
||||
const SHOT_CARD = 'flex min-w-0 cursor-pointer flex-col overflow-hidden rounded-[11px] border border-(--c-bg-emphasis) bg-panel '
|
||||
const SHOT_CARD = 'flex min-w-0 cursor-pointer flex-col overflow-hidden rounded-tile border border-(--c-bg-emphasis) bg-panel '
|
||||
+ 'transition-[border-color,transform,box-shadow] hover:-translate-y-px hover:border-line-bright'
|
||||
/** 缩略图(.thumb):16/9 定高,底部 3px 灯带 = 这一镜需不需要人看 */
|
||||
const SHOT_THUMB = 'relative aspect-video overflow-hidden bg-deepest [&_img]:block [&_img]:h-full [&_img]:w-full [&_img]:object-cover [&_video]:block [&_video]:h-full [&_video]:w-full [&_video]:object-cover'
|
||||
|
|
@ -93,7 +86,7 @@ const THUMB_PLATE = 'absolute grid place-items-center text-tiny tracking-[.5px]
|
|||
const THUMB_ORDINAL = 'absolute top-[7px] left-7 grid place-items-center rounded-chip bg-scrim-soft px-[6px] py-1 '
|
||||
+ 'text-caption font-bold leading-none tracking-[.5px] text-accent'
|
||||
const THUMB_DUR = 'absolute top-[7px] right-[34px] rounded-chip bg-scrim-soft px-[5px] py-1 '
|
||||
+ 'text-[10px] leading-none text-ink-2'
|
||||
+ 'text-tiny leading-none text-ink-2'
|
||||
/** 卡片正文(.cardbody):说明两行截断,脚注靠 mt-auto 永远贴底对齐 */
|
||||
const SHOT_BODY = 'flex min-w-0 flex-1 flex-col gap-[7px] p-[11px_12px_12px]'
|
||||
// 元信息行是卡片里最挤的一行,标签整排降到 sm 档;组内间距与 TagGroup 同规格(6px),
|
||||
|
|
@ -102,7 +95,7 @@ const SHOT_META = cn('flex flex-wrap items-center gap-[6px] text-tiny text-faint
|
|||
const SHOT_FOOT = 'mt-auto flex items-center gap-[5px] pt-1'
|
||||
/** 预检阻塞条(.issues):左侧一道红线,比整块涂红省注意力 */
|
||||
const SHOT_ISSUES = 'flex flex-col gap-[2px] rounded-control border-l-2 border-danger-line bg-panel px-[7px] py-[3px] '
|
||||
+ '[&_span]:text-[10px] [&_span]:leading-[1.45]'
|
||||
+ '[&_span]:text-tiny [&_span]:leading-[1.45]'
|
||||
|
||||
/** 一句一行(.linedlg-row):行号 / 说话人 / 台词 / 删除,控件在一条中心线上 */
|
||||
const LINE_ROW = 'grid [--ctl-h:var(--ctl-h-md)] grid-cols-[22px_128px_minmax(0,1fr)_var(--ctl-h)] items-center gap-[6px] '
|
||||
|
|
@ -110,8 +103,8 @@ const LINE_ROW = 'grid [--ctl-h:var(--ctl-h-md)] grid-cols-[22px_128px_minmax(0,
|
|||
/** 音效行:素材 / 入点 / 音量 / 删除 */
|
||||
const SFX_ROW = 'grid [--ctl-h:var(--ctl-h-md)] grid-cols-[minmax(0,1fr)_84px_74px_var(--ctl-h)] items-center gap-[6px] '
|
||||
+ '[&_input]:w-full'
|
||||
const LINE_EMPTY = 'rounded-[8px] border border-dashed border-line-strong bg-card px-[11px] py-[3px] '
|
||||
+ 'text-[11px] leading-[1.6] text-faint'
|
||||
const LINE_EMPTY = 'rounded-tile border border-dashed border-line-strong bg-card px-[11px] py-[3px] '
|
||||
+ 'text-caption leading-[1.6] text-faint'
|
||||
|
||||
/** 表格里那枚缩略图(.tthumb):高度由 92px 宽的画面比例决定,不是一档一档的表单控件 */
|
||||
const TABLE_THUMB = 'grid w-[92px] place-items-center text-dim min-h-[34px]'
|
||||
|
|
@ -1061,23 +1054,22 @@ export default function Storyboard() {
|
|||
<TabStack>
|
||||
{/* ===== 顶栏:sticky 在应用顶栏之下,「+新增镜头 / 切视图 / 收概况」始终够得到 ===== */}
|
||||
<div className="sticky top-(--nex-bar) z-40 flex min-w-0 flex-wrap items-center justify-between gap-4 rounded-block border border-line bg-panel p-[14px_18px]">
|
||||
<div className="flex min-w-0 flex-wrap gap-[22px]">
|
||||
<Metric value={shots.length} label="镜头" />
|
||||
<Metric value={`${plannedDuration.toFixed(1)}s`} label="计划时长" />
|
||||
<Metric value={approvedCount} label="已合格" tone="ok" />
|
||||
<Metric value={issueCount} label="有阻塞" tone={issueCount ? 'bad' : ''} />
|
||||
</div>
|
||||
<StatRow>
|
||||
<Stat variant="inline" value={shots.length} label="镜头" />
|
||||
<Stat variant="inline" value={`${plannedDuration.toFixed(1)}s`} label="计划时长" />
|
||||
<Stat variant="inline" value={approvedCount} label="已合格" tone="ok" />
|
||||
{issueCount ? <Stat variant="inline" value={issueCount} label="有阻塞" tone="bad" /> : null}
|
||||
</StatRow>
|
||||
<Row className="justify-end">
|
||||
<Button variant="primary" onClick={() => { setShowImport(!showImport); setCreating(false) }}>
|
||||
⇪ 导入脚本 / 关键帧
|
||||
</Button>
|
||||
<Button variant="add" onClick={startCreate}>+ 新增镜头</Button>
|
||||
<div className="flex gap-[2px] rounded-tile border border-line-strong p-[2px]" role="group" aria-label="切换分镜视图">
|
||||
<ViewBtn active={view === 'grid'} onClick={() => setView('grid')}
|
||||
title="网格看板:缩略图 + 脚本要点,逐镜对照最舒服"><i>▦</i>看板</ViewBtn>
|
||||
<ViewBtn active={view === 'table'} onClick={() => setView('table')}
|
||||
title="分镜表:一屏看更多镜,便于批量勾选与改参数"><i>☰</i>分镜表</ViewBtn>
|
||||
</div>
|
||||
<ViewSwitch value={view} onChange={setView} label="切换分镜视图"
|
||||
items={[{ value: 'grid', label: <><i className="not-italic text-caption">▦</i>看板</>,
|
||||
hint: '网格看板:缩略图 + 脚本要点,逐镜对照最舒服' },
|
||||
{ value: 'table', label: <><i className="not-italic text-caption">☰</i>分镜表</>,
|
||||
hint: '分镜表:一屏看更多镜,便于批量勾选与改参数' }]} />
|
||||
<Button variant="outline" aria-expanded={briefOpen} onClick={() => setBriefOpen(!briefOpen)}
|
||||
title={briefOpen ? '收起上方项目概况,把屏幕让给分镜' : '展开项目概况'}>
|
||||
{briefOpen ? '⌃ 收起概况' : '⌄ 展开概况'}
|
||||
|
|
@ -1088,8 +1080,7 @@ export default function Storyboard() {
|
|||
{/* ===== 筛选 / 导出 ===== */}
|
||||
<Ctlbar>
|
||||
<Field label="搜索" width="grow">
|
||||
<input value={keyword} onChange={(e) => setKeyword(e.target.value)} aria-label="搜索分镜"
|
||||
placeholder="镜号 / 标题 / 画面 / 台词 / 角色 / 场景…" />
|
||||
<Input value={keyword} onChange={(e) => setKeyword(e.target.value)} aria-label="搜索分镜" placeholder="镜号 / 标题 / 画面 / 台词 / 角色 / 场景…" />
|
||||
</Field>
|
||||
<Field label="状态" width="narrow">
|
||||
<Select size="sm" ariaLabel="按镜头状态筛选" value={statusFilter} onChange={setStatusFilter}
|
||||
|
|
@ -1109,10 +1100,9 @@ export default function Storyboard() {
|
|||
<Chip active={issueOnly} onClick={() => setIssueOnly(!issueOnly)}>仅看阻塞 {issueCount}</Chip>
|
||||
<Chip active={noKeyframeOnly} onClick={() => setNoKeyframeOnly(!noKeyframeOnly)}>仅看缺关键帧</Chip>
|
||||
<BarRight>
|
||||
<span className={MUTED}>导出</span>
|
||||
<ExtLink href={exportHref(projectId, 'md')} download>Markdown ↗</ExtLink>
|
||||
<ExtLink href={exportHref(projectId, 'csv')} download>CSV ↗</ExtLink>
|
||||
<ExtLink href={exportHref(projectId, 'json')} download>JSON ↗</ExtLink>
|
||||
<ExportMenu items={[{ label: 'Markdown(分镜脚本)', href: exportHref(projectId, 'md'), hint: '导入回写、给编剧看都用它' },
|
||||
{ label: 'CSV(表格)', href: exportHref(projectId, 'csv'), hint: '进 Excel 排产期' },
|
||||
{ label: 'JSON(原样字段)', href: exportHref(projectId, 'json'), hint: '交给外部管线' }]} />
|
||||
</BarRight>
|
||||
</Ctlbar>
|
||||
|
||||
|
|
@ -1122,7 +1112,7 @@ export default function Storyboard() {
|
|||
|
||||
{/* ===== 批量操作条 ===== */}
|
||||
{checked.size ? (
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2 rounded-[10px] border border-info-line p-[10px_14px] bg-[linear-gradient(90deg,var(--c-bg-hover),var(--c-bg-panel))]">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-2 rounded-tile border border-info-line p-[10px_14px] bg-[linear-gradient(90deg,var(--c-bg-hover),var(--c-bg-panel))]">
|
||||
<b className="text-accent-bright text-body">已选 {checked.size} 个镜头</b>
|
||||
<Button variant="outline" size="sm" onClick={() => void bulkAction('duplicate', {}, '复制镜头')}>⧉ 复制</Button>
|
||||
<Button variant="outline" size="sm" onClick={() => void bulkAction('move', { index: 1 }, '前移到片头')}>⇈ 移到最前</Button>
|
||||
|
|
@ -1137,9 +1127,8 @@ export default function Storyboard() {
|
|||
options={[{ value: '', label: '不改' }, ...options('mode')]} />
|
||||
</Field>
|
||||
<Field label="时长(秒)" width="narrow">
|
||||
<input type="number" min="0.5" step="0.5" placeholder="不改" value={bulk.fields.duration ?? ''}
|
||||
onChange={(e) => setBulk((prev) => ({ ...prev,
|
||||
fields: { ...prev.fields, duration: e.target.value === '' ? null : Number(e.target.value) } }))} />
|
||||
<MaybeNumberInput min="0.5" step="0.5" placeholder="不改" value={bulk.fields.duration} onChange={(v) => setBulk((prev) => ({ ...prev,
|
||||
fields: { ...prev.fields, duration: v } }))} />
|
||||
</Field>
|
||||
<Field label="景别">
|
||||
<Select size="sm" value={bulk.fields.shot_size} placeholder="不改"
|
||||
|
|
@ -1173,10 +1162,7 @@ export default function Storyboard() {
|
|||
<FormRow cols={2}>
|
||||
{importMode === 'paste' ? (
|
||||
<FieldBlock label="脚本文本">
|
||||
<textarea rows={10} spellCheck={false} value={script.script_text}
|
||||
title={'按「# 镜头 N:标题」分段,支持字段:画面 / 景别 / 视角 / 运镜 / 时长 / 台词 / 说话人 / 出镜角色 / 场景 / 转场 / 提示词 / 关键帧'}
|
||||
onChange={(e) => setScript((prev) => ({ ...prev, script_text: e.target.value }))}
|
||||
placeholder={'# 镜头 1:启航\n画面: 星舰舰桥,林澈凝视全息星图\n景别: 中景\n运镜: 推镜\n时长: 4\n台词: 我们出发吧\n说话人: 林澈\n出镜角色: 林澈\n场景: 星舰舰桥\n关键帧: s01.png'} />
|
||||
<TextArea rows={10} spellCheck={false} value={script.script_text} title={'按「# 镜头 N:标题」分段,支持字段:画面 / 景别 / 视角 / 运镜 / 时长 / 台词 / 说话人 / 出镜角色 / 场景 / 转场 / 提示词 / 关键帧'} onChange={(e) => setScript((prev) => ({ ...prev, script_text: e.target.value }))} placeholder={'# 镜头 1:启航\n画面: 星舰舰桥,林澈凝视全息星图\n景别: 中景\n运镜: 推镜\n时长: 4\n台词: 我们出发吧\n说话人: 林澈\n出镜角色: 林澈\n场景: 星舰舰桥\n关键帧: s01.png'} />
|
||||
</FieldBlock>
|
||||
) : (
|
||||
<FieldBlock label="脚本文件(.txt/.md/.csv/.tsv/.json/.srt/.ass/.docx)">
|
||||
|
|
@ -1200,8 +1186,7 @@ export default function Storyboard() {
|
|||
) : null}
|
||||
<Ctlbar>
|
||||
<Field label="默认时长(秒)" width="narrow">
|
||||
<input type="number" min="0.5" step="0.5" value={script.default_duration}
|
||||
onChange={(e) => setScript((prev) => ({ ...prev, default_duration: Number(e.target.value) }))} />
|
||||
<NumberInput min="0.5" step="0.5" value={script.default_duration} onChange={ (v) => setScript((prev) => ({ ...prev, default_duration: v }))} />
|
||||
</Field>
|
||||
<Check checked={script.keep_existing}
|
||||
onChange={(next) => setScript((prev) => ({ ...prev, keep_existing: next }))}>保留已有镜头</Check>
|
||||
|
|
@ -1260,8 +1245,12 @@ export default function Storyboard() {
|
|||
{/* ===== 看板 / 分镜表 =====
|
||||
旧版这里是一个会随检查器开合切换列数的 grid(.sb-body / .with-inspector)。
|
||||
检查器改成 fixed 常驻之后主区永远是单列,再套一层 grid 只会让子元素
|
||||
忘掉 min-w-0(规范 §7:grid 子项一律 min-w-0),所以直接留一个 main。 */}
|
||||
<main className="min-w-0">
|
||||
忘掉 min-w-0(规范 §7:grid 子项一律 min-w-0),所以这里只剩一个容器。
|
||||
症状:容器以前写成 <main>,而 App 外壳已经有一个 <main>——页面里套出
|
||||
两个 main 地标(读屏软件会念两遍「主内容」,体检里 locator("main")
|
||||
也因 strict mode 命中两个节点而报错)。
|
||||
做法:一页只准有一个 main,它在 app/App.tsx;页面内层是 div。 */}
|
||||
<div className="min-w-0">
|
||||
{loading ? (
|
||||
<Loading>正在载入分镜…</Loading>
|
||||
) : !shots.length ? (
|
||||
|
|
@ -1354,15 +1343,9 @@ export default function Storyboard() {
|
|||
<td>
|
||||
<div className={TABLE_THUMB}>
|
||||
{s.keyframe_url || s.output_url ? (
|
||||
<button className="cursor-zoom-in rounded-[5px] border-0 bg-transparent p-0 leading-none"
|
||||
title={`放大预览:${s.keyframe_url ? '关键帧' : '生成视频'}`}
|
||||
onClick={(ev) => {
|
||||
ev.stopPropagation()
|
||||
previewShot(s, s.keyframe_url ? 'keyframe' : 'output')
|
||||
}}>
|
||||
<MediaThumb item={fromShot(s, s.keyframe_url ? 'keyframe' : 'output')}
|
||||
clickable={false} width="92px" size="xs" radius={5} />
|
||||
</button>
|
||||
<MediaThumb item={fromShot(s, s.keyframe_url ? 'keyframe' : 'output')}
|
||||
width="92px" size="xs" radius="chip" className="cursor-zoom-in"
|
||||
onOpen={() => previewShot(s, s.keyframe_url ? 'keyframe' : 'output')} />
|
||||
) : <span>▧</span>}
|
||||
</div>
|
||||
</td>
|
||||
|
|
@ -1406,16 +1389,14 @@ export default function Storyboard() {
|
|||
</TableBox>
|
||||
</Panel>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{/* ===== 检查器(inspRef)=====
|
||||
它不是 Drawer:Drawer 是模态(Esc 关闭 + 锁滚动 + 遮罩吞点击),
|
||||
而改分镜要「左边挑镜头、右边改文案」来回看,遮罩会把看板挡死。
|
||||
这里保留抽屉的皮肤(同一套 head/body/actions 类名),自己管开合。 */}
|
||||
{selectedId || creating ? (
|
||||
<button type="button"
|
||||
className="fixed inset-0 z-[55] cursor-default border-0 bg-scrim backdrop-blur-[2px]"
|
||||
aria-label="关闭分镜详情" onClick={() => void closeInspector()} />
|
||||
<Scrim label="关闭分镜详情" onClose={() => void closeInspector()} />
|
||||
) : null}
|
||||
{selectedId || creating ? (
|
||||
/* 1400 / 1080 / 720 这三档没有命名断点(huge=1440 / mid=1180 / mid2=1100 / nav=900),
|
||||
|
|
@ -1469,24 +1450,20 @@ export default function Storyboard() {
|
|||
<SectionTitle title="只改这一镜:保存后提示词与预检即时重算,不必重跑整份分镜">📝 本镜文案</SectionTitle>
|
||||
<FormRow cols={2}>
|
||||
<Field label="标题">
|
||||
<input value={draft.title} onChange={(e) => edit({ title: e.target.value })} />
|
||||
<Input value={draft.title} onChange={(e) => edit({ title: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="镜号">
|
||||
<input value={draft.code} placeholder="留空自动编号"
|
||||
onChange={(e) => edit({ code: e.target.value })} />
|
||||
<Input value={draft.code} placeholder="留空自动编号" onChange={(e) => edit({ code: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="画面描述" title="这段描述是生成提示词的主体">
|
||||
<textarea ref={descRef} data-field="description" rows={4} value={draft.description}
|
||||
placeholder="星舰舰桥,林澈凝视全息星图"
|
||||
onChange={(e) => edit({ description: e.target.value })} />
|
||||
<TextArea ref={descRef} data-field="description" rows={4} value={draft.description} placeholder="星舰舰桥,林澈凝视全息星图" onChange={(e) => edit({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="剧情梗概(可选)">
|
||||
<textarea rows={2} value={draft.synopsis} onChange={(e) => edit({ synopsis: e.target.value })} />
|
||||
<TextArea rows={2} value={draft.synopsis} onChange={(e) => edit({ synopsis: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="本镜风格补充">
|
||||
<input value={draft.style_note} placeholder="只写这一镜与全片基调不同的地方"
|
||||
onChange={(e) => edit({ style_note: e.target.value })} />
|
||||
<Input value={draft.style_note} placeholder="只写这一镜与全片基调不同的地方" onChange={(e) => edit({ style_note: e.target.value })} />
|
||||
</FieldBlock>
|
||||
|
||||
<SectionTitle title="一句一行并标清说话人,系统按各自声线逐句配音;留空即这一镜没有人说话"
|
||||
|
|
@ -1512,14 +1489,12 @@ export default function Storyboard() {
|
|||
</div>
|
||||
|
||||
<FieldBlock label="字幕文本" title="留空则自动取这一镜的台词">
|
||||
<textarea data-field="subtitle" rows={2} value={draft.subtitle_text}
|
||||
onChange={(e) => edit({ subtitle_text: e.target.value })} />
|
||||
<TextArea data-field="subtitle" rows={2} value={draft.subtitle_text} onChange={(e) => edit({ subtitle_text: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow cols={2}>
|
||||
<Field label="环境声"
|
||||
title="听得见的东西,用名词短语(键盘敲击声、空调底噪),不要写成句子。模型直出声音时它除了给这一镜铺底噪,还能占住台词前后的空闲时间:MiniMax H3 的音轨和画面一样长,空着的地方它不会留静音,而是从提示词里挑一段画面描述念出来(成片开头那句听不懂的话就是这么来的)。没人说话的镜头同样该填。">
|
||||
<input value={draft.ambience} placeholder="键盘敲击声,办公室底噪"
|
||||
onChange={(e) => edit({ ambience: e.target.value })} />
|
||||
<Input value={draft.ambience} placeholder="键盘敲击声,办公室底噪" onChange={(e) => edit({ ambience: e.target.value })} />
|
||||
</Field>
|
||||
<Check className="self-center" checked={draft.subtitle_enabled}
|
||||
onChange={(next) => edit({ subtitle_enabled: next })}>启用字幕</Check>
|
||||
|
|
@ -1561,24 +1536,20 @@ export default function Storyboard() {
|
|||
options={options('camera_movement')} />
|
||||
</Field>
|
||||
<Field label="镜头备注">
|
||||
<input value={draft.lens_note} placeholder="35mm / 浅景深…"
|
||||
onChange={(e) => edit({ lens_note: e.target.value })} />
|
||||
<Input value={draft.lens_note} placeholder="35mm / 浅景深…" onChange={(e) => edit({ lens_note: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<SectionTitle className="mt-0">时长与转场</SectionTitle>
|
||||
<FormRow cols={3}>
|
||||
<Field label="时长(秒)" title={`模型支持区间 ${durationRange || '未声明'}`}>
|
||||
<input type="number" step="0.5" min={shotCaps.minDuration || 0.5}
|
||||
max={shotCaps.maxDuration || undefined} value={draft.duration}
|
||||
onChange={(e) => edit({ duration: e.target.value })} />
|
||||
<NumberInput step="0.5" min={shotCaps.minDuration || 0.5} max={shotCaps.maxDuration || undefined} value={draft.duration} onChange={ (v) => edit({ duration: v })} />
|
||||
</Field>
|
||||
<Field label="出转场">
|
||||
<Select value={draft.transition_out} onChange={(next) => edit({ transition_out: next })}
|
||||
options={options('transition')} />
|
||||
</Field>
|
||||
<Field label="转场(ms)">
|
||||
<input type="number" min="0" step="50" value={draft.transition_duration_ms}
|
||||
onChange={(e) => edit({ transition_duration_ms: e.target.value })} />
|
||||
<NumberInput min="0" step="50" value={draft.transition_duration_ms} onChange={ (v) => edit({ transition_duration_ms: v })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<SectionTitle className="mt-0">生成</SectionTitle>
|
||||
|
|
@ -1587,8 +1558,7 @@ export default function Storyboard() {
|
|||
<Select value={draft.mode} onChange={(next) => edit({ mode: next })} options={modeOptions} />
|
||||
</Field>
|
||||
<Field label="种子">
|
||||
<input type="number" value={draft.seed} placeholder="留空随机"
|
||||
onChange={(e) => edit({ seed: e.target.value })} />
|
||||
<NumberInput value={draft.seed} placeholder="留空随机" onChange={ (v) => edit({ seed: v })} />
|
||||
</Field>
|
||||
{/* 模型覆盖占两格:这一项的标签最长(跟随项目:provider/model),
|
||||
单格会截成「跟随项目:…」,看不出到底跟的是哪个模型。 */}
|
||||
|
|
@ -1640,7 +1610,7 @@ export default function Storyboard() {
|
|||
</Actions>
|
||||
|
||||
<Divider />
|
||||
<div className="rounded-[10px] border border-success-line bg-[linear-gradient(145deg,var(--c-bg-raised),var(--c-bg-shell)_65%)] p-[13px]">
|
||||
<div className="rounded-tile border border-success-line bg-[linear-gradient(145deg,var(--c-bg-raised),var(--c-bg-shell)_65%)] p-[13px]">
|
||||
<Between>
|
||||
<b className="text-ui text-accent-bright">AI 生成关键帧</b>
|
||||
<Tag tone={keyframeModel?.available ? 'ok' : 'warn'}>
|
||||
|
|
@ -1658,17 +1628,14 @@ export default function Storyboard() {
|
|||
}))} />
|
||||
</Field>
|
||||
<Field label="生成尺寸">
|
||||
<input readOnly value={`${keyframeGen.width} × ${keyframeGen.height}`} />
|
||||
<Input readOnly value={`${keyframeGen.width} × ${keyframeGen.height}`} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="关键帧提示词">
|
||||
<textarea rows={5} spellCheck={false} value={keyframeGen.prompt}
|
||||
placeholder="描述这一镜的最终画面、机位、人物动作、光线与场景"
|
||||
onChange={(e) => setKeyframeGen((prev) => ({ ...prev, prompt: e.target.value }))} />
|
||||
<TextArea rows={5} spellCheck={false} value={keyframeGen.prompt} placeholder="描述这一镜的最终画面、机位、人物动作、光线与场景" onChange={(e) => setKeyframeGen((prev) => ({ ...prev, prompt: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="负面提示词">
|
||||
<textarea rows={2} spellCheck={false} value={keyframeGen.negative_prompt}
|
||||
onChange={(e) => setKeyframeGen((prev) => ({ ...prev, negative_prompt: e.target.value }))} />
|
||||
<TextArea rows={2} spellCheck={false} value={keyframeGen.negative_prompt} onChange={(e) => setKeyframeGen((prev) => ({ ...prev, negative_prompt: e.target.value }))} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="参考素材" title="可多选;默认取场景图、人物定妆图与镜头参考图">
|
||||
<MultiSelect value={keyframeGen.reference_asset_ids} ariaLabel="关键帧参考素材"
|
||||
|
|
@ -1726,19 +1693,14 @@ export default function Storyboard() {
|
|||
<Tag>负面 {promptForm.negative_prompt.length} 字</Tag>
|
||||
</ChipBar>
|
||||
<FieldBlock label="正向提示词" title="勾选「跟随镜头参数自动组装」时这里是只读的:手工文本会在下一次保存时被自动组装覆盖">
|
||||
<textarea rows={7} spellCheck={false} value={promptForm.prompt}
|
||||
readOnly={promptForm.auto_sync}
|
||||
onChange={(e) => patchPrompt({ prompt: e.target.value })} />
|
||||
<TextArea rows={7} spellCheck={false} value={promptForm.prompt} readOnly={promptForm.auto_sync} onChange={(e) => patchPrompt({ prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="负面提示词">
|
||||
<textarea rows={2} spellCheck={false} value={promptForm.negative_prompt}
|
||||
readOnly={promptForm.auto_sync}
|
||||
onChange={(e) => patchPrompt({ negative_prompt: e.target.value })} />
|
||||
<TextArea rows={2} spellCheck={false} value={promptForm.negative_prompt} readOnly={promptForm.auto_sync} onChange={(e) => patchPrompt({ negative_prompt: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FormRow>
|
||||
<Field label="修改原因">
|
||||
<input value={promptForm.reason} placeholder="例如:加强角色一致性 / 按驳回原因修复"
|
||||
onChange={(e) => patchPrompt({ reason: e.target.value })} />
|
||||
<Input value={promptForm.reason} placeholder="例如:加强角色一致性 / 按驳回原因修复" onChange={(e) => patchPrompt({ reason: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Check checked={promptForm.auto_sync} onChange={(next) => patchPrompt({ auto_sync: next })}>
|
||||
|
|
@ -1827,11 +1789,9 @@ export default function Storyboard() {
|
|||
</>
|
||||
) : null}
|
||||
<Actions>
|
||||
<Link to={`/projects/${projectId}/review?shot=${selectedId}`}
|
||||
className={buttonCls({ variant: 'primary' })}>前往审核 →</Link>
|
||||
<Link to={detail?.output_url ? dispatchLink(projectId, detail) : `/projects/${projectId}/dispatch?shot=${selectedId}`}
|
||||
className={buttonCls({ variant: 'outline' })}
|
||||
title="只把这一镜排进队列;已有产物时自动带上强制重建">重新生成 →</Link>
|
||||
<LinkButton to={`/projects/${projectId}/review?shot=${selectedId}`} variant="primary">前往审核 →</LinkButton>
|
||||
<LinkButton to={detail?.output_url ? dispatchLink(projectId, detail) : `/projects/${projectId}/dispatch?shot=${selectedId}`}
|
||||
variant="outline" title="只把这一镜排进队列;已有产物时自动带上强制重建">重新生成 →</LinkButton>
|
||||
</Actions>
|
||||
</>
|
||||
) : (
|
||||
|
|
@ -1871,19 +1831,6 @@ export default function Storyboard() {
|
|||
它们的类名是从旧站逐条抄来的,脱离这一页就没有第二个使用者,
|
||||
提前抽成通用组件只会让 ui 目录变成「什么都往里扔」。 */
|
||||
|
||||
/** 顶栏指标(.sb-metrics > div):数字走 num-sm + tabular-nums,刷新时行宽不跳 */
|
||||
function Metric({ value, label, tone = '' }: {
|
||||
value: ReactNode; label: ReactNode; tone?: '' | 'ok' | 'bad'
|
||||
}) {
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<b className={cn('text-num-sm font-bold leading-[1.1] tabular-nums text-ink',
|
||||
tone === 'ok' && 'text-accent', tone === 'bad' && 'text-danger')}>{value}</b>
|
||||
<small className="mt-[3px] text-tiny tracking-[.6px] text-faint">{label}</small>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 看板卡(.card):整张卡就是镜头入口,
|
||||
* 所以缩略图预览、勾选框、脚注三处都要各自拦下冒泡,否则点一下会变成「选中镜头 + 打开预览」。
|
||||
|
|
@ -1915,6 +1862,9 @@ function ShotCard({
|
|||
const badge = reviewBadge(s)
|
||||
return (
|
||||
<article draggable
|
||||
/* 选中整镜 = 打开检查器。挂个稳定属性给 scripts/ui/audit.py 点:
|
||||
卡片是 <article onClick>,不是 <button>,探针按文案点不中它。 */
|
||||
data-shot-card={s.id}
|
||||
onDragStart={onDragStart}
|
||||
onDragOver={(ev) => { ev.preventDefault(); onDragOverItem() }}
|
||||
onDragEnd={onDragEnd}
|
||||
|
|
@ -1927,7 +1877,12 @@ function ShotCard({
|
|||
selected && 'border-accent-deep shadow-[inset_0_0_0_1px_var(--c-success-line),0_8px_22px_-14px_var(--c-shade-3)]',
|
||||
draggedOver && 'border-sky border-dashed',
|
||||
picked && 'border-accent-line bg-accent-tint shadow-[inset_0_0_0_1px_var(--c-accent-line)]')}>
|
||||
<div className={cn(SHOT_THUMB, PULSE_CLS[cardPulse(s)])}>
|
||||
{/* 卡片有两块热区,探针各认一块(见 scripts/ui/audit.py 的 OVERLAYS):
|
||||
data-shot-preview = 缩略图,点它是「预览这一镜的媒体」(灯箱);
|
||||
data-shot-select = 标题行,点它是「选中这一镜」(检查器)。
|
||||
为什么必须分开:探针点的是元素几何中心,窄屏卡片中心正好落在缩略图上,
|
||||
拿整卡当入口会打开灯箱,检查器那条用例就永远量不到面板。 */}
|
||||
<div data-shot-preview className={cn(SHOT_THUMB, PULSE_CLS[cardPulse(s)])}>
|
||||
{s.output_url ? (
|
||||
<video src={s.output_url} muted preload="none" loop
|
||||
poster={thumbUrl(s.keyframe_url || s.output_url, 384)}
|
||||
|
|
@ -1955,7 +1910,7 @@ function ShotCard({
|
|||
|
||||
<div className={SHOT_BODY}>
|
||||
<div className="flex min-w-0 items-start justify-between gap-2">
|
||||
<b className="text-label leading-[1.35]">{s.title || '未命名镜头'}</b>
|
||||
<b data-shot-select className="text-label leading-[1.35]">{s.title || '未命名镜头'}</b>
|
||||
<Status value={s.status} />
|
||||
</div>
|
||||
<p className="m-0 line-clamp-2 text-caption leading-[1.55] text-muted">{s.description || '未填写画面描述'}</p>
|
||||
|
|
@ -1995,10 +1950,10 @@ function ShotCard({
|
|||
) : null}
|
||||
<div className={SHOT_FOOT} onClick={(ev) => ev.stopPropagation()}>
|
||||
<Button variant="primary" size="sm" onClick={onText} title="直接改这一镜的画面描述与台词">✎ 改文案</Button>
|
||||
<Link to={dispatchLink(projectId, s)} className={buttonCls({ variant: 'outline', size: 'sm' })}
|
||||
<LinkButton to={dispatchLink(projectId, s)} variant="outline" size="sm"
|
||||
title={s.output_url ? '已有产物:到调度中心只重做这一镜' : '到调度中心生成这一镜'}>
|
||||
{s.output_url ? '↻ 重生成' : '▷ 生成'}
|
||||
</Link>
|
||||
</LinkButton>
|
||||
<BarRight>
|
||||
<Link to={`/projects/${projectId}/review?shot=${s.id}`} className={LINK_CLS}>审核</Link>
|
||||
<Button variant="outline" size="sm" disabled={busy} onClick={onDuplicate} title="复制这一镜">⧉</Button>
|
||||
|
|
@ -2031,9 +1986,7 @@ function DialogueRow({ index, row, total, characters, issue, onSpeaker, onText,
|
|||
<Select value={row.character_id} ariaLabel="说话人" onChange={onSpeaker}
|
||||
options={[{ value: null, label: '未指定' },
|
||||
...characters.map((c) => ({ value: c.id, label: c.name }))]} />
|
||||
<textarea rows={2} value={row.text}
|
||||
placeholder={total > 1 ? `第 ${index + 1} 句台词` : '这一镜的台词,留空表示无台词'}
|
||||
onChange={(e) => onText(e.target.value)} />
|
||||
<TextArea rows={2} value={row.text} placeholder={total > 1 ? `第 ${index + 1} 句台词` : '这一镜的台词,留空表示无台词'} onChange={(e) => onText(e.target.value)} />
|
||||
<Button variant="del" square type="button" title="删除这一句" aria-label="删除这一句" onClick={onRemove}>✕</Button>
|
||||
</div>
|
||||
{issue ? <small className="ml-[156px] text-tiny leading-[1.5] text-warn-bright">⚠ {issue}</small> : null}
|
||||
|
|
@ -2055,12 +2008,8 @@ function SfxRowView({ row, assets, onPick, onPatch, onRemove }: {
|
|||
onChange={(next) => onPick(next === undefined ? null : next)}
|
||||
options={[{ value: null, label: '选择音效' },
|
||||
...assets.map((a) => ({ value: a.id, label: a.name }))]} />
|
||||
<input type="number" step="100" min="0" value={row.offset_ms ?? 0}
|
||||
title="入点(毫秒)" aria-label="入点毫秒"
|
||||
onChange={(e) => onPatch({ offset_ms: numOr(e.target.value, 0) })} />
|
||||
<input type="number" step="1" value={row.gain_db ?? 0}
|
||||
title="音量(dB)" aria-label="音量分贝"
|
||||
onChange={(e) => onPatch({ gain_db: numOr(e.target.value, 0) })} />
|
||||
<NumberInput step="100" min="0" value={row.offset_ms ?? 0} title="入点(毫秒)" aria-label="入点毫秒" onChange={ (v) => onPatch({ offset_ms: numOr(v, 0) })} />
|
||||
<NumberInput step="1" value={row.gain_db ?? 0} title="音量(dB)" aria-label="音量分贝" onChange={ (v) => onPatch({ gain_db: numOr(v, 0) })} />
|
||||
<Button variant="del" square type="button" title="删除这个音效" aria-label="删除这个音效" onClick={onRemove}>✕</Button>
|
||||
</div>
|
||||
)
|
||||
|
|
@ -2071,8 +2020,8 @@ function AssetRow({ asset: a, queue, index, onPreview }: {
|
|||
asset: any; queue: MediaItem[]; index: number; onPreview: () => void
|
||||
}) {
|
||||
return (
|
||||
<div className="flex min-w-0 items-center gap-[9px] rounded-[8px] border border-active bg-card p-[7px] text-caption">
|
||||
<MediaThumb item={fromAsset(a)} queue={queue} index={index} width="62px" size="xs" radius={6}
|
||||
<div className="flex min-w-0 items-center gap-[9px] rounded-tile border border-active bg-card p-[7px] text-caption">
|
||||
<MediaThumb item={fromAsset(a)} queue={queue} index={index} width="62px" size="xs"
|
||||
inlineAudio={false} className="flex-none" title={`放大预览:${a.name}`} />
|
||||
<div className="min-w-0 flex-1">
|
||||
<b>{a.kind_label || a.kind}</b> <span className={MUTED}>{a.name}</span>
|
||||
|
|
|
|||
|
|
@ -16,12 +16,7 @@ import { refresh, useProjectStore } from '../../stores/project'
|
|||
import { useSystemStore } from '../../stores/system'
|
||||
import { notify } from '../../stores/notice'
|
||||
import { openPreview } from '../../stores/preview'
|
||||
import {
|
||||
Actions, Between, Button, Check, Chip, ChipBar, Ctlbar, Divider, Empty, ErrorText, ExtLink, Field,
|
||||
FieldBlock, FilePick, FormGrid, FormRow, Grid, IssueRow, Layout, LineHint, MONO, MUTED, MUTED_MONO, Mono, Panel,
|
||||
PanelHead, Row, SectionTitle, Spinner, Status, TabStack, Table, TableBox, Tag, TagGroup, Value,
|
||||
cellCenter, cellRight
|
||||
} from '../../components/ui'
|
||||
import { Actions, Between, Button, Check, Chip, ChipBar, Ctlbar, Divider, Empty, ErrorText, ExtLink, Field, FieldBlock, FilePick, FormGrid, FormRow, Grid, Input, IssueRow, Layout, LineHint, MONO, MUTED, MUTED_MONO, MaybeNumberInput, Mono, NumberInput, Panel, PanelHead, Row, SectionTitle, Spinner, Status, TabStack, Table, TableBox, Tag, TagGroup, TextArea, Value, cellCenter, cellRight } from '../../components/ui'
|
||||
|
||||
const SUBTITLE_MODES = [
|
||||
{ value: 'embed', label: '内嵌软字幕轨(播放器可开关,画质无损 · 推荐)' },
|
||||
|
|
@ -32,6 +27,16 @@ const SUBTITLE_MODES = [
|
|||
]
|
||||
const subtitleModeLabel = (m: string) => SUBTITLE_MODES.find((x) => x.value === m)?.label || m || '—'
|
||||
|
||||
/**
|
||||
* 交付预检报告里的字幕模式短名。下拉里那串完整说明是给人做选择用的,
|
||||
* 而标签(Tag)是 nowrap 的一行胶囊:整句塞进去实测 280px,比 264px 的
|
||||
* TagGroup 还宽 16px,900px 断点下撑破面板。完整说法留在 title 里。
|
||||
*/
|
||||
const SUBTITLE_MODE_SHORT: Record<string, string> = {
|
||||
embed: '内嵌软字幕轨', burn: '烧录硬字幕', both: '烧录 + 内嵌', sidecar: '仅外挂 SRT', off: '不输出'
|
||||
}
|
||||
const subtitleModeShort = (m: string) => SUBTITLE_MODE_SHORT[m] || m || '—'
|
||||
|
||||
/** 编排设置的初值:key 顺序同时是脏值比对的基准(resolveSettings 必须按同一顺序产出) */
|
||||
const SETTING_INIT = {
|
||||
subtitle_mode: 'embed', burn_subtitle: true, voice_gain_db: 0, bgm_gain_db: -17, duck_bgm: true,
|
||||
|
|
@ -91,8 +96,6 @@ const AUDIO_KINDS = [
|
|||
/** 字幕 / 音轨行(.subline):定列栅格,窄屏折成一列 */
|
||||
const SUBLINE = 'grid items-center gap-2 border-b border-line-soft py-[7px] text-caption [&>*]:min-w-0'
|
||||
|
||||
/** 数字输入框解析:清空时按 0 处理,避免 Number('') 之外的 NaN 渗进请求体 */
|
||||
const numOf = (v: string) => (v === '' ? 0 : Number(v))
|
||||
|
||||
export default function Timeline() {
|
||||
const projectId = useProjectStore((s) => s.id)
|
||||
|
|
@ -426,8 +429,7 @@ export default function Timeline() {
|
|||
<PanelHead title="构建时间线" />
|
||||
<Ctlbar>
|
||||
<Field label="时间线名称" width="grow">
|
||||
<input value={build.name} placeholder="留空使用「主时间线」"
|
||||
onChange={(e) => patchBuild({ name: e.target.value })} />
|
||||
<Input value={build.name} placeholder="留空使用「主时间线」" onChange={(e) => patchBuild({ name: e.target.value })} />
|
||||
</Field>
|
||||
<Check checked={build.only_approved} onChange={(v) => patchBuild({ only_approved: v })}
|
||||
title="不勾选任何镜头时按「仅合格」或全部有产物镜头自动编排。">
|
||||
|
|
@ -469,7 +471,9 @@ export default function Timeline() {
|
|||
<Tag>配音 {report.voice_clips}</Tag>
|
||||
<Tag>BGM {report.bgm_clips}</Tag>
|
||||
<Tag>总时长 {fmtMs(report.total_duration_ms)}</Tag>
|
||||
<Tag>字幕 {subtitleModeLabel(report.subtitle_mode || (report.burn_subtitle ? 'burn' : 'sidecar'))}</Tag>
|
||||
<Tag title={subtitleModeLabel(report.subtitle_mode || (report.burn_subtitle ? 'burn' : 'sidecar'))}>
|
||||
字幕 {subtitleModeShort(report.subtitle_mode || (report.burn_subtitle ? 'burn' : 'sidecar'))}
|
||||
</Tag>
|
||||
</TagGroup>
|
||||
<Divider />
|
||||
{!report.issues?.length
|
||||
|
|
@ -543,20 +547,17 @@ export default function Timeline() {
|
|||
options={[{ value: '', label: '(全局字幕)' }, ...shotOptions]} />
|
||||
</Field>
|
||||
<Field label="说话人">
|
||||
<input value={cue.speaker} placeholder="角色名,可留空" onChange={(e) => patchCue({ speaker: e.target.value })} />
|
||||
<Input value={cue.speaker} placeholder="角色名,可留空" onChange={(e) => patchCue({ speaker: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="起始 ms">
|
||||
<input type="number" min={0} step={50} value={cue.start_ms ?? ''}
|
||||
onChange={(e) => patchCue({ start_ms: e.target.value === '' ? null : Number(e.target.value) })} />
|
||||
<MaybeNumberInput min={0} step={50} value={cue.start_ms} onChange={(v) => patchCue({ start_ms: v })} />
|
||||
</Field>
|
||||
<Field label="结束 ms">
|
||||
<input type="number" min={0} step={50} value={cue.end_ms ?? ''}
|
||||
onChange={(e) => patchCue({ end_ms: e.target.value === '' ? null : Number(e.target.value) })} />
|
||||
<MaybeNumberInput min={0} step={50} value={cue.end_ms} onChange={(v) => patchCue({ end_ms: v })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<FieldBlock label="字幕文本">
|
||||
<textarea rows={2} value={cue.text} placeholder={cue.cue_id ? '留空表示删除这条字幕' : '留空表示删除该镜头字幕'}
|
||||
onChange={(e) => patchCue({ text: e.target.value })} />
|
||||
<TextArea rows={2} value={cue.text} placeholder={cue.cue_id ? '留空表示删除这条字幕' : '留空表示删除该镜头字幕'} onChange={(e) => patchCue({ text: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<Actions>
|
||||
<Button variant="primary" size="sm" disabled={!!busy || !timeline} onClick={saveSubtitle}>保存字幕</Button>
|
||||
|
|
@ -607,40 +608,31 @@ export default function Timeline() {
|
|||
保留镜头自带音轨(模型原生音画同步)
|
||||
</Check>
|
||||
<Field label="原生音轨增益 dB">
|
||||
<input type="number" step={0.5} disabled={!setting.keep_shot_audio} value={setting.shot_audio_gain_db}
|
||||
onChange={(e) => patchSetting({ shot_audio_gain_db: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.5} disabled={!setting.keep_shot_audio} value={setting.shot_audio_gain_db} onChange={ (v) => patchSetting({ shot_audio_gain_db: v })} />
|
||||
</Field>
|
||||
<Field label="配音增益 dB">
|
||||
<input type="number" step={0.5} value={setting.voice_gain_db}
|
||||
onChange={(e) => patchSetting({ voice_gain_db: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.5} value={setting.voice_gain_db} onChange={ (v) => patchSetting({ voice_gain_db: v })} />
|
||||
</Field>
|
||||
<Field label="BGM 增益 dB">
|
||||
<input type="number" step={0.5} value={setting.bgm_gain_db}
|
||||
onChange={(e) => patchSetting({ bgm_gain_db: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.5} value={setting.bgm_gain_db} onChange={ (v) => patchSetting({ bgm_gain_db: v })} />
|
||||
</Field>
|
||||
<Field label="目标响度 LUFS">
|
||||
<input type="number" step={0.5} value={setting.target_lufs}
|
||||
onChange={(e) => patchSetting({ target_lufs: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.5} value={setting.target_lufs} onChange={ (v) => patchSetting({ target_lufs: v })} />
|
||||
</Field>
|
||||
<Field label="片头留白 ms">
|
||||
<input type="number" step={10} value={setting.lead_padding_ms}
|
||||
onChange={(e) => patchSetting({ lead_padding_ms: numOf(e.target.value) })} />
|
||||
<NumberInput step={10} value={setting.lead_padding_ms} onChange={ (v) => patchSetting({ lead_padding_ms: v })} />
|
||||
</Field>
|
||||
<Field label="片尾留白 ms">
|
||||
<input type="number" step={10} value={setting.tail_padding_ms}
|
||||
onChange={(e) => patchSetting({ tail_padding_ms: numOf(e.target.value) })} />
|
||||
<NumberInput step={10} value={setting.tail_padding_ms} onChange={ (v) => patchSetting({ tail_padding_ms: v })} />
|
||||
</Field>
|
||||
<Field label="字幕字号(0=自动)">
|
||||
<input type="number" min={0} value={setting.sub_size}
|
||||
onChange={(e) => patchSetting({ sub_size: numOf(e.target.value) })} />
|
||||
<NumberInput min={0} value={setting.sub_size} onChange={ (v) => patchSetting({ sub_size: v })} />
|
||||
</Field>
|
||||
<Field label="字幕下边距(0=自动)">
|
||||
<input type="number" min={0} value={setting.sub_margin}
|
||||
onChange={(e) => patchSetting({ sub_margin: numOf(e.target.value) })} />
|
||||
<NumberInput min={0} value={setting.sub_margin} onChange={ (v) => patchSetting({ sub_margin: v })} />
|
||||
</Field>
|
||||
<Field label="字幕描边(0=自动)">
|
||||
<input type="number" min={0} value={setting.sub_outline}
|
||||
onChange={(e) => patchSetting({ sub_outline: numOf(e.target.value) })} />
|
||||
<NumberInput min={0} value={setting.sub_outline} onChange={ (v) => patchSetting({ sub_outline: v })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Actions>
|
||||
|
|
@ -681,23 +673,20 @@ export default function Timeline() {
|
|||
<Select ariaLabel="音轨类型" value={audio.kind} onChange={(v: any) => patchAudio({ kind: v })} options={AUDIO_KINDS} />
|
||||
</Field>
|
||||
<Field label="标签">
|
||||
<input value={audio.label} placeholder="例如:主旋律 BGM" onChange={(e) => patchAudio({ label: e.target.value })} />
|
||||
<Input value={audio.label} placeholder="例如:主旋律 BGM" onChange={(e) => patchAudio({ label: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="对齐镜头">
|
||||
<Select ariaLabel="音轨对齐镜头" value={audio.shot_id} onChange={(v: any) => patchAudio({ shot_id: v ?? '' })}
|
||||
options={[{ value: '', label: '(不绑定)' }, ...shotOptions]} />
|
||||
</Field>
|
||||
<Field label="起始 ms">
|
||||
<input type="number" min={0} step={50} value={audio.start_ms}
|
||||
onChange={(e) => patchAudio({ start_ms: numOf(e.target.value) })} />
|
||||
<NumberInput min={0} step={50} value={audio.start_ms} onChange={ (v) => patchAudio({ start_ms: v })} />
|
||||
</Field>
|
||||
<Field label="时长 ms(0=自动)">
|
||||
<input type="number" min={0} step={50} value={audio.duration_ms}
|
||||
onChange={(e) => patchAudio({ duration_ms: numOf(e.target.value) })} />
|
||||
<NumberInput min={0} step={50} value={audio.duration_ms} onChange={ (v) => patchAudio({ duration_ms: v })} />
|
||||
</Field>
|
||||
<Field label="增益 dB">
|
||||
<input type="number" step={0.5} value={audio.gain_db}
|
||||
onChange={(e) => patchAudio({ gain_db: numOf(e.target.value) })} />
|
||||
<NumberInput step={0.5} value={audio.gain_db} onChange={ (v) => patchAudio({ gain_db: v })} />
|
||||
</Field>
|
||||
<Check checked={audio.loop} onChange={(v) => patchAudio({ loop: v })} className="self-center">循环铺满</Check>
|
||||
<Check checked={audio.ducking} onChange={(v) => patchAudio({ ducking: v })} className="self-center">压低 BGM</Check>
|
||||
|
|
@ -706,7 +695,7 @@ export default function Timeline() {
|
|||
<FilePick label="🎵 选择音频文件" accept="audio/*"
|
||||
onFiles={(files) => patchAudio({ file: files[0] ?? null })} />
|
||||
{audio.file
|
||||
? <Chip as="span" active>{audio.file.name}</Chip>
|
||||
? <Tag tone="ok" title="已选本地文件,点「开始替换」生效">{audio.file.name}</Tag>
|
||||
: <span className={MUTED}>或直接引用已有素材:</span>}
|
||||
{audioAssets.map((a: any) => (
|
||||
<Chip key={a.id} active={audio.source_path === a.path} onClick={() => useAsset(a.path)}>{a.name}</Chip>
|
||||
|
|
@ -714,8 +703,7 @@ export default function Timeline() {
|
|||
</Row>
|
||||
<FormRow className="mt-3">
|
||||
<Field label="素材路径(可留空,或直接点上方已有素材)">
|
||||
<input value={audio.source_path} placeholder="media 相对路径,如 5/bgm/timeline-bgm_xxx.mp3"
|
||||
onChange={(e) => patchAudio({ source_path: e.target.value })} />
|
||||
<Input value={audio.source_path} placeholder="media 相对路径,如 5/bgm/timeline-bgm_xxx.mp3" onChange={(e) => patchAudio({ source_path: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
</FormGrid>
|
||||
|
|
@ -793,15 +781,15 @@ function SegmentRow({ seg, i, count, item, queue, shot, transitions, busy, open,
|
|||
const native = seg.voice_source === 'native'
|
||||
|
||||
return (
|
||||
<div className={cn('mb-[9px] grid items-start gap-[11px] rounded-[10px] border bg-card p-[11px]',
|
||||
<div className={cn('mb-[9px] grid items-start gap-[11px] rounded-tile border bg-card p-[11px]',
|
||||
open ? 'border-accent-line bg-raise' : 'border-emphasis',
|
||||
'grid-cols-[30px_112px_minmax(0,1fr)] max-narrow:grid-cols-[24px_minmax(0,1fr)]')}>
|
||||
<div className="pt-1 text-accent-deep text-[12px] font-bold">{seg.order_index}</div>
|
||||
<MediaThumb item={item} size="sm" width="104px" radius={6} queue={queue} index={i}
|
||||
<div className="pt-1 text-accent-deep text-body font-bold">{seg.order_index}</div>
|
||||
<MediaThumb item={item} size="sm" width="104px" queue={queue} index={i}
|
||||
title={`片段 ${seg.order_index} · ${seg.label}`} className="max-narrow:hidden" />
|
||||
<div className="min-w-0">
|
||||
<div className="flex flex-wrap items-center gap-[5px_9px]">
|
||||
<h4 className="m-0 text-[12.5px] font-semibold">{seg.label}</h4>
|
||||
<h4 className="m-0 text-body font-semibold">{seg.label}</h4>
|
||||
<Mono className={MUTED}>{fmtMs(seg.start_ms)} → {fmtMs(seg.start_ms + seg.duration_ms)}</Mono>
|
||||
<Tag>源 {fmtMs(seg.source_in_ms)}–{fmtMs(seg.source_out_ms)}</Tag>
|
||||
{hasVoice && (
|
||||
|
|
@ -823,15 +811,13 @@ function SegmentRow({ seg, i, count, item, queue, shot, transitions, busy, open,
|
|||
<>
|
||||
<FormRow cols={6} stack tight className="mt-[9px] [&_input]:px-[7px] [&_input]:text-tiny">
|
||||
<Field label="片段名称">
|
||||
<input key={`label-${seg.label}`} defaultValue={seg.label} onBlur={txt('label', '片段名称')} />
|
||||
<Input key={`label-${seg.label}`} defaultValue={seg.label} onBlur={txt('label', '片段名称')} />
|
||||
</Field>
|
||||
<Field label="时长 ms">
|
||||
<input key={`duration-${seg.duration_ms}`} type="number" min={80} step={20}
|
||||
defaultValue={seg.duration_ms} onBlur={num('duration_ms', '时长')} />
|
||||
<NumberInput key={`duration-${seg.duration_ms}`} min={80} step={20} defaultValue={seg.duration_ms} onBlur={num('duration_ms', '时长')} />
|
||||
</Field>
|
||||
<Field label="源入点 ms">
|
||||
<input key={`in-${seg.source_in_ms}`} type="number" min={0} step={20}
|
||||
defaultValue={seg.source_in_ms} onBlur={num('source_in_ms', '源入点')} />
|
||||
<NumberInput key={`in-${seg.source_in_ms}`} min={0} step={20} defaultValue={seg.source_in_ms} onBlur={num('source_in_ms', '源入点')} />
|
||||
</Field>
|
||||
<Field label="转场">
|
||||
<Select size="md" className="px-[7px] text-tiny" ariaLabel="片段出场转场"
|
||||
|
|
@ -839,12 +825,10 @@ function SegmentRow({ seg, i, count, item, queue, shot, transitions, busy, open,
|
|||
onChange={(v: any) => onPatch(seg, { transition_out: v }, '修改转场')} />
|
||||
</Field>
|
||||
<Field label="转场时长 ms">
|
||||
<input key={`tdur-${seg.transition_duration_ms}`} type="number" min={0} step={50}
|
||||
defaultValue={seg.transition_duration_ms} onBlur={num('transition_duration_ms', '转场时长')} />
|
||||
<NumberInput key={`tdur-${seg.transition_duration_ms}`} min={0} step={50} defaultValue={seg.transition_duration_ms} onBlur={num('transition_duration_ms', '转场时长')} />
|
||||
</Field>
|
||||
<Field label="音量">
|
||||
<input key={`vol-${seg.volume}`} type="number" min={0} max={3} step={0.05}
|
||||
defaultValue={seg.volume} onBlur={num('volume', '音量')} />
|
||||
<NumberInput key={`vol-${seg.volume}`} min={0} max={3} step={0.05} defaultValue={seg.volume} onBlur={num('volume', '音量')} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
<Actions>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,402 @@
|
|||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
基础层 + Ant Design 接管的三处细节
|
||||
-----------------------------------------------------------------------------
|
||||
这里只放两类东西:
|
||||
1) 元素级默认值(body/h1~h3/small/滚动条/焦点环/减弱动效)——不是控件皮肤;
|
||||
2) 必须靠 CSS 才能做到的 antd 集成:字段标签列宽、标签度量档位、浮层层级。
|
||||
任何「按钮/输入框/下拉长什么样」都去 src/theme/antd.ts 改 token,
|
||||
写在这里就等于又开了第三个皮肤来源(这正是历史上控件不一致的根因)。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
|
||||
html { -webkit-text-size-adjust: 100% }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--c-bg-app);
|
||||
color: var(--c-text);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--fs-body);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* 站内最小可读字号:中文在 10px 以下只剩墨点。父级字号更小时按 0.8 倍缩。 */
|
||||
small { font-size: max(0.8em, var(--fs-tiny)) }
|
||||
|
||||
h1 { font-size: var(--fs-h1); line-height: var(--fs-h1-lh); font-weight: 700; margin: 6px 0 0 }
|
||||
h2 { font-size: var(--fs-h2); line-height: var(--fs-h2-lh); font-weight: 700; margin: 5px 0 0 }
|
||||
h3 { font-size: var(--fs-title); line-height: var(--fs-title-lh); font-weight: 700; margin: 0 0 14px }
|
||||
|
||||
::selection { background: var(--c-accent-fill); color: var(--c-accent-ink) }
|
||||
|
||||
/* 键盘焦点必须始终可见(点按钮不出现描边,所以只看 :focus-visible) */
|
||||
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after {
|
||||
scroll-behavior: auto !important;
|
||||
animation-duration: .01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: .01ms !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
字段体系:「标题与控件对齐」的唯一机制
|
||||
-----------------------------------------------------------------------------
|
||||
症状(用户截图里那些):同一张表单里「显示名」的输入框比「角色」右移十几 px;
|
||||
筛选栏里标签在上、控件在下,一个字段吃掉整行。
|
||||
做法:标签列宽是一个 CSS 变量(--label-w),不是每个字段自己写的宽度。
|
||||
· 表单作用域(.nex-form)把它抬到 --field-label-w,整表共用一条控件左边界;
|
||||
· 工具条(.nex-ctlbar / .nex-card-actions / .nex-chipbar)压回 0,标签挨着控件;
|
||||
· 只给下限不给上限(minmax),比默认宽的中文标题宁可把那一格控件顶右,也不截断。
|
||||
需要严格对齐的抽屉表单由 <FormGrid labelWidth={n}> 把上下限锁成同一个数,
|
||||
此时超长标题自动折行(.nf-label 允许 anywhere)。
|
||||
控件本体(Ant Design)永远不写宽高:.nf-ctl 里的控件一律撑满列宽。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
|
||||
/* 表单作用域:12 等分栅格 + 标签列宽。列边界只在这里定义,FormRow 只负责跨格。 */
|
||||
.nex-form {
|
||||
--label-w: var(--field-label-w);
|
||||
--ctl-h: var(--ctl-h-main);
|
||||
display: grid;
|
||||
grid-template-columns: repeat(var(--form-cols, 12), minmax(0, 1fr));
|
||||
gap: var(--form-gap-y, 10px) var(--form-gap-x, 14px);
|
||||
align-items: start;
|
||||
min-width: 0;
|
||||
}
|
||||
/* 直接放在 FormGrid 里的字段独占一行(页面忘了写 FormRow 也不会挤成一列宽) */
|
||||
.nex-form > .nex-field, .nex-form > .nex-field-block { grid-column: 1 / -1 }
|
||||
/* 表单里混进非字段块(Panel、Notice、普通 div)时同样铺满整行:
|
||||
12 等分栅格下,没写 grid-column 的块会掉进 1/12 轨道,整张卡被压成 40px 宽。 */
|
||||
.nex-form > :not(.nex-form-row):not(.nex-field):not(.nex-field-block) { grid-column: 1 / -1; min-width: 0 }
|
||||
|
||||
/* 表单里的一行:有列数按跨格落位,没列数 auto-fit 自己降列 */
|
||||
.nex-form-row {
|
||||
/* 表单行永远站在主档:外层套了紧凑工具条(Ctlbar / ChipBar / 抽屉动作条)
|
||||
也不能把整排字段拖到 31px——一个容器只有一个 --ctl-h 档位。 */
|
||||
--ctl-h: var(--ctl-h-main);
|
||||
grid-column: 1 / -1;
|
||||
display: grid;
|
||||
align-items: start;
|
||||
min-width: 0;
|
||||
}
|
||||
.nex-form-row.nf-row-grid { grid-template-columns: repeat(var(--form-cols, 12), minmax(0, 1fr)) }
|
||||
/* auto-fit 的最小轨要用 min(基准, 100%):容器窄于基准(审核台右栏只有 173px,
|
||||
基准 200px)时,裸 minmax(200px,1fr) 的轨不会收缩,字段整个顶出卡片 27px。 */
|
||||
.nex-form-row.nf-row-auto { grid-template-columns: repeat(auto-fit, minmax(min(var(--row-min, 200px), 100%), 1fr)) }
|
||||
.nex-form-row { gap: var(--form-gap-y, 10px) var(--form-gap-x, 14px) }
|
||||
.nex-form-row.nf-tight { gap: var(--form-gap-y-tight, 8px) var(--form-gap-x-tight, 10px) }
|
||||
/* 基准栅格(FormGrid)里 tight 只准收纵向呼吸,列间距必须留在表单基准上:
|
||||
12 等分轨道里一换 column-gap,列线就按「前面已经过了几条轨道」累计漂移——
|
||||
900px 下同一个抽屉里 cols-3 行与 cols-4 tight 行的第二列控件左缘量出 465 / 467。 */
|
||||
.nex-form .nex-form-row.nf-tight { column-gap: var(--form-gap-x, 14px) }
|
||||
/* 跨格:cols 只决定「这行几个字段」。降列节奏照旧站 LATTICE:
|
||||
≤1180 两列字段拍平、三/四列变两列;≤900 全部最多两列;≤640 一行一个。 */
|
||||
.nf-cols-2 > * { grid-column: span 6 }
|
||||
.nf-cols-3 > * { grid-column: span 4 }
|
||||
.nf-cols-4 > * { grid-column: span 3 }
|
||||
.nf-cols-6 > * { grid-column: span 2 }
|
||||
@media (max-width: 1180px) {
|
||||
.nf-cols-2 > * { grid-column: span 12 }
|
||||
.nf-cols-3 > *, .nf-cols-4 > * { grid-column: span 6 }
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.nf-cols-2 > * { grid-column: span 12 }
|
||||
.nf-cols-3 > *, .nf-cols-4 > *, .nf-cols-6 > * { grid-column: span 6 }
|
||||
}
|
||||
@media (max-width: 640px) { .nex-form-row > * { grid-column: 1 / -1 } }
|
||||
/* 触摸档(≤560 = metrics.breakpoints.narrow):标签一律退回控件上方,只准堆叠,不准并排。
|
||||
原因:css-vars 在这一档把 --field-label-w 压成 0,本意是「一行一个字段,标签列没有对齐对象」,
|
||||
可标签列是 minmax(--label-w, max-content),压 0 等于把宽度交给每条标题自己——
|
||||
560px 的个人中心量出同一张表里控件左缘 137 / 149,430px 差到 23px,手机上最扎眼的就是这种歪。
|
||||
堆叠之后控件共用容器左缘,一个盒子只剩一条列线,长中文标题也不用挤在一行后面被裁。
|
||||
断点在这里写字面量,和 styles/index.css 是同一条已登记例外(media query 读不到 var())。 */
|
||||
@media (max-width: 560px) {
|
||||
.nex-form .nex-field { grid-template-columns: minmax(0, 1fr); row-gap: 5px; align-items: start }
|
||||
.nex-form .nex-field > .nf-label { line-height: 1.45 }
|
||||
/* 有说明文字的字段平时靠行高对齐控件首行,堆叠后这层补偿必须撤掉 */
|
||||
.nex-form .nex-field.nf-has-hint > .nf-label { line-height: 1.45 }
|
||||
.nex-form .nex-field > .nf-hint { grid-column: 1 }
|
||||
}
|
||||
/* 独占整行:width="full" 或 data-full(表格上方的长说明字段) */
|
||||
.nex-form-row > .nf-w-full, .nex-form-row > [data-full] { grid-column: 1 / -1 }
|
||||
/* stack:标签退回控件上方(抽屉里的长标题字段、代码类输入)。
|
||||
字段自己仍是 grid,所以这里改的是列轨道,而不是 flex-direction。 */
|
||||
.nex-form-row.nf-stack > .nex-field { grid-template-columns: minmax(0, 1fr); row-gap: 5px; align-items: start }
|
||||
.nex-form-row.nf-stack > .nex-field > .nf-label { line-height: 1.45 }
|
||||
.nex-form-row.nf-stack > .nex-field > .nf-hint { grid-column: 1 }
|
||||
.nex-field-block > .nf-hint { grid-column: auto }
|
||||
|
||||
/* 行内字段:标签在左、控件在右,两列共用同一条基线 */
|
||||
.nex-field {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(var(--label-w), var(--label-max, max-content)) minmax(0, 1fr);
|
||||
column-gap: 9px;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
/* 标签在上的长字段(多行文本、上传区) */
|
||||
.nex-field-block { display: flex; flex-direction: column; gap: 5px; min-width: 0 }
|
||||
|
||||
.nf-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
font-size: var(--fs-label);
|
||||
line-height: 1.45;
|
||||
color: var(--c-text-3);
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
/* 星号和标签文字是同一个 flex item,否则列方向会把「*」顶到下一行 */
|
||||
.nf-req { color: var(--c-danger); font-weight: 700; margin-inline-start: 1px }
|
||||
.nex-field-block .nf-label { flex: none }
|
||||
/* 有说明文字时标签与控件首行对齐(用行高居中,比 align-items:start + padding 稳) */
|
||||
.nf-has-hint { align-items: start }
|
||||
.nf-has-hint > .nf-label { line-height: var(--ctl-h) }
|
||||
.nf-ctl { display: block; min-width: 0 }
|
||||
.nf-hint {
|
||||
grid-column: 2;
|
||||
font-size: var(--fs-tiny);
|
||||
line-height: 1.5;
|
||||
color: var(--c-text-dim);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.nex-field-block > .nf-hint { grid-column: auto }
|
||||
|
||||
/* 控件撑满字段列:antd 的 Select/Picker 默认宽度随内容收缩,不写这条会长短不齐 */
|
||||
.nf-ctl > *:only-child { min-width: 0 }
|
||||
.nf-ctl > .ant-select,
|
||||
.nf-ctl > .ant-input,
|
||||
.nf-ctl > .ant-input-affix-wrapper,
|
||||
.nf-ctl > .ant-input-number,
|
||||
.nf-ctl > .ant-picker,
|
||||
.nf-ctl > .ant-input-textarea,
|
||||
.nf-ctl > textarea,
|
||||
.nf-ctl > .ant-mentions,
|
||||
.nf-ctl > .ant-segmented,
|
||||
.nf-ctl > .ant-radio-group,
|
||||
.nf-ctl > .ant-slider,
|
||||
.nf-ctl > .ant-upload-wrapper { width: 100% }
|
||||
|
||||
/* 字段宽度意图(工具条里的 flex basis / 栅格里的跨列都由同一档决定) */
|
||||
.nf-w-default { min-width: 0 }
|
||||
.nf-w-narrow { flex: 0 1 118px; min-width: 0 }
|
||||
.nf-w-grow { flex: 1 1 190px; min-width: 0 }
|
||||
.nf-w-wide { flex: 1 1 280px; min-width: 0 }
|
||||
.nf-w-full { flex: 0 0 100%; width: 100% }
|
||||
.nex-form-row > .nf-w-full, .nex-form > .nf-w-full { grid-column: 1 / -1 }
|
||||
.nex-form-row > .nf-w-narrow { min-width: 0 }
|
||||
|
||||
/* 分组说明(ChipBar / TagGroup 行首那句「筛选:」) */
|
||||
.nf-group-label { font-size: var(--fs-caption); color: var(--c-text-faint); margin-inline-end: 2px }
|
||||
/* 与标签同行的只读回显值:同一基线、同一字号档 */
|
||||
.nf-value { font-size: var(--fs-body); color: var(--c-text-2); overflow-wrap: anywhere }
|
||||
|
||||
/* ── 控件容器(三档之外没有第四种横排)───────────────────────────────────
|
||||
Ctlbar 含控件的横条(带 12px 下边距);CardActions 卡片内动作行(不带);
|
||||
BarRight 右靠的一组控件。三者只做布局,控件高度由 Dense 下发 antd small + --ctl-h。 */
|
||||
.nex-ctlbar { --label-w: 0px; display: block; min-width: 0; margin-block-end: 12px }
|
||||
.nex-ctlbar-inner {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
.nex-card-actions {
|
||||
--label-w: 0px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 7px 9px;
|
||||
min-width: 0;
|
||||
}
|
||||
.nex-barright { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-inline-start: auto; min-width: 0 }
|
||||
|
||||
/* ── 可点胶囊(Chip):与同排按钮等高,只读回显一律走 Tag ────────────────── */
|
||||
.nex-chipbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 7px 8px;
|
||||
min-width: 0;
|
||||
margin-block-end: 12px;
|
||||
}
|
||||
.nex-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
height: var(--ctl-h);
|
||||
padding-inline: 11px;
|
||||
border: 1px solid var(--c-line-strong);
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--c-bg-raise);
|
||||
color: var(--c-text-3);
|
||||
font-size: var(--fs-caption);
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition: background-color .14s ease, border-color .14s ease, color .14s ease;
|
||||
}
|
||||
.nex-chip:hover { background: var(--c-bg-active); border-color: var(--c-line-bright); color: var(--c-text) }
|
||||
.nex-chip.is-on {
|
||||
background: var(--c-accent-fill);
|
||||
border-color: var(--c-accent-fill);
|
||||
color: var(--c-accent-ink);
|
||||
font-weight: 700;
|
||||
}
|
||||
.nex-chip.is-on:hover { background: var(--c-accent-fill-deep); border-color: var(--c-accent-fill-deep) }
|
||||
.nex-chip.is-off { opacity: .45; cursor: not-allowed }
|
||||
.nex-chip-sm { height: calc(var(--ctl-h-md) - 6px); padding-inline: 9px; font-size: var(--fs-tiny) }
|
||||
|
||||
/* 多选回显:选中态胶囊 + 移除叉 */
|
||||
.nex-tag-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: 100%;
|
||||
min-height: var(--tag-h);
|
||||
padding-inline: var(--tag-px);
|
||||
border: 1px solid var(--c-accent-line);
|
||||
border-radius: var(--radius-chip);
|
||||
background: var(--c-accent-tint);
|
||||
color: var(--c-accent-bright);
|
||||
font-size: var(--tag-text);
|
||||
line-height: 1.45;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.nex-tag-chip-x {
|
||||
flex: none;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
padding: 0 1px;
|
||||
cursor: pointer;
|
||||
opacity: .65;
|
||||
}
|
||||
.nex-tag-chip-x:hover { opacity: 1 }
|
||||
|
||||
/* 数字气泡:与标签同度量,只收成 pill 并加粗 */
|
||||
.nex-badge { border-radius: var(--radius-pill); font-weight: 700; padding-inline: calc(var(--tag-px) + 1px) }
|
||||
/* 单个标签的密集档(容器挂 TAG_DENSE 时不需要它) */
|
||||
.nex-tag-solo-sm {
|
||||
--tag-h: var(--tag-h-sm);
|
||||
--tag-px: var(--tag-px-sm);
|
||||
--tag-gap: var(--tag-gap-sm);
|
||||
--tag-text: var(--tag-text-sm);
|
||||
}
|
||||
.nex-tag-icon { display: inline-flex; align-items: center; line-height: 0 }
|
||||
/* 只读标签行:组内 6px、组与下方 12px 定死 */
|
||||
.nex-taggroup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; margin-block-end: 12px }
|
||||
.nex-taggroup > .nf-group-label { flex: none }
|
||||
|
||||
/* ── 分页条:page_size 唯一的家 ─────────────────────────────────────────── */
|
||||
.nex-pager {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
margin-block-start: 12px;
|
||||
}
|
||||
|
||||
/* ── 滑杆字段:与 Field 共用标签列,值贴在右端不参与挤压 ─────────────────── */
|
||||
.nf-slider-ctl { display: flex; align-items: center; gap: 12px }
|
||||
.nf-slider-ctl .ant-slider { flex: 1 1 auto; min-width: 0; margin: 0 }
|
||||
.nf-slider-value {
|
||||
flex: none;
|
||||
min-width: 46px;
|
||||
text-align: right;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-body);
|
||||
font-weight: 400;
|
||||
color: var(--c-text-2);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* ── 复选与文件选择:antd 组件的两个收尾细节 ───────────────────────────── */
|
||||
.nex-check.ant-checkbox-wrapper { font-size: var(--fs-body); color: var(--c-text-2) }
|
||||
.nex-check .ant-checkbox + span { padding-inline-start: 6px; padding-inline-end: 0 }
|
||||
/* 整块按钮就是热区:input 铺满父按钮,点哪里都开文件对话框 */
|
||||
.ant-btn:has(> .nex-file-input), .ant-btn:has(.nex-file-input) { position: relative; overflow: hidden }
|
||||
.nex-file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer }
|
||||
|
||||
/* ── 分段控件:轨道高度必须正好落在档位上 ────────────────────────────────
|
||||
症状:窄屏体检量到 37px(触摸档只有 36/40/44),真值是 36.53;宽屏 31.03
|
||||
侥幸四舍五入成 31,所以只在 ≤560 犯病,看起来像「窄屏专属 bug」。
|
||||
根因:antd 把 .ant-segmented-item-label 的 min-height / line-height 写成
|
||||
「档位 − 2×trackPadding」这个整数,可 kit 的 <Tabs> 在 label 里放了一只
|
||||
inline-flex(图标 + count)。inline-flex 是行内盒,按基线参与行盒计算,
|
||||
把行盒顶高 0.5px,于是轨道 = 内容高 + 2×padding 不再是那个整数。
|
||||
做法:label 改成 flex 容器 + 居中,包装层退出基线计算;文字省略号本来在 label 上,
|
||||
flex 之后对它无效,改由包装层自己承接(min-width:0 才能被压缩)。
|
||||
为什么不在 theme/antd.ts 修:这是「内容参与行盒计算」,token 算不出这 0.5px。 */
|
||||
.nex-segmented .ant-segmented-item-label { display: flex; align-items: center; justify-content: center }
|
||||
.nex-segmented .ant-segmented-item-label > span { min-width: 0; overflow: hidden; text-overflow: ellipsis }
|
||||
|
||||
/* 长文本字段的最小高度:挂在容器上,往抽屉里加字段的人不必再记一遍。
|
||||
只准命中 textarea:以前连带命中了 .ant-input / affix-wrapper,
|
||||
抽屉里「名称」这种单行 Input 也被顶成 96px,一行三格就成了三块空盒子。 */
|
||||
.nex-textarea-tall :is(textarea, .ant-input-textarea > textarea),
|
||||
.nex-textarea-tall:is(textarea) {
|
||||
min-height: 96px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
/* ── 标签度量(Tag / Status / Badge / CheckableTag 共用一套尺子)──────────
|
||||
尺寸不写在标签上:容器(TagGroup、密集表格)把 --tag-* 压到 sm 档,
|
||||
整片标签一起降,于是同一行里三种标签严格等高。 */
|
||||
.nex-tag.ant-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--tag-gap);
|
||||
min-height: var(--tag-h);
|
||||
padding-inline: var(--tag-px);
|
||||
margin-inline-end: 0;
|
||||
font-size: var(--tag-text);
|
||||
line-height: 1.45;
|
||||
border-radius: var(--radius-chip);
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* 密集档:挂在容器上,不挂在单个标签上 */
|
||||
.nex-tag-dense {
|
||||
--tag-h: var(--tag-h-sm);
|
||||
--tag-px: var(--tag-px-sm);
|
||||
--tag-gap: var(--tag-gap-sm);
|
||||
--tag-text: var(--tag-text-sm);
|
||||
}
|
||||
/* 可点的筛选胶囊(CheckableTag)跟紧凑控件同高,和它旁边的下拉/搜索框一条中心线 */
|
||||
.nex-tag.ant-tag-checkable {
|
||||
height: var(--ctl-h);
|
||||
padding-inline: 11px;
|
||||
border-radius: var(--radius-pill);
|
||||
font-size: var(--fs-caption);
|
||||
user-select: none;
|
||||
}
|
||||
.nex-tag.ant-tag-checkable:not(.ant-tag-checkable-checked):hover { background: var(--c-bg-hover); color: var(--c-text) }
|
||||
|
||||
/* ── 浮层层级:站内自绘浮层(灯箱、下拉、抽屉)与 antd 浮层共用一套 z 轴 ──
|
||||
antd 默认 dropdown 1050 / drawer 1000 / modal 1000 / message 1010;
|
||||
我们的灯箱要盖住一切,抽屉里的下拉又要盖住抽屉本体,所以只动这两处。 */
|
||||
.ant-drawer .ant-select-dropdown,
|
||||
.ant-drawer .ant-picker-dropdown,
|
||||
.ant-drawer .ant-cascader-dropdown,
|
||||
.ant-drawer .ant-dropdown { z-index: 1100 }
|
||||
.ant-message { z-index: 1200 }
|
||||
/* 抽屉/弹窗的滚动区统一用细描边滚动条(与 scrollbar-slim 同一条配方) */
|
||||
.ant-drawer-body, .ant-modal-body { scrollbar-width: thin; scrollbar-color: var(--c-line-strong) transparent }
|
||||
.ant-drawer-body::-webkit-scrollbar, .ant-modal-body::-webkit-scrollbar { width: 8px; height: 8px }
|
||||
.ant-drawer-body::-webkit-scrollbar-thumb, .ant-modal-body::-webkit-scrollbar-thumb { background: var(--c-line-strong); border-radius: 8px }
|
||||
|
||||
/* ── 表格:单元格里的标签、按钮排成一排时不要互相挤(antd 的 cell 默认不换行) */
|
||||
.ant-table-cell .ant-tag + .ant-tag { margin-inline-start: 0 }
|
||||
.ant-table-wrapper .ant-table-cell { overflow-wrap: anywhere }
|
||||
.ant-table-wrapper .ant-table-cell-fix-left, .ant-table-wrapper .ant-table-cell-fix-right { background: var(--c-bg-panel) }
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
元素级默认值(Tailwind base 层)
|
||||
-----------------------------------------------------------------------------
|
||||
这里只管「裸元素长什么样」:页面里直接写 <input> / <label> / <h2> 也能拿到
|
||||
设计系统的尺子和配色;一旦某个地方需要不一样,加工具类就能盖掉
|
||||
(utilities 层排在 base 之后,不需要再靠 !important 和特指度打架)。
|
||||
重复出现的组合(按钮、控件栏、面板、抽屉…)不要加在这里,
|
||||
去 src/components/ui 里做成组件,样式以工具类形式写在组件内部。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
@layer base {
|
||||
html { -webkit-text-size-adjust: 100% }
|
||||
|
||||
body {
|
||||
@apply bg-app text-ink text-ui;
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
|
||||
/* 站内最小可读字号:<small> 的原生实现是 font-size:smaller(÷1.2),
|
||||
套在 10~11px 的容器里会掉到 8.3px,中文只剩一团墨点。
|
||||
元素选择器优先级最低,比它大的场景仍按父级 0.8 倍缩放。 */
|
||||
small { font-size: max(0.8em, 10px) }
|
||||
|
||||
h1 { @apply text-h1 font-bold; margin: 6px 0 0 }
|
||||
h2 { @apply text-h2 font-bold; margin: 5px 0 0 }
|
||||
h3 { @apply text-title font-bold; margin: 0 0 14px }
|
||||
|
||||
button, input, textarea, select { font: inherit }
|
||||
/* 按钮文案不折行:CJK 在窄列里会被切成两行行盒,撑出「野高度」(UI规范 §1.2)。
|
||||
卡片式按钮是热区不是控件,需要折行时用 whitespace-normal 显式豁免。 */
|
||||
button { cursor: pointer; white-space: nowrap }
|
||||
button:disabled { cursor: not-allowed }
|
||||
|
||||
/* 单行控件定高(--ctl-h 由所在容器决定),文字交给浏览器垂直居中 */
|
||||
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]),
|
||||
select,
|
||||
textarea {
|
||||
@apply w-full rounded-control border border-line-strong bg-field px-3 text-body text-ink outline-none;
|
||||
transition: border-color .14s ease;
|
||||
}
|
||||
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]),
|
||||
select { height: var(--ctl-h); padding-block: 0 }
|
||||
|
||||
/* 多行文本也归档位管:行数由 rows 决定,但「一行」必须正好等于 --ctl-h。
|
||||
默认 line-height 1.65 时 rows=2 的裸 textarea 量出来是 41.6px,
|
||||
比同一行里的 input(38px)高 3.6px,一排字段就参差不齐;
|
||||
把上下 padding 按 --ctl-h 倒推,rows=1 → 38px,之后每多一行正好多 1.5em。 */
|
||||
textarea {
|
||||
min-height: var(--ctl-h);
|
||||
resize: vertical;
|
||||
line-height: 1.5;
|
||||
padding-block: calc((var(--ctl-h) - 1.5em - 2px) / 2);
|
||||
}
|
||||
input:focus, textarea:focus, select:focus { border-color: var(--c-accent-deep) }
|
||||
input:disabled, textarea:disabled, select:disabled { @apply bg-sunken text-faint; opacity: .7 }
|
||||
|
||||
/* 原生下拉:抹掉 UA 皮肤后必须自己补箭头,并给箭头腾出右侧空间 */
|
||||
select {
|
||||
appearance: none; -webkit-appearance: none;
|
||||
background-image: var(--ctl-caret);
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 8px center;
|
||||
background-size: 15px 15px;
|
||||
padding-right: 28px;
|
||||
}
|
||||
|
||||
/* 数字框:UA 的 spinner 比控件本身还高(模型抽屉里那颗大箭头),
|
||||
尺寸和配色都不受控,统一去掉;步进动作交给旁边的按钮。 */
|
||||
input[type=number] { appearance: textfield; -moz-appearance: textfield }
|
||||
input[type=number]::-webkit-outer-spin-button,
|
||||
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0 }
|
||||
|
||||
/* 勾选类控件不参与定高,跟随系统强调色改成主色 */
|
||||
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--c-accent-fill) }
|
||||
|
||||
/* 键盘焦点必须始终可见(与鼠标 :focus 分开,点按钮不出现描边) */
|
||||
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px }
|
||||
|
||||
/* 数值滑杆:轨道和滑块都用令牌,两个主题都看得见 */
|
||||
input[type=range] { accent-color: var(--c-accent-fill); width: 100% }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after {
|
||||
scroll-behavior: auto !important;
|
||||
animation-duration: .01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: .01ms !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,163 @@
|
|||
/* 样式入口:令牌 → 元素默认值。工具类由 Tailwind 在编译期按源码里的实际用量生成。 */
|
||||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
样式入口(技术栈:React 18 + Ant Design 5 + Vite + Zustand + React Router 6)
|
||||
-----------------------------------------------------------------------------
|
||||
分工只有两条,写代码前先对号入座:
|
||||
· 控件(按钮 / 输入 / 下拉 / 表格 / 抽屉 / 标签 / 分页 / 提示…)= Ant Design 5,
|
||||
皮肤来自 src/theme/antd.ts,页面不许给控件拼 bg- / border- / rounded- 这类皮肤类;
|
||||
· 布局与自绘区域(flex/grid/间距/尺寸/断点 + 素材墙、时间线、灯箱、流程条)= Tailwind
|
||||
工具类 + src/styles/app.css,颜色字号只准用下面这套「语义名」。
|
||||
数值(颜色、字号、圆角、控件高度、断点)的唯一真源在 src/theme/{palette,metrics}.ts,
|
||||
由 src/theme/css-vars.ts 在启动时写成 --c-* / --fs-* / --radius-* / --ctl-h-*;
|
||||
这个文件只做「语义名 → 变量」的转发,本身不含一个像素。
|
||||
于是 Tailwind 类和 antd token 不可能漂成两套尺子——它们读的是同一份 TS。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
@import "tailwindcss";
|
||||
@import "./tokens.css";
|
||||
@import "./base.css";
|
||||
@import "./app.css";
|
||||
|
||||
/* 弹层里滚动的地方(下拉面板、抽屉、日志流)用细描边滚动条,
|
||||
避免出现一条系统默认的粗白条压在深色面板上。 */
|
||||
@theme {
|
||||
/* 清掉 Tailwind 默认调色板与字阶:页面上出现一个没登记的颜色/字号,类名本身就看得出来 */
|
||||
--color-*: initial;
|
||||
--text-*: initial;
|
||||
--radius-*: initial;
|
||||
--shadow-*: initial;
|
||||
|
||||
/* ── 表面(由底到顶 12 档)────────────────────────────────────────────── */
|
||||
--color-deepest: var(--c-bg-deepest);
|
||||
--color-app: var(--c-bg-app);
|
||||
--color-field: var(--c-bg-input);
|
||||
--color-sunken: var(--c-bg-sunken);
|
||||
--color-card: var(--c-bg-card);
|
||||
--color-shell: var(--c-bg-shell);
|
||||
--color-panel: var(--c-bg-panel);
|
||||
--color-raised: var(--c-bg-raised);
|
||||
--color-hover: var(--c-bg-hover);
|
||||
--color-raise: var(--c-bg-raise);
|
||||
--color-active: var(--c-bg-active);
|
||||
--color-emphasis: var(--c-bg-emphasis);
|
||||
|
||||
/* ── 描边 ─────────────────────────────────────────────────────────────── */
|
||||
--color-line-soft: var(--c-line-soft);
|
||||
--color-line: var(--c-line);
|
||||
--color-line-strong: var(--c-line-strong);
|
||||
--color-line-bright: var(--c-line-bright);
|
||||
--color-hairline: var(--c-hairline);
|
||||
|
||||
/* ── 文字 ─────────────────────────────────────────────────────────────── */
|
||||
--color-ink: var(--c-text);
|
||||
--color-ink-2: var(--c-text-2);
|
||||
--color-ink-3: var(--c-text-3);
|
||||
--color-muted: var(--c-text-muted);
|
||||
--color-faint: var(--c-text-faint);
|
||||
--color-dim: var(--c-text-dim);
|
||||
--color-on-accent: var(--c-accent-ink);
|
||||
|
||||
/* ── 语义色(文字 / 实心 / 底纹 / 描边 四件套)────────────────────────── */
|
||||
--color-accent: var(--c-accent);
|
||||
--color-accent-bright: var(--c-accent-bright);
|
||||
--color-accent-deep: var(--c-accent-deep);
|
||||
--color-accent-fill: var(--c-accent-fill);
|
||||
--color-accent-fill-deep: var(--c-accent-fill-deep);
|
||||
--color-accent-tint: var(--c-accent-tint);
|
||||
--color-accent-tint-2: var(--c-accent-tint2);
|
||||
--color-accent-line: var(--c-accent-line);
|
||||
--color-danger: var(--c-danger);
|
||||
--color-danger-bright: var(--c-danger-bright);
|
||||
--color-danger-tint: var(--c-danger-tint);
|
||||
--color-danger-tint-2: var(--c-danger-tint2);
|
||||
--color-danger-line: var(--c-danger-line);
|
||||
--color-danger-ink: var(--c-danger-ink);
|
||||
--color-warn: var(--c-warn);
|
||||
--color-warn-bright: var(--c-warn-bright);
|
||||
--color-warn-fill: var(--c-warn-fill);
|
||||
--color-warn-ink: var(--c-warn-ink);
|
||||
--color-warn-tint: var(--c-warn-tint);
|
||||
--color-warn-line: var(--c-warn-line);
|
||||
--color-info: var(--c-info);
|
||||
--color-info-tint: var(--c-info-tint);
|
||||
--color-info-line: var(--c-info-line);
|
||||
--color-success: var(--c-success);
|
||||
--color-success-tint: var(--c-success-tint);
|
||||
--color-success-line: var(--c-success-line);
|
||||
--color-pink: var(--c-pink);
|
||||
--color-sky: var(--c-sky);
|
||||
--color-white: var(--c-pure-white);
|
||||
--color-black: var(--c-pure-black);
|
||||
|
||||
/* ── 遮罩与投影 ───────────────────────────────────────────────────────── */
|
||||
--color-scrim: var(--c-scrim);
|
||||
--color-scrim-soft: var(--c-scrim-soft);
|
||||
--color-backdrop: var(--c-backdrop);
|
||||
--color-backdrop-shadow: var(--c-backdrop-shadow);
|
||||
--color-backdrop-veil: var(--c-backdrop-veil);
|
||||
--color-tint-success: var(--c-tint-success);
|
||||
--color-tint-info: var(--c-tint-info);
|
||||
--color-tint-accent: var(--c-tint-accent);
|
||||
--color-shade-1: var(--c-shade-1);
|
||||
--color-shade-2: var(--c-shade-2);
|
||||
--color-shade-3: var(--c-shade-3);
|
||||
|
||||
/* ── 字体与字阶(值来自 theme/metrics.ts 的 typeScale)───────────────── */
|
||||
--default-font-family: var(--font-sans);
|
||||
--font-sans: var(--font-sans);
|
||||
--font-mono: var(--font-mono);
|
||||
--text-tiny: var(--fs-tiny); --text-tiny--line-height: var(--fs-tiny-lh);
|
||||
--text-caption: var(--fs-caption); --text-caption--line-height: var(--fs-caption-lh);
|
||||
--text-label: var(--fs-label); --text-label--line-height: var(--fs-label-lh);
|
||||
--text-body: var(--fs-body); --text-body--line-height: var(--fs-body-lh);
|
||||
--text-ui: var(--fs-ui); --text-ui--line-height: var(--fs-ui-lh);
|
||||
--text-title: var(--fs-title); --text-title--line-height: var(--fs-title-lh);
|
||||
--text-md: var(--fs-md); --text-md--line-height: var(--fs-md-lh);
|
||||
--text-h2: var(--fs-h2); --text-h2--line-height: var(--fs-h2-lh);
|
||||
--text-lg: var(--fs-lg); --text-lg--line-height: var(--fs-lg-lh);
|
||||
--text-num-sm: var(--fs-num-sm); --text-num-sm--line-height: var(--fs-num-sm-lh);
|
||||
--text-num: var(--fs-num); --text-num--line-height: var(--fs-num-lh);
|
||||
--text-h1: var(--fs-h1); --text-h1--line-height: var(--fs-h1-lh);
|
||||
--text-3xl: var(--fs-3xl); --text-3xl--line-height: var(--fs-3xl-lh);
|
||||
--text-display: var(--fs-display); --text-display--line-height: var(--fs-display-lh);
|
||||
|
||||
/* ── 圆角六档 ─────────────────────────────────────────────────────────── */
|
||||
--radius-chip: var(--radius-chip);
|
||||
--radius-control: var(--radius-control);
|
||||
--radius-tile: var(--radius-tile);
|
||||
--radius-block: var(--radius-block);
|
||||
--radius-float: var(--radius-float);
|
||||
--radius-pill: var(--radius-pill);
|
||||
|
||||
--shadow-raise: 0 1px 2px var(--c-shade-1);
|
||||
--shadow-pop: 0 18px 44px var(--c-backdrop-shadow);
|
||||
--shadow-drawer: -25px 0 80px var(--c-shade-2);
|
||||
|
||||
/* 断点是这个体系里唯一「两边都要写」的数:media query 不能读 var(),
|
||||
所以这里是字面量,改档位的另一处在 src/theme/metrics.ts 的 breakpoints。
|
||||
|
||||
⚠ short 是**宽度** 820px,不是「屏幕矮」。名字从旧站抄过来的,
|
||||
Tailwind 的 --breakpoint-* 只会生成 (width < N),没有高度档位。
|
||||
资产库左栏在 430px 手机上把「人物 / 定妆、造型与角色一致性」压成
|
||||
一个字一行(实测正文块只剩 16.7px),就是有人按字面理解把
|
||||
`max-short:grid-cols-3` 当成了「矮屏就三列并排」——430 宽的屏同时
|
||||
也是 ≤820 宽的屏,三列各 104px,扣掉图标和计数就见底了。
|
||||
需要按高度排布请写 `@media (max-height: …)`,别借这一档。 */
|
||||
--breakpoint-huge: 1440px;
|
||||
--breakpoint-mid: 1180px;
|
||||
--breakpoint-mid2: 1100px;
|
||||
--breakpoint-nav: 900px;
|
||||
--breakpoint-short: 820px;
|
||||
--breakpoint-tiny: 640px;
|
||||
--breakpoint-narrow: 560px;
|
||||
|
||||
--animate-spin-slow: nex-spin .8s linear infinite;
|
||||
--animate-pulse-soft: nex-pulse 1.6s ease-in-out infinite;
|
||||
--animate-fade-in: nex-fade-in .12s ease-out;
|
||||
--animate-agent-in: nex-agent-in .45s ease-out both;
|
||||
--animate-agent-pulse: nex-agent-pulse 1.4s infinite;
|
||||
--animate-agent-step: nex-agent-step 1.1s ease-in-out infinite alternate;
|
||||
--animate-agent-scan: nex-agent-scan 4s linear infinite;
|
||||
}
|
||||
|
||||
/* 极少数「同一元素两个主题形状不同」的场合用 light:;能用令牌解决就别用它。 */
|
||||
@custom-variant light (&:where([data-theme="light"], [data-theme="light"] *));
|
||||
|
||||
/* 弹层里滚动的地方用细描边滚动条,避免一条系统默认粗白条压在深色面板上。 */
|
||||
@utility scrollbar-slim {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--c-line-strong) transparent;
|
||||
|
|
@ -18,3 +171,16 @@
|
|||
scrollbar-width: none;
|
||||
&::-webkit-scrollbar { display: none }
|
||||
}
|
||||
|
||||
@keyframes nex-spin { to { transform: rotate(360deg) } }
|
||||
@keyframes nex-fade-in { from { opacity: 0 } }
|
||||
@keyframes nex-pulse { 50% { opacity: .45 } }
|
||||
@keyframes nex-agent-in { from { opacity: 0; transform: translateY(8px) } }
|
||||
@keyframes nex-agent-pulse {
|
||||
70% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--c-accent) 0%, transparent) }
|
||||
100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c-accent) 0%, transparent) }
|
||||
}
|
||||
@keyframes nex-agent-step {
|
||||
to { box-shadow: 0 0 14px color-mix(in srgb, var(--c-warn-bright) 35%, transparent) }
|
||||
}
|
||||
@keyframes nex-agent-scan { from { top: 5% } to { top: 95% } }
|
||||
|
|
|
|||
|
|
@ -1,400 +0,0 @@
|
|||
/* ══════════════════════════════════════════════════════════════════════════
|
||||
设计令牌 · 全站唯一的「颜色 / 尺子」定义处(docs/UI规范.md §0 的那三块基础设施)
|
||||
-----------------------------------------------------------------------------
|
||||
两层结构,别混:
|
||||
① `--c-*` 原始值:深色写在 :root,浅色写在 [data-theme="light"]。
|
||||
切换主题只改 <html data-theme>(src/stores/theme.ts),组件不参与。
|
||||
② `@theme` 把原始值映射成 Tailwind 命名空间(--color-* / --text-* / …),
|
||||
于是页面里写的是语义类名 bg-panel、text-muted、rounded-block,
|
||||
拿到的值是 var(--color-panel) → var(--c-bg-panel):var 在用例处解析,
|
||||
主题一翻,全部工具类跟着翻,不需要重渲染。
|
||||
新增一个视觉概念时的规矩:先在 ① 补值(两个主题都要),再在 ② 起个语义名。
|
||||
页面里出现 text-[#123456] 这种硬编码色 = 绕过了令牌体系,按返工处理。
|
||||
══════════════════════════════════════════════════════════════════════════ */
|
||||
|
||||
:root {
|
||||
--c-bg-deepest: #0b1116;
|
||||
--c-bg-app: #0d1117;
|
||||
--c-bg-input: #0e141a;
|
||||
--c-bg-sunken: #0f161d;
|
||||
--c-bg-card: #10171e;
|
||||
--c-bg-shell: #111820;
|
||||
--c-bg-panel: #141b23;
|
||||
--c-bg-raised: #18211a;
|
||||
--c-bg-hover: #1e2932;
|
||||
--c-bg-raise: #202b35;
|
||||
--c-bg-active: #243039;
|
||||
--c-bg-emphasis: #283540;
|
||||
--c-line-soft: #212c35;
|
||||
--c-line: #293640;
|
||||
--c-line-strong: #35434e;
|
||||
--c-line-bright: #4b5a64;
|
||||
--c-text: #e9edf2;
|
||||
--c-text-2: #c3ced7;
|
||||
--c-text-3: #adb9c3;
|
||||
--c-text-muted: #a1adb7;
|
||||
--c-text-faint: #96a2ad;
|
||||
--c-text-dim: #99a5b0;
|
||||
--c-on-accent: #18200f;
|
||||
--c-accent: #c5ee79;
|
||||
--c-accent-bright: #dff9a7;
|
||||
--c-accent-deep: #9acb60;
|
||||
--c-accent-fill: #c5ee79;
|
||||
--c-accent-fill-deep: #9acb60;
|
||||
--c-accent-tint: #1a2410;
|
||||
--c-accent-tint2: #263b28;
|
||||
--c-accent-line: #465840;
|
||||
--c-accent-ink: #18200f;
|
||||
--c-danger: #f0a59c;
|
||||
--c-danger-bright: #ffb9b0;
|
||||
--c-danger-tint: #482927;
|
||||
--c-danger-tint2: #3c2320;
|
||||
--c-danger-line: #6b3630;
|
||||
--c-danger-ink: #2a1210;
|
||||
--c-warn: #f0cf8e;
|
||||
--c-warn-bright: #f2d18b;
|
||||
--c-warn-fill: #f0cf8e;
|
||||
--c-warn-ink: #302108;
|
||||
--c-warn-tint: #3b3320;
|
||||
--c-warn-line: #584c2c;
|
||||
--c-info: #9bcdf1;
|
||||
--c-info-tint: #233649;
|
||||
--c-info-line: #2f4a5e;
|
||||
--c-success: #bce989;
|
||||
--c-success-tint: #22371f;
|
||||
--c-success-line: #3d5c33;
|
||||
--c-pink: #e5a4d0;
|
||||
--c-sky: #79c8ef;
|
||||
--c-pure-white: #ffffff;
|
||||
--c-pure-black: #000000;
|
||||
--c-scrim: rgba(4, 8, 11, .74);
|
||||
--c-scrim-soft: rgba(9, 13, 17, .82);
|
||||
/* 媒体预览(灯箱)用的观看背景:两种主题都压得够暗,让画面本身成为主体 */
|
||||
--c-backdrop: rgba(2, 5, 8, .82);
|
||||
--c-backdrop-shadow: rgba(0, 0, 0, .55);
|
||||
--c-backdrop-veil: rgba(9, 14, 20, .62);
|
||||
--c-tint-success: rgba(38, 63, 32, .92);
|
||||
--c-tint-info: rgba(99, 132, 255, .10);
|
||||
--c-tint-accent: rgba(197, 238, 121, .16);
|
||||
--c-hairline: rgba(111, 135, 116, .24);
|
||||
--c-shade-1: rgba(0, 0, 0, .16);
|
||||
--c-shade-2: rgba(0, 0, 0, .24);
|
||||
--c-shade-3: rgba(0, 0, 0, .42);
|
||||
}
|
||||
|
||||
[data-theme="light"] {
|
||||
--c-bg-deepest: #e7edf4;
|
||||
--c-bg-app: #f0f4f8;
|
||||
--c-bg-input: #fbfcfe;
|
||||
--c-bg-sunken: #eef2f7;
|
||||
--c-bg-card: #f6f8fb;
|
||||
--c-bg-shell: #ffffff;
|
||||
--c-bg-panel: #ffffff;
|
||||
--c-bg-raised: #eef4ea;
|
||||
--c-bg-hover: #e9eff6;
|
||||
--c-bg-raise: #e2e9f1;
|
||||
--c-bg-active: #dae3ec;
|
||||
--c-bg-emphasis: #cfd9e3;
|
||||
--c-line-soft: #e9eef4;
|
||||
--c-line: #dbe3ea;
|
||||
--c-line-strong: #c3ccd6;
|
||||
--c-line-bright: #aab5bf;
|
||||
--c-text: #111a22;
|
||||
--c-text-2: #2c3946;
|
||||
--c-text-3: #3f4c58;
|
||||
--c-text-muted: #4d5762;
|
||||
--c-text-faint: #535d68;
|
||||
--c-text-dim: #555f6a;
|
||||
--c-on-accent: #18200f;
|
||||
--c-accent: #356309;
|
||||
--c-accent-bright: #2f5a08;
|
||||
--c-accent-deep: #3f6810;
|
||||
--c-accent-fill: #b9e277;
|
||||
--c-accent-fill-deep: #9bd34f;
|
||||
--c-accent-tint: #f3fbe6;
|
||||
--c-accent-tint2: #e6f5cf;
|
||||
--c-accent-line: #b3d78d;
|
||||
--c-accent-ink: #18200f;
|
||||
--c-danger: #b3261e;
|
||||
--c-danger-bright: #8f1710;
|
||||
--c-danger-tint: #fceae8;
|
||||
--c-danger-tint2: #f8d9d5;
|
||||
--c-danger-line: #e6b6b0;
|
||||
--c-danger-ink: #fceae8;
|
||||
--c-warn: #7d4a00;
|
||||
--c-warn-bright: #653c00;
|
||||
--c-warn-fill: #f2c96f;
|
||||
--c-warn-ink: #382506;
|
||||
--c-warn-tint: #fdf3dd;
|
||||
--c-warn-line: #e4cd9c;
|
||||
--c-info: #0a5a90;
|
||||
--c-info-tint: #e6f2fb;
|
||||
--c-info-line: #b6d7f0;
|
||||
--c-success: #2c6510;
|
||||
--c-success-tint: #e9f6df;
|
||||
--c-success-line: #bfe0a8;
|
||||
--c-pink: #96326e;
|
||||
--c-sky: #0a5a90;
|
||||
--c-pure-white: #ffffff;
|
||||
--c-pure-black: #000000;
|
||||
--c-scrim: rgba(30, 41, 52, .52);
|
||||
--c-scrim-soft: rgba(255, 255, 255, .82);
|
||||
--c-backdrop: rgba(20, 28, 38, .58);
|
||||
--c-backdrop-shadow: rgba(8, 14, 22, .30);
|
||||
--c-backdrop-veil: rgba(24, 32, 42, .55);
|
||||
--c-tint-success: rgba(233, 246, 223, .92);
|
||||
--c-tint-info: rgba(11, 97, 155, .10);
|
||||
--c-tint-accent: rgba(95, 156, 26, .12);
|
||||
--c-hairline: rgba(120, 140, 120, .30);
|
||||
--c-shade-1: rgba(15, 23, 32, .06);
|
||||
--c-shade-2: rgba(15, 23, 32, .10);
|
||||
--c-shade-3: rgba(15, 23, 32, .16);
|
||||
}
|
||||
|
||||
/* ── 控件高度体系(全站唯一,先读这段再改任何控件样式)──────────────────────
|
||||
症状:同一个视觉行里按钮 38、下拉 31、输入框 34,中心线错开。
|
||||
根因:控件高度靠各自 padding 撑,补丁散落在十几个文件里。
|
||||
做法:控件一律 h-(--ctl-h) 定高;容器只声明自己是哪一档
|
||||
([Ctlbar] / [ChipBar] 用 Tailwind 任意属性写 --ctl-h:var(--ctl-h-md)),
|
||||
行内所有控件随之等高。要改尺寸只改下面两个值。
|
||||
· 主尺寸 --ctl-h-main = 38px:表单字段、页面级主按钮
|
||||
· 紧凑 --ctl-h-md = 31px:工具条、筛选条、卡片动作行、chip / 分段开关
|
||||
触摸档(≤560px)只抬这两档令牌,页面不许自己写 min-height/padding 补丁。 */
|
||||
:root {
|
||||
--ctl-h-main: 38px;
|
||||
--ctl-h-md: 31px;
|
||||
--ctl-h: var(--ctl-h-main);
|
||||
/* 标签度量(ui/Status.tsx 的 Tag / Status / Badge 与紧凑档 Chip 共用)。
|
||||
规矩和 --ctl-h 一模一样:尺寸不写在标签上,容器(TagGroup、密集表格)
|
||||
把 --tag-* 压到 sm 档,整片标签一起降;于是同一行里三种标签严格等高。 */
|
||||
--tag-h-main: 20px; --tag-px-main: 7px; --tag-gap-main: 5px; --tag-text-main: 11px;
|
||||
--tag-h-sm: 18px; --tag-px-sm: 6px; --tag-gap-sm: 4px; --tag-text-sm: 10px;
|
||||
--tag-h: var(--tag-h-main);
|
||||
--tag-px: var(--tag-px-main);
|
||||
--tag-gap: var(--tag-gap-main);
|
||||
--tag-text: var(--tag-text-main);
|
||||
/* 字段标签列宽(ui/Controls.tsx 的 Field)。
|
||||
症状:同一张表单里「显示名」的输入框和「角色」的输入框左边缘差 8px——
|
||||
标签是 auto 宽的,中文标签 2~5 字,控件起点自然跟着字数漂。
|
||||
做法:表单作用域(FormRow)把标签列钉成 var(--field-label-w),
|
||||
同行/同列的所有控件共用一条左边界;筛选条这类贴边排版由 Ctlbar 把它压回 0
|
||||
(= minmax(0,max-content),回到标签挨着控件的老样子)。
|
||||
取 66px 是量出来的:全站 193 个行内字段标签的 p90 是 62px,
|
||||
比它长的(「覆盖负面提示词(可选)」这类)由 minmax(--,max-content) 自己撑开,
|
||||
宁可那一格控件右移,也不把标题截断。 */
|
||||
--field-label-w: 66px;
|
||||
/* 勾选框边长(primitives/Checkbox)。原生 checkbox 在 macOS 是 14px 系统绿圆角块、
|
||||
在 Windows 是方角,同一张表里并排就是两套控件;换成自绘后尺寸收成这一个令牌,
|
||||
触摸档抬到 18px(仍然小于 --ctl-h-md,不会把行高顶开)。 */
|
||||
--check-size: 14px;
|
||||
/* 标签列宽的作用域开关(不是尺寸,尺寸是上面的 --field-label-w)。
|
||||
默认 0px = 「标签挨着控件排」,这是筛选条/工具条要的;
|
||||
FormRow 在自己的作用域里把它抬到 var(--field-label-w),整表单共用一条控件左边界。
|
||||
写成开关而不是让 Field 直接读 --field-label-w,是为了让 Ctlbar 这类
|
||||
容器有明确的「压回」动作,而不是靠继承顺序碰运气。 */
|
||||
--label-w: 0px;
|
||||
/* 裸 <select> 的下拉箭头:base.css 把 select 的 appearance 抹掉了,
|
||||
不自己画就变成一个「没有 ▼ 的文本框」(分页条的「每页」正是这样)。
|
||||
几何与 components/forms/Caret.tsx 完全一致,只有颜色跟着主题翻。 */
|
||||
--ctl-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 7.5 10 12l4.5-4.5' fill='none' stroke='%23a1adb7' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
/* 顶栏高度:侧栏 sticky、分镜检查器的 top 都取这个值,差 1px 就露缝。
|
||||
64 = 顶栏内边距 7×2 + 下边框 1 + 流程控制台 49(17 + 4 + 16 + 内边距 10 + 边框 2)。 */
|
||||
--nex-bar: 64px;
|
||||
--nex-ctl: var(--ctl-h);
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
:root {
|
||||
--ctl-h-main: 40px; --ctl-h-md: 36px;
|
||||
/* 手机档一行只有一个字段,标签列没有对齐对象,直接挨着控件排 */
|
||||
--field-label-w: 0px;
|
||||
--check-size: 18px;
|
||||
}
|
||||
}
|
||||
/* 浅色主题下箭头要更深一档,否则在白底上几乎看不见 */
|
||||
[data-theme="light"] {
|
||||
--ctl-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 7.5 10 12l4.5-4.5' fill='none' stroke='%234d5762' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
/* Tailwind v4 主题层:先清掉默认调色板/字阶,只留设计系统的语义名,
|
||||
这样「页面上出现一个没登记的颜色/字号」在类名上就看得出来。 */
|
||||
@theme {
|
||||
--color-*: initial;
|
||||
--text-*: initial;
|
||||
--radius-*: initial;
|
||||
--shadow-*: initial;
|
||||
|
||||
/* 表面(由暗到亮)与描边 */
|
||||
--color-deepest: var(--c-bg-deepest);
|
||||
--color-app: var(--c-bg-app);
|
||||
--color-field: var(--c-bg-input);
|
||||
--color-sunken: var(--c-bg-sunken);
|
||||
--color-card: var(--c-bg-card);
|
||||
--color-shell: var(--c-bg-shell);
|
||||
--color-panel: var(--c-bg-panel);
|
||||
--color-raised: var(--c-bg-raised);
|
||||
--color-hover: var(--c-bg-hover);
|
||||
--color-raise: var(--c-bg-raise);
|
||||
--color-active: var(--c-bg-active);
|
||||
--color-emphasis: var(--c-bg-emphasis);
|
||||
--color-line-soft: var(--c-line-soft);
|
||||
--color-line: var(--c-line);
|
||||
--color-line-strong: var(--c-line-strong);
|
||||
--color-line-bright: var(--c-line-bright);
|
||||
|
||||
/* 文字:ink 是正文,往下逐级变淡 */
|
||||
--color-ink: var(--c-text);
|
||||
--color-ink-2: var(--c-text-2);
|
||||
--color-ink-3: var(--c-text-3);
|
||||
--color-muted: var(--c-text-muted);
|
||||
--color-faint: var(--c-text-faint);
|
||||
--color-dim: var(--c-text-dim);
|
||||
--color-on-accent: var(--c-accent-ink);
|
||||
|
||||
/* 主色(青柠)与语义色 */
|
||||
--color-accent: var(--c-accent);
|
||||
--color-accent-bright: var(--c-accent-bright);
|
||||
--color-accent-deep: var(--c-accent-deep);
|
||||
--color-accent-fill: var(--c-accent-fill);
|
||||
--color-accent-fill-deep: var(--c-accent-fill-deep);
|
||||
--color-accent-tint: var(--c-accent-tint);
|
||||
--color-accent-tint-2: var(--c-accent-tint2);
|
||||
--color-accent-line: var(--c-accent-line);
|
||||
--color-danger: var(--c-danger);
|
||||
--color-danger-bright: var(--c-danger-bright);
|
||||
--color-danger-tint: var(--c-danger-tint);
|
||||
--color-danger-tint-2: var(--c-danger-tint2);
|
||||
--color-danger-line: var(--c-danger-line);
|
||||
--color-danger-ink: var(--c-danger-ink);
|
||||
--color-warn: var(--c-warn);
|
||||
--color-warn-bright: var(--c-warn-bright);
|
||||
--color-warn-fill: var(--c-warn-fill);
|
||||
--color-warn-ink: var(--c-warn-ink);
|
||||
--color-warn-tint: var(--c-warn-tint);
|
||||
--color-warn-line: var(--c-warn-line);
|
||||
--color-info: var(--c-info);
|
||||
--color-info-tint: var(--c-info-tint);
|
||||
--color-info-line: var(--c-info-line);
|
||||
--color-success: var(--c-success);
|
||||
--color-success-tint: var(--c-success-tint);
|
||||
--color-success-line: var(--c-success-line);
|
||||
--color-pink: var(--c-pink);
|
||||
--color-sky: var(--c-sky);
|
||||
--color-white: var(--c-pure-white);
|
||||
--color-black: var(--c-pure-black);
|
||||
|
||||
/* 浮层 / 遮罩 */
|
||||
--color-scrim: var(--c-scrim);
|
||||
--color-scrim-soft: var(--c-scrim-soft);
|
||||
--color-backdrop: var(--c-backdrop);
|
||||
--color-backdrop-shadow: var(--c-backdrop-shadow);
|
||||
--color-backdrop-veil: var(--c-backdrop-veil);
|
||||
--color-tint-success: var(--c-tint-success);
|
||||
--color-tint-info: var(--c-tint-info);
|
||||
--color-tint-accent: var(--c-tint-accent);
|
||||
--color-hairline: var(--c-hairline);
|
||||
--color-shade-1: var(--c-shade-1);
|
||||
--color-shade-2: var(--c-shade-2);
|
||||
--color-shade-3: var(--c-shade-3);
|
||||
|
||||
/* 字阶:10px 是站内最小可读字号(中文低于 10px 只剩一团墨点) */
|
||||
--default-font-family: var(--font-sans);
|
||||
--font-sans: 'DM Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
||||
--text-tiny: 10px;
|
||||
--text-tiny--line-height: 1.5;
|
||||
--text-caption: 11px;
|
||||
--text-caption--line-height: 1.55;
|
||||
--text-label: 11.5px;
|
||||
--text-label--line-height: 1.5;
|
||||
--text-body: 12px;
|
||||
--text-body--line-height: 1.6;
|
||||
--text-ui: 13px;
|
||||
--text-ui--line-height: 1.6;
|
||||
--text-title: 14px;
|
||||
--text-title--line-height: 1.5;
|
||||
--text-md: 16px;
|
||||
--text-md--line-height: 1.45;
|
||||
--text-h2: 17px;
|
||||
--text-h2--line-height: 1.4;
|
||||
--text-lg: 20px;
|
||||
--text-lg--line-height: 1.35;
|
||||
--text-num-sm: 21px;
|
||||
--text-num-sm--line-height: 1.2;
|
||||
--text-num: 24px;
|
||||
--text-num--line-height: 1.2;
|
||||
--text-h1: 25px;
|
||||
--text-h1--line-height: 1.25;
|
||||
--text-3xl: 32px;
|
||||
--text-3xl--line-height: 1.25;
|
||||
--text-display: 42px;
|
||||
--text-display--line-height: 1.25;
|
||||
|
||||
/* 圆角 */
|
||||
--radius-chip: 5px;
|
||||
--radius-control: 7px;
|
||||
--radius-tile: 9px;
|
||||
--radius-block: 12px;
|
||||
--radius-float: 14px;
|
||||
--radius-pill: 999px;
|
||||
|
||||
/* 阴影:只区分「贴层浮起 / 弹出菜单 / 抽屉」三档 */
|
||||
--shadow-raise: 0 1px 2px var(--c-shade-1);
|
||||
--shadow-pop: 0 18px 44px var(--c-backdrop-shadow);
|
||||
--shadow-drawer: -25px 0 80px var(--c-shade-2);
|
||||
|
||||
/* 断点:沿用旧站已经调好的七档,名字按「这一档在收什么」取。
|
||||
页面不要再自己写 @media(1180px) 这类魔法数字(UI规范 §0)。
|
||||
huge 1440 超宽屏开始收窄
|
||||
mid 1180 右栏检查器落到下方、控制台收起当前节点
|
||||
mid2 1100 两栏布局转一栏
|
||||
nav 900 侧栏收成图标轨、顶栏品牌只剩徽标
|
||||
short 820 顶栏工具收成图标
|
||||
tiny 640 顶栏控制台收起徽标与文字标签
|
||||
narrow 560 手机档:控件升到 40/36px */
|
||||
--breakpoint-huge: 1440px;
|
||||
--breakpoint-mid: 1180px;
|
||||
--breakpoint-mid2: 1100px;
|
||||
--breakpoint-nav: 900px;
|
||||
--breakpoint-short: 820px;
|
||||
--breakpoint-tiny: 640px;
|
||||
--breakpoint-narrow: 560px;
|
||||
|
||||
/* 动效 */
|
||||
--animate-spin-slow: nex-spin .8s linear infinite;
|
||||
--animate-pulse-soft: nex-pulse 1.6s ease-in-out infinite;
|
||||
/* 弹层出现:下拉面板只做淡入。面板向上翻边时靠 transform:translateY(-100%) 定位,
|
||||
位移类动画会和它打架(面板会跳一下)。 */
|
||||
--animate-fade-in: nex-fade-in .12s ease-out;
|
||||
/* 抽屉 / 模态(Radix Dialog)的入场:位移写在 translate / scale 这两个独立属性上,
|
||||
不碰 transform——Tailwind v4 的定位(模态的 -translate-x-1/2)走的也是 translate,
|
||||
关键帧里再动 transform 才会互相覆盖。 */
|
||||
--animate-sheet-in: nex-sheet-in .18s cubic-bezier(.22,.8,.32,1);
|
||||
--animate-pop-in: nex-pop-in .14s ease-out;
|
||||
|
||||
/* 项目总控台(LLM 编排)的四个状态动画。
|
||||
它们表达的是「服务端还在干活」,不是装饰:控制台一打开就要让人看出
|
||||
这条指令是在跑还是在等,所以命名按用途取,不复用 pulse-soft。
|
||||
prefers-reduced-motion 由 base.css 全局降级(时长压到 .01ms),这里不再各写一份。 */
|
||||
--animate-agent-in: nex-agent-in .45s ease-out both;
|
||||
--animate-agent-pulse: nex-agent-pulse 1.4s infinite;
|
||||
--animate-agent-step: nex-agent-step 1.1s ease-in-out infinite alternate;
|
||||
--animate-agent-scan: nex-agent-scan 4s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes nex-spin { to { transform: rotate(360deg) } }
|
||||
@keyframes nex-fade-in { from { opacity: 0 } }
|
||||
@keyframes nex-sheet-in { from { opacity: 0; translate: 24px 0 } }
|
||||
@keyframes nex-pop-in { from { opacity: 0; scale: .98 } }
|
||||
@keyframes nex-pulse { 50% { opacity: .45 } }
|
||||
@keyframes nex-agent-in { from { opacity: 0; transform: translateY(8px) } }
|
||||
@keyframes nex-agent-pulse {
|
||||
70% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--c-accent) 0%, transparent) }
|
||||
100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c-accent) 0%, transparent) }
|
||||
}
|
||||
@keyframes nex-agent-step {
|
||||
to { box-shadow: 0 0 14px color-mix(in srgb, var(--c-warn-bright) 35%, transparent) }
|
||||
}
|
||||
@keyframes nex-agent-scan { from { top: 5% } to { top: 95% } }
|
||||
|
||||
/* 浅色变体:极少数「同一元素两个主题形状不同」的场合用 light:,
|
||||
能用令牌解决的不要用它(令牌已经跟着 data-theme 翻了)。 */
|
||||
@custom-variant light (&:where([data-theme="light"], [data-theme="light"] *));
|
||||
|
|
@ -0,0 +1,413 @@
|
|||
/**
|
||||
* Ant Design 5 的主题:把本站的色板 + 尺子翻成 antd 的 ThemeConfig。
|
||||
*
|
||||
* 这一份文件是「控件长什么样」的唯一答案。页面里不要再给 antd 控件写皮肤类
|
||||
* (不要拿 bg- 、border- 、rounded- 拼一个按钮),需要不一样就加语义档位或改这里的 token。
|
||||
*
|
||||
* 对齐的关键三件事:
|
||||
* 1) controlHeight 38 / controlHeightSM 31 与 CSS 侧 --ctl-h-main / --ctl-h-md 同一个数,
|
||||
* 所以 antd 控件和自绘区域在同一行里中心线一致;触摸档(≤560px)两路一起抬到 40 / 36,
|
||||
* 靠 buildAntdTheme(mode, { narrow }) 传进来,判定见 hooks/use-narrow.ts;
|
||||
* 2) fontSize 12 起步(antd 默认 14 对我们太胖,中文密集工作台要 12);
|
||||
* 3) 主按钮的实心色与文字色走 accent-fill / accent-ink,浅色主题下是
|
||||
* 「浅绿底 + 近黑字」,深色主题下是「亮绿底 + 深绿黑字」,两种主题都不靠白色撑对比度。
|
||||
*
|
||||
* cssVar: true —— antd 的 token 也落成 CSS 变量,切主题不重新生成样式表;
|
||||
* hashed: false —— 关掉样式哈希后缀,浮层里嵌套样式稳定,产物也小。
|
||||
*/
|
||||
import { theme as antdAlgorithms, type ThemeConfig } from 'antd'
|
||||
import { color, type ThemeMode } from './palette'
|
||||
import { antdFontSize, checkboxSize, checkboxSizeTouch, controlHeight, fieldLabelWidth, fontStack, radius, tag, typeScale } from './metrics'
|
||||
|
||||
export function buildAntdTheme(mode: ThemeMode, opts: { narrow?: boolean } = {}): ThemeConfig {
|
||||
const c = (k: Parameters<typeof color>[1]) => color(mode, k)
|
||||
const dark = mode === 'dark'
|
||||
|
||||
/* 触摸档(≤ breakpoints.narrow):主档/紧凑档抬到 40 / 36,取的是 metrics.controlHeight
|
||||
里同一张表的另两个数,lg 不跟着抬(页面不用 lg)。
|
||||
为什么在这里传参而不是在 CSS 里覆盖 .ant-* 的 height:antd 的内边距、选中项行高、
|
||||
Segmented 滑块高度全是从 controlHeight 反推的(见下面 Input 那段注释),
|
||||
只改外层高度会让文字歪在半空。CSS 侧的 css-vars.ts::touch() 读同一对令牌,两路同源。 */
|
||||
const H = opts.narrow
|
||||
? { main: controlHeight.touchMain, sm: controlHeight.touchSm, lg: controlHeight.lg }
|
||||
: { main: controlHeight.main, sm: controlHeight.sm, lg: controlHeight.lg }
|
||||
const CHK = opts.narrow ? checkboxSizeTouch : checkboxSize
|
||||
|
||||
return {
|
||||
algorithm: dark ? antdAlgorithms.darkAlgorithm : antdAlgorithms.defaultAlgorithm,
|
||||
cssVar: true,
|
||||
hashed: false,
|
||||
token: {
|
||||
fontFamily: fontStack,
|
||||
fontSize: antdFontSize.base,
|
||||
fontSizeSM: antdFontSize.sm,
|
||||
fontSizeLG: antdFontSize.lg,
|
||||
fontSizeXL: antdFontSize.xl,
|
||||
/* antd 的字号令牌带行高派生,这里把它钉回我们的尺子,控件文字行高不随组件变 */
|
||||
lineHeight: typeScale.body.lh,
|
||||
lineHeightSM: typeScale.caption.lh,
|
||||
lineHeightLG: typeScale.ui.lh,
|
||||
|
||||
controlHeight: H.main,
|
||||
controlHeightSM: H.sm,
|
||||
controlHeightLG: H.lg,
|
||||
controlInteractiveSize: CHK,
|
||||
sizeStep: 4,
|
||||
|
||||
borderRadius: radius.control,
|
||||
borderRadiusSM: radius.chip,
|
||||
borderRadiusLG: radius.tile,
|
||||
borderRadiusXS: radius.chip,
|
||||
|
||||
/* 品牌色:文字/描边/聚焦环用 accent,实心填充用 accent-fill */
|
||||
colorPrimary: c('accent'),
|
||||
colorPrimaryHover: c('accent-bright'),
|
||||
colorPrimaryActive: c(dark ? 'accent' : 'accent-bright'),
|
||||
colorTextLightSolid: c('accent-ink'),
|
||||
colorLink: c('success'),
|
||||
colorLinkHover: c(dark ? 'accent-bright' : 'accent-deep'),
|
||||
colorLinkActive: c('success'),
|
||||
|
||||
colorTextBase: c('text'),
|
||||
colorText: c('text'),
|
||||
colorTextSecondary: c('text-2'),
|
||||
colorTextTertiary: c('text-muted'),
|
||||
colorTextQuaternary: c('text-faint'),
|
||||
colorTextDisabled: c('text-faint'),
|
||||
|
||||
colorBgContainer: c('bg-input'),
|
||||
colorBgElevated: c('bg-panel'),
|
||||
colorBgLayout: c('bg-app'),
|
||||
colorBgSpotlight: c('bg-raised'),
|
||||
colorBgMask: c('scrim'),
|
||||
colorBgContainerDisabled: c('bg-sunken'),
|
||||
|
||||
colorBorder: c('line-strong'),
|
||||
colorBorderSecondary: c('line'),
|
||||
colorSplit: c('line-soft'),
|
||||
colorFill: dark ? 'rgba(255,255,255,.10)' : 'rgba(15,23,32,.08)',
|
||||
colorFillSecondary: dark ? 'rgba(255,255,255,.06)' : 'rgba(15,23,32,.05)',
|
||||
colorFillTertiary: c('bg-hover'),
|
||||
colorFillQuaternary: c('bg-card'),
|
||||
colorFillContent: c('bg-hover'),
|
||||
colorFillContentHover: c('bg-raise'),
|
||||
colorFillAlter: c('bg-card'),
|
||||
|
||||
colorSuccess: c('success'),
|
||||
colorSuccessBg: c('success-tint'),
|
||||
colorSuccessBorder: c('success-line'),
|
||||
colorSuccessHover: c(dark ? 'success' : 'accent-deep'),
|
||||
colorWarning: c('warn'),
|
||||
colorWarningBg: c('warn-tint'),
|
||||
colorWarningBorder: c('warn-line'),
|
||||
colorWarningHover: c('warn-fill'),
|
||||
colorError: c('danger'),
|
||||
colorErrorBg: c('danger-tint'),
|
||||
colorErrorBorder: c('danger-line'),
|
||||
colorErrorHover: c('danger-bright'),
|
||||
colorInfo: c('info'),
|
||||
colorInfoBg: c('info-tint'),
|
||||
colorInfoBorder: c('info-line'),
|
||||
|
||||
boxShadow: `0 1px 2px ${c('shade-1')}`,
|
||||
boxShadowSecondary: `0 18px 44px ${c('backdrop-shadow')}`,
|
||||
boxShadowTertiary: `0 1px 2px ${c('shade-1')}`,
|
||||
|
||||
wireframe: false,
|
||||
motionDurationMid: '.14s',
|
||||
motionDurationSlow: '.2s'
|
||||
},
|
||||
components: {
|
||||
/* ── 按钮:三档字号 + 两档高度,图标按钮是正方形(热区不小于控件)──────── */
|
||||
Button: {
|
||||
fontWeight: 600,
|
||||
borderRadius: radius.control,
|
||||
borderRadiusSM: radius.chip,
|
||||
borderRadiusLG: radius.control,
|
||||
controlHeight: H.main,
|
||||
controlHeightSM: H.sm,
|
||||
controlHeightLG: H.lg,
|
||||
paddingInline: 14,
|
||||
paddingInlineSM: 9,
|
||||
paddingInlineLG: 18,
|
||||
contentFontSize: typeScale.ui.size,
|
||||
contentFontSizeSM: typeScale.label.size,
|
||||
contentFontSizeLG: typeScale.title.size,
|
||||
iconGap: 5,
|
||||
onlyIconSize: typeScale.title.size,
|
||||
onlyIconSizeSM: typeScale.ui.size,
|
||||
onlyIconSizeLG: typeScale.md.size,
|
||||
primaryShadow: 'none',
|
||||
defaultShadow: 'none',
|
||||
dangerShadow: 'none',
|
||||
colorPrimary: c('accent-fill'),
|
||||
colorPrimaryHover: c('accent-fill-hover'),
|
||||
colorPrimaryActive: c('accent-fill-active'),
|
||||
defaultBg: c('bg-raise'),
|
||||
defaultColor: c('text-2'),
|
||||
defaultBorderColor: c('line-strong'),
|
||||
defaultHoverBg: c('bg-active'),
|
||||
defaultHoverColor: c('text'),
|
||||
defaultHoverBorderColor: c('line-bright'),
|
||||
defaultActiveBg: c('bg-emphasis'),
|
||||
defaultActiveColor: c('text'),
|
||||
defaultActiveBorderColor: c('line-bright'),
|
||||
borderColorDisabled: c('line'),
|
||||
colorBorder: c('line-strong')
|
||||
},
|
||||
|
||||
/* ── 输入类:定高由容器档位决定(sm 档由调用处给 size="small")。
|
||||
注意这里**不准**写 paddingBlock:antd 的内边距默认值就是
|
||||
(controlHeight − fontSize × lineHeight) / 2 − lineWidth,也就是「高度令牌反推出的唯一值」。
|
||||
一旦手写 padding 覆盖它,盒子高度就变成 padding 说话——历史上写成 6,
|
||||
12px 字号 × 1.6 行高 + 12 + 2 边框 = 33px,同一个表单里 input 33 而 button/select 38,
|
||||
同行控件中心线全歪。paddingInline 相反,antd 默认 15 太宽,必须显式收。 */
|
||||
Input: {
|
||||
controlHeight: H.main,
|
||||
controlHeightSM: H.sm,
|
||||
controlHeightLG: H.lg,
|
||||
paddingInline: 11,
|
||||
paddingInlineSM: 9,
|
||||
inputFontSize: typeScale.body.size,
|
||||
inputFontSizeSM: typeScale.body.size,
|
||||
hoverBorderColor: c('line-bright'),
|
||||
activeBorderColor: c('accent-deep'),
|
||||
activeShadow: `0 0 0 2px ${c('tint-accent')}`,
|
||||
errorActiveShadow: `0 0 0 2px ${c('danger-tint')}`,
|
||||
colorBgContainer: c('bg-input')
|
||||
},
|
||||
/* Textarea 没有独立 ComponentToken:它继承 Input 的 paddingBlock / paddingInline / fontSize,
|
||||
长文本的最小高度由 ui/Controls.tsx 的 TEXTAREA_TALL(容器级 CSS)给,避免两处定高。 */
|
||||
InputNumber: {
|
||||
controlHeight: H.main,
|
||||
controlHeightSM: H.sm,
|
||||
controlHeightLG: H.lg,
|
||||
inputFontSize: typeScale.body.size,
|
||||
inputFontSizeSM: typeScale.body.size,
|
||||
paddingInline: 11,
|
||||
paddingInlineSM: 9,
|
||||
hoverBorderColor: c('line-bright'),
|
||||
activeBorderColor: c('accent-deep'),
|
||||
activeShadow: `0 0 0 2px ${c('tint-accent')}`,
|
||||
addonBg: c('bg-card')
|
||||
},
|
||||
|
||||
/* ── 下拉:面板至少和触发器同宽(popupMatchSelectWidth 由 ui/Select.tsx 统一打开),
|
||||
长选项不换行、靠横向滚动/省略号,这是「下拉一塌糊住右边标题」的正解 */
|
||||
Select: {
|
||||
controlHeight: H.main,
|
||||
controlHeightSM: H.sm,
|
||||
optionFontSize: typeScale.body.size,
|
||||
optionHeight: H.sm,
|
||||
optionSelectedBg: c('accent-tint2'),
|
||||
optionSelectedColor: c('accent-bright'),
|
||||
optionActiveBg: c('bg-hover'),
|
||||
optionPadding: '5px 11px',
|
||||
hoverBorderColor: c('line-bright'),
|
||||
activeBorderColor: c('accent-deep'),
|
||||
activeOutlineColor: c('tint-accent')
|
||||
},
|
||||
/* Cascader / TreeSelect 的下拉面板复用 Select 的 token,不再各写一份 */
|
||||
|
||||
Checkbox: {
|
||||
controlInteractiveSize: CHK,
|
||||
borderRadiusSM: 4,
|
||||
colorPrimary: c('accent-fill'),
|
||||
colorPrimaryHover: c('accent-fill-hover')
|
||||
},
|
||||
Radio: {
|
||||
dotSize: CHK - 6,
|
||||
radioSize: CHK + 6,
|
||||
wrapperMarginInlineEnd: 10
|
||||
},
|
||||
Switch: {
|
||||
trackHeight: 20,
|
||||
handleSize: 16,
|
||||
trackMinWidth: 34,
|
||||
trackMinWidthSM: 28,
|
||||
trackHeightSM: 16,
|
||||
handleSizeSM: 12,
|
||||
innerMinMargin: 6
|
||||
},
|
||||
Slider: {
|
||||
trackBg: c('accent-fill'),
|
||||
trackHoverBg: c('accent-fill-hover'),
|
||||
railBg: c('bg-active'),
|
||||
railHoverBg: c('bg-emphasis'),
|
||||
handleColor: c('accent-fill'),
|
||||
handleActiveColor: c('accent-fill-hover'),
|
||||
handleSize: 12,
|
||||
handleSizeHover: 13,
|
||||
handleLineWidth: 0,
|
||||
handleActiveOutlineColor: c('tint-accent')
|
||||
},
|
||||
|
||||
/* ── 表格:12px 正文、11px 表头,行高由内边距控制;密集档 cellPaddingBlockSM */
|
||||
Table: {
|
||||
headerBg: c('bg-card'),
|
||||
headerColor: c('text-muted'),
|
||||
headerSplitColor: 'transparent',
|
||||
rowHoverBg: c('bg-hover'),
|
||||
rowSelectedBg: c('accent-tint'),
|
||||
rowSelectedHoverBg: c('accent-tint2'),
|
||||
borderColor: c('line-soft'),
|
||||
cellFontSize: typeScale.body.size,
|
||||
cellFontSizeMD: typeScale.body.size,
|
||||
cellFontSizeSM: typeScale.body.size,
|
||||
cellPaddingBlock: 9,
|
||||
cellPaddingInline: 12,
|
||||
cellPaddingBlockSM: 5,
|
||||
cellPaddingInlineSM: 8,
|
||||
footerBg: c('bg-card'),
|
||||
stickyScrollBarBg: c('line-strong')
|
||||
},
|
||||
|
||||
/* ── 容器 ───────────────────────────────────────────────────────────── */
|
||||
Card: {
|
||||
colorBorderSecondary: c('line'),
|
||||
headerBg: c('bg-card'),
|
||||
headerFontSize: typeScale.title.size,
|
||||
paddingLG: 18,
|
||||
bodyPadding: 18
|
||||
},
|
||||
Drawer: {
|
||||
/* 抽屉本体底色走 colorBgElevated(下面 Modal 一起给),这里只管遮罩与内边距 */
|
||||
colorBgMask: c('scrim'),
|
||||
paddingLG: 20
|
||||
},
|
||||
Modal: {
|
||||
contentBg: c('bg-shell'),
|
||||
headerBg: c('bg-raised'),
|
||||
footerBg: c('bg-raised'),
|
||||
titleColor: c('text'),
|
||||
titleFontSize: typeScale.md.size,
|
||||
paddingLG: 20,
|
||||
colorBgMask: c('scrim')
|
||||
},
|
||||
Popover: { colorBgElevated: c('bg-panel'), borderRadiusLG: radius.tile, titleMinWidth: 0 },
|
||||
Dropdown: {
|
||||
colorBgElevated: c('bg-panel'),
|
||||
borderRadiusLG: radius.tile,
|
||||
paddingBlock: 4,
|
||||
controlItemBgHover: c('bg-hover'),
|
||||
controlItemBgActive: c('accent-tint2'),
|
||||
controlPaddingHorizontal: 12
|
||||
},
|
||||
Tooltip: {
|
||||
colorBgSpotlight: c('bg-raised'),
|
||||
colorTextLightSolid: c('text-2'),
|
||||
borderRadiusLG: radius.chip,
|
||||
fontSize: typeScale.caption.size
|
||||
},
|
||||
|
||||
/* ── 导航 ───────────────────────────────────────────────────────────── */
|
||||
Menu: {
|
||||
itemBg: 'transparent',
|
||||
subMenuItemBg: 'transparent',
|
||||
itemColor: c('text-3'),
|
||||
itemHoverBg: c('bg-hover'),
|
||||
itemHoverColor: c('text'),
|
||||
itemSelectedBg: c('accent-tint'),
|
||||
itemSelectedColor: c('accent-bright'),
|
||||
itemActiveBg: c('accent-tint2'),
|
||||
itemHeight: 34,
|
||||
iconMarginInlineEnd: 10,
|
||||
itemBorderRadius: radius.control,
|
||||
itemMarginInline: 8,
|
||||
fontSize: typeScale.ui.size
|
||||
},
|
||||
Tabs: {
|
||||
titleFontSize: typeScale.ui.size,
|
||||
titleFontSizeSM: typeScale.body.size,
|
||||
horizontalItemPadding: '8px 2px',
|
||||
horizontalMargin: '0 0 12px 0',
|
||||
horizontalItemGutter: 18,
|
||||
inkBarColor: c('accent-fill'),
|
||||
itemColor: c('text-muted'),
|
||||
itemHoverColor: c('text'),
|
||||
itemSelectedColor: c('text'),
|
||||
cardHeight: H.sm,
|
||||
cardGutter: 6
|
||||
},
|
||||
Segmented: {
|
||||
trackBg: c('bg-card'),
|
||||
trackPadding: 3,
|
||||
itemSelectedBg: c('accent-fill'),
|
||||
itemSelectedColor: c('accent-ink'),
|
||||
itemColor: c('text-muted'),
|
||||
itemHoverColor: c('text'),
|
||||
borderRadius: radius.control,
|
||||
borderRadiusSM: radius.chip
|
||||
},
|
||||
Steps: {
|
||||
iconSize: 20,
|
||||
iconFontSize: typeScale.caption.size,
|
||||
fontSizeSM: typeScale.caption.size,
|
||||
titleLineHeight: typeScale.ui.lh
|
||||
},
|
||||
Breadcrumb: {
|
||||
itemColor: c('text-muted'),
|
||||
lastItemColor: c('text'),
|
||||
separatorColor: c('line-bright'),
|
||||
fontSize: typeScale.body.size
|
||||
},
|
||||
Pagination: {
|
||||
itemBg: c('bg-raise'),
|
||||
itemActiveBg: c('accent-fill'),
|
||||
itemActiveColor: c('accent-ink'),
|
||||
itemActiveColorHover: c('accent-fill-hover'),
|
||||
itemLinkBg: 'transparent',
|
||||
itemSize: H.sm,
|
||||
itemSizeSM: 24,
|
||||
borderRadius: radius.control
|
||||
},
|
||||
|
||||
/* ── 反馈 ───────────────────────────────────────────────────────────── */
|
||||
Alert: {
|
||||
defaultPadding: '8px 12px',
|
||||
withDescriptionPadding: '12px 14px',
|
||||
borderRadiusLG: radius.control
|
||||
},
|
||||
Message: { contentPadding: '8px 12px', borderRadiusLG: radius.tile, fontSize: typeScale.body.size },
|
||||
Notification: { borderRadiusLG: radius.float, colorIcon: c('text-muted') },
|
||||
Progress: {
|
||||
lineWidth: 5,
|
||||
defaultColor: c('accent-fill'),
|
||||
remainingColor: c('bg-active'),
|
||||
circleTextFontSize: `${typeScale.caption.size}px`
|
||||
},
|
||||
Tag: { defaultBg: c('bg-card'), defaultColor: c('text-muted'), borderRadiusSM: radius.chip },
|
||||
Badge: {
|
||||
indicatorHeight: tag.main.h,
|
||||
indicatorHeightSM: tag.sm.h,
|
||||
textFontSize: tag.main.text,
|
||||
textFontSizeSM: tag.sm.text,
|
||||
borderRadius: radius.pill
|
||||
},
|
||||
Empty: { colorTextDescription: c('text-faint') },
|
||||
Spin: { dotSize: 16, dotSizeSM: 12, dotSizeLG: 22 },
|
||||
Skeleton: { gradientFromColor: c('bg-card'), gradientToColor: c('bg-hover') },
|
||||
Result: { iconFontSize: 36 },
|
||||
|
||||
/* ── 表单:标签右对齐 + 固定标签列宽(对齐的唯一机制,见 metrics.fieldLabelWidth) */
|
||||
Form: {
|
||||
labelColor: c('text-muted'),
|
||||
labelFontSize: typeScale.label.size,
|
||||
labelRequiredMarkColor: c('danger'),
|
||||
labelHeight: H.main,
|
||||
itemMarginBottom: 12,
|
||||
verticalLabelPadding: '0 0 5px'
|
||||
},
|
||||
Descriptions: {
|
||||
labelBg: c('bg-card'),
|
||||
labelColor: c('text-muted'),
|
||||
contentColor: c('text-2'),
|
||||
titleMarginBottom: 10,
|
||||
itemPaddingBottom: 8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 字段标签列宽(antd 用 labelCol={{flex:'…'}} 固定像素列,和 CSS 侧 --field-label-w 同一个值) */
|
||||
export const labelColFlex = `${fieldLabelWidth}px`
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* 把 theme/palette.ts + theme/metrics.ts 写成 CSS 自定义属性。
|
||||
*
|
||||
* 为什么是运行时注入而不是再抄一份 CSS:抄一份就有两份真值,历史上「改一处忘另一处」
|
||||
* 已经让 antd 控件和自绘区域漂出过两套尺子。这里由 TS 生成一次,
|
||||
* Tailwind 的 @theme(styles/index.css)只做「语义名 → var(--c-*)」的转发,不含任何数字。
|
||||
*
|
||||
* 注入时机:main.tsx 在 createRoot 之前调 injectThemeVars()。#root 在这之前是空的,
|
||||
* 唯一可能露白的是 <html> 自己的底色,所以 index.html 的内联脚本里提前铺了
|
||||
* 一个同值字面量(只有这一个数字是抄的,值来自 palette.ts 的 ROOT_BG)。
|
||||
*/
|
||||
import { PALETTE } from './palette'
|
||||
import { barHeight, breakpoints, checkboxSize, checkboxSizeTouch, controlHeight, fieldLabelWidth, fontStack, monoStack, radius, tag, typeScale } from './metrics'
|
||||
import type { ThemeMode } from './palette'
|
||||
|
||||
const STYLE_ID = 'nex-theme-vars'
|
||||
|
||||
function block(mode: ThemeMode): string {
|
||||
const p = PALETTE[mode]
|
||||
const colors = Object.entries(p).map(([k, v]) => `--c-${k}:${v}`).join(';')
|
||||
return `[data-theme="${mode}"]{${colors}}`
|
||||
}
|
||||
|
||||
function geometry(): string {
|
||||
const radii = Object.entries(radius).map(([k, v]) => `--radius-${k}:${v}px`).join(';')
|
||||
const type = Object.entries(typeScale)
|
||||
.map(([k, v]) => `--fs-${k}:${v.size}px;--fs-${k}-lh:${v.lh}`).join(';')
|
||||
return [
|
||||
`:root{`,
|
||||
`--font-sans:${fontStack};--font-mono:${monoStack};`,
|
||||
`--ctl-h-main:${controlHeight.main}px;--ctl-h-md:${controlHeight.sm}px;--ctl-h:var(--ctl-h-main);`,
|
||||
/* lg 不进 --ctl-h 那条链(它不是「表单里的一档」):给盖在媒体上的大目标按钮用,
|
||||
窄屏不抬——触摸档上限就是 44,所以 touch() 里不覆盖它。
|
||||
注意每行末尾的分号:这些字符串是 join('') 拼起来的,漏一个就和下一条黏成
|
||||
`44px--radius-chip:5px`,整条声明被 CSS 解析器丢掉,用到它的地方静默退回 auto
|
||||
(灯箱箭头就从 42px 塌成 21px)。 */
|
||||
`--ctl-h-lg:${controlHeight.lg}px;`,
|
||||
`--tag-h-main:${tag.main.h}px;--tag-px-main:${tag.main.px}px;--tag-gap-main:${tag.main.gap}px;--tag-text-main:${tag.main.text}px;`,
|
||||
`--tag-h-sm:${tag.sm.h}px;--tag-px-sm:${tag.sm.px}px;--tag-gap-sm:${tag.sm.gap}px;--tag-text-sm:${tag.sm.text}px;`,
|
||||
`--tag-h:var(--tag-h-main);--tag-px:var(--tag-px-main);--tag-gap:var(--tag-gap-main);--tag-text:var(--tag-text-main);`,
|
||||
radii + ';',
|
||||
type + ';',
|
||||
`--field-label-w:${fieldLabelWidth}px;--check-size:${checkboxSize}px;--nex-bar:${barHeight}px;`,
|
||||
/* 标签列宽的作用域开关:默认 0 = 标签挨着控件(筛选条要的);
|
||||
表单栅格(Field 所在容器)把它抬到 --field-label-w,整表共用一条控件左边界。 */
|
||||
`--label-w:0px`,
|
||||
`}`
|
||||
].join('')
|
||||
}
|
||||
|
||||
function touch(): string {
|
||||
return `@media (max-width:${breakpoints.narrow}px){:root{`
|
||||
+ `--ctl-h-main:${controlHeight.touchMain}px;--ctl-h-md:${controlHeight.touchSm}px;`
|
||||
/* 手机档一行一个字段,标签列没有对齐对象,压回 0 */
|
||||
+ `--field-label-w:0px;--check-size:${checkboxSizeTouch}px}}`
|
||||
}
|
||||
|
||||
export function injectThemeVars() {
|
||||
const css = `${geometry()}${block('dark')}${block('light')}${touch()}`
|
||||
let el = document.getElementById(STYLE_ID) as HTMLStyleElement | null
|
||||
if (!el) {
|
||||
el = document.createElement('style')
|
||||
el.id = STYLE_ID
|
||||
document.head.appendChild(el)
|
||||
}
|
||||
el.textContent = css
|
||||
}
|
||||
|
||||
export { STYLE_ID as THEME_VARS_STYLE_ID }
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* 几何:控件高度、圆角、字阶、标签度量、断点 —— 全站唯一的一把尺子。
|
||||
*
|
||||
* 为什么要搬进 TS:以前这些数字写在 tokens.css 里,Ant Design 的 ThemeConfig 里
|
||||
* 再抄一遍,两套数字各自漂(antd 默认 controlHeight 32、borderRadius 6,
|
||||
* 我们的 input 38、圆角 7,同一个表单里就是两种控件)。现在数字只在这里出现一次,
|
||||
* antd.ts 读它生成 ThemeConfig,css-vars.ts 读它生成 --ctl-h-* / --radius-* / --text-*,
|
||||
* 两条路同源,控件和自绘区域不可能再长歪。
|
||||
*
|
||||
* 唯一的例外是断点:media query 不能读 var(),所以 Tailwind 的 @theme 里
|
||||
* 还要写字面量(src/styles/index.css),改断点时两边一起改。
|
||||
*/
|
||||
|
||||
/** 控件两档,没有第三档;触摸档(≤560px)只抬这两档令牌 */
|
||||
export const controlHeight = {
|
||||
/** 表单字段、页面主按钮 */
|
||||
main: 38,
|
||||
/** 工具条、筛选条、卡片动作行、chip、分段开关 */
|
||||
sm: 31,
|
||||
/** lg = 主档 + 4。窄屏不跟着抬(触摸档上限本来就是 44)。
|
||||
用它的地方:antd 的第三档,以及盖在媒体上的大目标按钮(灯箱翻页箭头)——
|
||||
那些按钮悬在图上,38 会挡住内容、31 点不准,只有 44 两头都说得过去。 */
|
||||
lg: 44,
|
||||
touchMain: 40,
|
||||
touchSm: 36
|
||||
}
|
||||
|
||||
/** 圆角六档:页面只准写 rounded-chip/control/tile/block/float/pill,禁止 rounded-[8px] */
|
||||
export const radius = { chip: 5, control: 7, tile: 9, block: 12, float: 14, pill: 999 }
|
||||
|
||||
/**
|
||||
* 字阶十四档(含行高)。中文在 10px 以下只剩墨点,所以最小就是 tiny=10。
|
||||
* 页面只准写 text-tiny/caption/label/body/ui/title/md/h2/lg/num-sm/num/h1/3xl/display。
|
||||
*/
|
||||
export const typeScale = {
|
||||
tiny: { size: 10, lh: 1.5 },
|
||||
caption: { size: 11, lh: 1.55 },
|
||||
label: { size: 11.5, lh: 1.5 },
|
||||
body: { size: 12, lh: 1.6 },
|
||||
ui: { size: 13, lh: 1.6 },
|
||||
title: { size: 14, lh: 1.5 },
|
||||
md: { size: 16, lh: 1.45 },
|
||||
h2: { size: 17, lh: 1.4 },
|
||||
lg: { size: 20, lh: 1.35 },
|
||||
'num-sm': { size: 21, lh: 1.2 },
|
||||
num: { size: 24, lh: 1.2 },
|
||||
h1: { size: 25, lh: 1.25 },
|
||||
'3xl': { size: 32, lh: 1.25 },
|
||||
display: { size: 42, lh: 1.25 }
|
||||
}
|
||||
|
||||
/** antd 的全局字号档位映射到本站尺子:控件文字用 body(12),浮层标题用 title/md */
|
||||
export const antdFontSize = { sm: typeScale.caption.size, base: typeScale.body.size, lg: typeScale.ui.size, xl: typeScale.md.size }
|
||||
|
||||
/**
|
||||
* 标签度量(Tag / Status / Badge 共用)。尺寸不写在标签上:
|
||||
* 容器(TagGroup、密集表格)把 --tag-* 压到 sm 档,整片标签一起降,同行严格等高。
|
||||
*/
|
||||
export const tag = {
|
||||
main: { h: 20, px: 7, gap: 5, text: 11 },
|
||||
sm: { h: 18, px: 6, gap: 4, text: 10 }
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段标签列宽:同行同列的控件共用一条左边界,这是「标题和控件对齐」的唯一机制。
|
||||
* 66 是量出来的(全站行内字段标签 p90 = 62px);更长的中文标题由
|
||||
* labelCol 的 minmax(…, max-content) 自己撑开,宁可那一格控件右移也不截断标题。
|
||||
*/
|
||||
export const fieldLabelWidth = 66
|
||||
|
||||
/** 勾选框边长(antd Checkbox 用 scale 控制,这里只做 CSS 侧兜底) */
|
||||
export const checkboxSize = 14
|
||||
export const checkboxSizeTouch = 18
|
||||
|
||||
/** 顶栏高度:侧栏 sticky、分镜检查器的 top 都取这个值,差 1px 就露缝 */
|
||||
export const barHeight = 64
|
||||
|
||||
/** 断点(降列节奏、侧栏折叠、触摸档都从这里取) */
|
||||
/* 全部是**视口宽度**(含 short——它继承旧站名字,读作「平板横屏以下」,
|
||||
不是「屏幕矮」;详见 styles/index.css 的警告)。
|
||||
tiny=640 / narrow=560 是手机与触摸档的分水岭:narrow 以下控件升到 36/40/44,
|
||||
tiny 以下多列布局一律并成单列——列宽低于 200px 时正文就已经在竖排了。 */
|
||||
export const breakpoints = {
|
||||
huge: 1440, mid: 1180, mid2: 1100, nav: 900, short: 820, tiny: 640, narrow: 560
|
||||
}
|
||||
|
||||
export const fontStack = "'DM Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif"
|
||||
export const monoStack = "ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace"
|
||||
|
||||
/** 把控件高度写成 CSS 变量名(页面容器用 var(--ctl-h) 切档,不要写数字) */
|
||||
export const controlVar = (tier: 'main' | 'sm' | 'lg') => `var(--ctl-h-${tier})`
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
/**
|
||||
* 色板:全站颜色的唯一出处。
|
||||
*
|
||||
* 一份 key → 两个值(dark / light)。同一个语义名在两套主题里承担同一个角色,
|
||||
* 换主题只换这张表,不换任何组件。
|
||||
*
|
||||
* 消费方有两个,都不许自己写十六进制:
|
||||
* 1) theme/css-vars.ts —— 把这张表写成 --c-* 自定义属性(Tailwind 语义工具类、
|
||||
* 时间线 / 素材墙 / 灯箱这些自绘区域从这里取色);
|
||||
* 2) theme/antd.ts —— 把这张表映射成 Ant Design 的 Seed/Map Token。
|
||||
* 于是 antd 控件(按钮、输入框、下拉、抽屉、表格)和我们的自绘区域永远同一套色,
|
||||
* 不会再出现「antd 的蓝 + 自绘的绿」「深色控件配浅色描边」这种拼贴感。
|
||||
*
|
||||
* 命名规矩:<层位>-<作用>。层位只有 bg-*(表面)、line-*(描边)、text-*(文字)三类,
|
||||
* 语义色(accent/danger/warn/info/success)各带四件套:文字色 / 实心填充 / 底色 / 描边。
|
||||
*/
|
||||
|
||||
export type ThemeMode = 'dark' | 'light'
|
||||
|
||||
/** 深色:key 就是 CSS 变量名去掉 --c- 前缀的那一段 */
|
||||
const dark = {
|
||||
/* 表面:从「最底下」到「最上面」共 12 档。差 1 档 ≈ 抬高一层的投影感。 */
|
||||
'bg-deepest': '#0b1116',
|
||||
'bg-app': '#0d1117',
|
||||
'bg-input': '#0e141a',
|
||||
'bg-sunken': '#0f161d',
|
||||
'bg-card': '#10171e',
|
||||
'bg-shell': '#111820',
|
||||
'bg-panel': '#141b23',
|
||||
'bg-raised': '#18211a',
|
||||
'bg-hover': '#1e2932',
|
||||
'bg-raise': '#202b35',
|
||||
'bg-active': '#243039',
|
||||
'bg-emphasis': '#283540',
|
||||
|
||||
/* 描边 */
|
||||
'line-soft': '#212c35',
|
||||
'line': '#293640',
|
||||
'line-strong': '#35434e',
|
||||
'line-bright': '#4b5a64',
|
||||
|
||||
/* 文字:ink 正文 / 2 次级 / 3 三级 / muted 说明 / faint 弱化 / dim 最弱 */
|
||||
'text': '#e9edf2',
|
||||
'text-2': '#c3ced7',
|
||||
'text-3': '#adb9c3',
|
||||
'text-muted': '#a1adb7',
|
||||
'text-faint': '#96a2ad',
|
||||
'text-dim': '#99a5b0',
|
||||
|
||||
/* 品牌绿:文字用 accent,实心块用 accent-fill,底纹用 tint,描边用 line */
|
||||
'accent': '#c5ee79',
|
||||
'accent-bright': '#dff9a7',
|
||||
'accent-deep': '#9acb60',
|
||||
'accent-fill': '#c5ee79',
|
||||
'accent-fill-deep': '#9acb60',
|
||||
/* 实心主按钮的悬停/按下色:深色主题往更亮走,浅色主题往更饱和走。
|
||||
做成派生令牌而不是在 antd.ts 里写 dark ? A : B,是为了让 CSS 侧(链接型按钮)
|
||||
和 antd 侧读到同一个名字。 */
|
||||
'accent-fill-hover': '#dff9a7',
|
||||
'accent-fill-active': '#c5ee79',
|
||||
'accent-tint': '#1a2410',
|
||||
'accent-tint2': '#263b28',
|
||||
'accent-line': '#465840',
|
||||
'accent-ink': '#18200f',
|
||||
|
||||
'danger': '#f0a59c',
|
||||
'danger-bright': '#ffb9b0',
|
||||
'danger-tint': '#482927',
|
||||
'danger-tint2': '#3c2320',
|
||||
'danger-line': '#6b3630',
|
||||
'danger-ink': '#2a1210',
|
||||
|
||||
'warn': '#f0cf8e',
|
||||
'warn-bright': '#f2d18b',
|
||||
'warn-fill': '#f0cf8e',
|
||||
'warn-ink': '#302108',
|
||||
'warn-tint': '#3b3320',
|
||||
'warn-line': '#584c2c',
|
||||
|
||||
'info': '#9bcdf1',
|
||||
'info-tint': '#233649',
|
||||
'info-line': '#2f4a5e',
|
||||
|
||||
'success': '#bce989',
|
||||
'success-tint': '#22371f',
|
||||
'success-line': '#3d5c33',
|
||||
|
||||
'pink': '#e5a4d0',
|
||||
'sky': '#79c8ef',
|
||||
'pure-white': '#ffffff',
|
||||
'pure-black': '#000000',
|
||||
|
||||
/* 浮层遮罩与投影 */
|
||||
'scrim': 'rgba(4, 8, 11, .74)',
|
||||
'scrim-soft': 'rgba(9, 13, 17, .82)',
|
||||
'backdrop': 'rgba(2, 5, 8, .82)',
|
||||
'backdrop-shadow': 'rgba(0, 0, 0, .55)',
|
||||
'backdrop-veil': 'rgba(9, 14, 20, .62)',
|
||||
'tint-success': 'rgba(38, 63, 32, .92)',
|
||||
'tint-info': 'rgba(99, 132, 255, .10)',
|
||||
'tint-accent': 'rgba(197, 238, 121, .16)',
|
||||
'hairline': 'rgba(111, 135, 116, .24)',
|
||||
'shade-1': 'rgba(0, 0, 0, .16)',
|
||||
'shade-2': 'rgba(0, 0, 0, .24)',
|
||||
'shade-3': 'rgba(0, 0, 0, .42)'
|
||||
}
|
||||
|
||||
export type ColorKey = keyof typeof dark
|
||||
|
||||
/** 浅色:类型逼着两套主题的 key 完全一致,漏一个就编译不过 */
|
||||
const light: Record<ColorKey, string> = {
|
||||
'bg-deepest': '#e7edf4',
|
||||
'bg-app': '#f0f4f8',
|
||||
'bg-input': '#fbfcfe',
|
||||
'bg-sunken': '#eef2f7',
|
||||
'bg-card': '#f6f8fb',
|
||||
'bg-shell': '#ffffff',
|
||||
'bg-panel': '#ffffff',
|
||||
'bg-raised': '#eef4ea',
|
||||
'bg-hover': '#e9eff6',
|
||||
'bg-raise': '#e2e9f1',
|
||||
'bg-active': '#dae3ec',
|
||||
'bg-emphasis': '#cfd9e3',
|
||||
|
||||
'line-soft': '#e9eef4',
|
||||
'line': '#dbe3ea',
|
||||
'line-strong': '#c3ccd6',
|
||||
'line-bright': '#aab5bf',
|
||||
|
||||
'text': '#111a22',
|
||||
'text-2': '#2c3946',
|
||||
'text-3': '#3f4c58',
|
||||
'text-muted': '#4d5762',
|
||||
'text-faint': '#535d68',
|
||||
'text-dim': '#555f6a',
|
||||
|
||||
'accent': '#356309',
|
||||
'accent-bright': '#2f5a08',
|
||||
'accent-deep': '#3f6810',
|
||||
'accent-fill': '#b9e277',
|
||||
'accent-fill-deep': '#9bd34f',
|
||||
'accent-fill-hover': '#9bd34f',
|
||||
'accent-fill-active': '#8ec744',
|
||||
'accent-tint': '#f3fbe6',
|
||||
'accent-tint2': '#e6f5cf',
|
||||
'accent-line': '#b3d78d',
|
||||
'accent-ink': '#18200f',
|
||||
|
||||
'danger': '#b3261e',
|
||||
'danger-bright': '#8f1710',
|
||||
'danger-tint': '#fceae8',
|
||||
'danger-tint2': '#f8d9d5',
|
||||
'danger-line': '#e6b6b0',
|
||||
'danger-ink': '#fceae8',
|
||||
|
||||
'warn': '#7d4a00',
|
||||
'warn-bright': '#653c00',
|
||||
'warn-fill': '#f2c96f',
|
||||
'warn-ink': '#382506',
|
||||
'warn-tint': '#fdf3dd',
|
||||
'warn-line': '#e4cd9c',
|
||||
|
||||
'info': '#0a5a90',
|
||||
'info-tint': '#e6f2fb',
|
||||
'info-line': '#b6d7f0',
|
||||
|
||||
'success': '#2c6510',
|
||||
'success-tint': '#e9f6df',
|
||||
'success-line': '#bfe0a8',
|
||||
|
||||
'pink': '#96326e',
|
||||
'sky': '#0a5a90',
|
||||
'pure-white': '#ffffff',
|
||||
'pure-black': '#000000',
|
||||
|
||||
'scrim': 'rgba(30, 41, 52, .52)',
|
||||
'scrim-soft': 'rgba(255, 255, 255, .82)',
|
||||
'backdrop': 'rgba(20, 28, 38, .58)',
|
||||
'backdrop-shadow': 'rgba(8, 14, 22, .30)',
|
||||
'backdrop-veil': 'rgba(24, 32, 42, .55)',
|
||||
'tint-success': 'rgba(233, 246, 223, .92)',
|
||||
'tint-info': 'rgba(11, 97, 155, .10)',
|
||||
'tint-accent': 'rgba(95, 156, 26, .12)',
|
||||
'hairline': 'rgba(120, 140, 120, .30)',
|
||||
'shade-1': 'rgba(15, 23, 32, .06)',
|
||||
'shade-2': 'rgba(15, 23, 32, .10)',
|
||||
'shade-3': 'rgba(15, 23, 32, .16)'
|
||||
}
|
||||
|
||||
export const PALETTE: Record<ThemeMode, Record<ColorKey, string>> = { dark, light }
|
||||
|
||||
/** 取色(antd.ts 里用;CSS 侧直接写 var(--c-…)) */
|
||||
export const color = (mode: ThemeMode, key: ColorKey): string => PALETTE[mode][key]
|
||||
|
||||
/** 首帧之前 index.html 里的内联脚本要铺的底色,只此两个值,从这里导出避免抄错 */
|
||||
export const ROOT_BG: Record<ThemeMode, string> = { dark: dark['bg-app'], light: light['bg-app'] }
|
||||
|
|
@ -17,7 +17,9 @@
|
|||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true
|
||||
"noEmit": true,
|
||||
"baseUrl": ".",
|
||||
"paths": { "@/*": ["./src/*"] }
|
||||
},
|
||||
"include": ["src", "vite.config.ts"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,16 @@ import react from '@vitejs/plugin-react'
|
|||
import tailwindcss from '@tailwindcss/vite'
|
||||
|
||||
declare const process: { env: Record<string, string | undefined> }
|
||||
/* 配置文件本身以 ESM 加载,import.meta.url 就够用,不必为此装 @types/node */
|
||||
|
||||
// 开发态把 /api 与 /media 代理到本地 FastAPI(默认 127.0.0.1:8000)
|
||||
const backend = process.env.NEX_BACKEND || 'http://127.0.0.1:8000'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
// '@' → src:标准控件组(shadcn)的组件源码一律 import '@/lib/utils'、'@/components/kit',
|
||||
// 别名和 tsconfig.json 的 paths 必须一致,否则 npx shadcn add 下来的文件跑不起来。
|
||||
resolve: { alias: { '@': new URL('./src', import.meta.url).pathname } },
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 5173,
|
||||
|
|
|
|||
|
|
@ -2175,3 +2175,304 @@ styles/tokens.css → components/primitives/ → components/{ui,forms}/ →
|
|||
真要做(命令面板、悬浮预览),按 §0.6.3 的三步流程加原语,别在页面里手搓。
|
||||
4. 日期/时间选择器、命令面板、Toast 队列这三个常见件还没需求,来了需求再补 `primitives`,
|
||||
这是 headless 架构最省事的一面:**加一个原语 ≈ 一个文件,加一个组件库 = 换一次方向盘。**
|
||||
|
||||
---
|
||||
|
||||
# 第二十六章 · 换成 Ant Design 5:把「页面自己拼皮肤」这件事从制度上关掉(2026-11-02)
|
||||
|
||||
## 26.1 第二十五章选错了什么
|
||||
|
||||
第二十五章的结论是「只买行为、不买皮肤」,落地成 Radix primitives + 自有皮肤。方向对了一半:
|
||||
**行为确实外包出去了,皮肤却仍然由 30 多个页面自己拼**。半个月后用户的原话是——
|
||||
|
||||
> 当前的页面组件太混乱了,前端请统一到如下技术栈:React 18 + Ant Design 5 + Vite + Zustand + React Router 6
|
||||
|
||||
这一句里真正的问题不是「antd 还是 Radix」,而是**同一件事有三千种写法**:
|
||||
左导航的内边距一页写 11px、一页写 12px;会亮的方块每页各长一套;
|
||||
白名单要从某个页面的 `className` 上抄一段切片才能匹配。
|
||||
Radix 那一轮把这类分叉治了一次,但**没有任何机制阻止它再长回来**——这才是"混乱"的本体。
|
||||
|
||||
所以这一轮做的不是"把 antd 装上",而是把**词汇表**收口:页面只准说业务,
|
||||
控件怎么长、怎么算高度,由 kit 层和一份令牌说了算,并且加两道闸盯着它不许反弹。
|
||||
|
||||
## 26.2 底座换了什么(版本读数,不是描述)
|
||||
|
||||
| 依赖 | 换之前 | 换之后 | 说明 |
|
||||
|---|---|---|---|
|
||||
| `react` / `react-dom` | 19.3.1 | **18.3.1** | 点名的就是 18;19 → 18 是**降级**,代价见 26.6 |
|
||||
| `react-router-dom` | 7.18.5 | **6.30.6** | 同上,点名为 6;`data router` API 不变,改的是路由声明处 |
|
||||
| `antd` | — | **5.29.3** | 唯一的标准控件组 |
|
||||
| `@ant-design/icons` | — | 6.3.4 | 只用了一颗(`SearchOutlined`,搜索框的放大镜) |
|
||||
| `@radix-ui/*` | 5 个包 | **0** | 行为层整个交回给 antd |
|
||||
| `class-variance-authority` | 有 | **0** | 尺子搬进 `theme/metrics.ts` 之后没有消费者了 |
|
||||
| `zustand` / `vite` / `tailwindcss` | 5.0.16 / — / 4.3.3 | 不变 | 已经在点上 |
|
||||
|
||||
规模(`frontend/src` 全量,含没进 git 的新文件——只看 `git diff --stat` 会把新增的 15 个文件漏在账外):
|
||||
|
||||
| 口径 | 换之前(HEAD) | 换之后 |
|
||||
|---|---|---|
|
||||
| `frontend/src` 源码文件 | 83 个 | **87 个** |
|
||||
| `frontend/src` 行数 | 20 307 行 | **20 795 行** |
|
||||
| 其中:改 / 删的旧文件 | — | +1 621 / −2 936 |
|
||||
| 其中:新增文件(`theme/`、`ui/{Tile,Menu,Input,Checkbox,Rail,field-labels}`、`app/providers.tsx`、`hooks/use-narrow.ts`、`lib/{layers,ref}.ts`、`styles/app.css`) | — | 15 个 / +1 803 |
|
||||
|
||||
**净 +488 行,不是上一稿写的「少了一千行」**:`git diff --stat` 只数 tracked 文件,
|
||||
而这一轮新写的 kit 层恰好全是新文件,1 803 行完全没进账。删掉的 2 936 行里有一大半
|
||||
是每页各写一遍的控件皮肤,加上整个 `primitives/` 层(11 个文件 1 133 行);
|
||||
补回来的 1 803 行是**只此一份**的 kit 与令牌。所以真实结论是「**同样面积的代码从
|
||||
三十个页面挪进了两个目录**」,行数基本没少——这比「少一千行」更值得留意:
|
||||
省下的不是字节,是**分叉的次数**。体检用的 `scripts/ui/`(3 个文件 995 行)另计。
|
||||
|
||||
## 26.3 四条根因(都有读数,且都不是"页面写错了")
|
||||
|
||||
1. **两套尺子**:antd 默认 `controlHeight=32`、`borderRadius=6`,而我们的 input 是 38、圆角 7。
|
||||
同一个表单里天然有两种控件。修法不是"把 antd 改成 38",而是**数字只有一个来源**:
|
||||
`theme/metrics.ts` 定义 → `theme/antd.ts` 据此生成 `ThemeConfig` → `theme/css-vars.ts` 据此生成
|
||||
`--ctl-h-* / --radius-* / --text-*`。antd 控件和自绘区读同一份,**结构上不可能再长歪**。
|
||||
2. **词汇表分叉在渲染结果里看不出来**:11px vs 12px 内边距这种 1px 级差异,`audit.py` 五项判据一条都不会红。
|
||||
所以光有"量结果"的闸不够,还得有"量用词"的闸(26.4 第二道)。
|
||||
3. **白名单抄类名 = 静默失效**:条目长这样 `^button\.flex\.items-center\.gap-2\.5`,是从页面 `className` 上抄的;
|
||||
kit 改一个 utility 规则它就不命中了。现在改成认**组件自己盖在 class 首位的标记类**
|
||||
(`nex-tile` / `nex-stat` / `nex-media-badge` / `nex-media-remove` / `nex-icon-spot` / `nex-drawer-body` / `nex-scrim` / `nex-tool`),
|
||||
组件在场必命中,组件删掉立刻以"白名单失效"报错。
|
||||
4. **探针会假绿**(本轮新病,前 25 章都没被发现):浮层用例找不到抽屉时会兜底 `scope = "main"`,
|
||||
把页面再量一遍,读数照样 `misaligned=0`。分镜「检查器」的字段全在 `main` **外面**那个 `<aside>` 里,
|
||||
**29 个字段 / 57 个输入控件 / 35 个按钮,一条都没被测过**。详见 26.4 最后一节。
|
||||
|
||||
## 26.4 改法
|
||||
|
||||
**① 皮肤只住三个地方**:kit 组件、`theme/antd.ts`、`styles/app.css`。页面里不许出现 `bg-` / `border-` / `rounded-` 拼控件。
|
||||
|
||||
**② antd 的合法落点**(实测 `grep -l "from 'antd"` 按目录计数):
|
||||
|
||||
| 目录 | 文件数 | 角色 |
|
||||
|---|---|---|
|
||||
| `components/ui/` | 9 | kit:控件 = antd + 统一皮肤 |
|
||||
| `components/forms/` | 3 | kit:表单控件(Select / MultiSelect / SecretInput) |
|
||||
| `theme/antd.ts` | 1 | 令牌 → `ThemeConfig` |
|
||||
| `app/providers.tsx` | 1 | `ConfigProvider` 挂载点 |
|
||||
| **`pages/` + `app/layout/`** | **0** | 页面一个都不许直接 import antd |
|
||||
|
||||
**③ 页面原生控件清零**(只数 `pages/` 与 `app/`,kit 内部当然允许):
|
||||
|
||||
| 标签 | 换之前(`git show HEAD`) | 现在 |
|
||||
|---|---|---|
|
||||
| `<button>` | 17 | **0**(剩 1 处是注释里的字) |
|
||||
| `<input>` | 132 | **0**(剩 1 处是注释里的字) |
|
||||
| `<textarea>` | 40 | **0** |
|
||||
| `<select>` | 0(上一轮已清) | 0 |
|
||||
|
||||
**④ 两道闸**:
|
||||
|
||||
- `scripts/ui/audit.py`——量**渲染结果**:`naked` / `misaligned` / `tiers` / `overflow` / `dd` / `console` /
|
||||
`surface` 七项(第 7 项是 26.9 之后补的),
|
||||
14 个页面视图 × 1440/1280/900 × 明暗 + 10 个浮层用例 × 1440/900/560/430 × 明暗。
|
||||
- `scripts/ui/vocab.py`——量**源码用词**:规则 1 antd 落点、规则 2 页面禁原生控件、
|
||||
规则 3 `<Chip>` 必须带动作(点不动的胶囊读起来像按钮,只读回显该用 `<Tag>`)、
|
||||
规则 4 页面私有皮肤常量**按文件棘轮**(现存账 **79 个**,只降不升;`Help.tsx` 36 个带理由豁免)、
|
||||
规则 5 **ref 契约**(R10)、规则 6 **JSX 子节点上的注释**(26.7)。
|
||||
|
||||
**⑤ 浮层用例必须自证"我量的是哪块表面"**(治 26.3-4 的假绿):`OVERLAYS` 每条补第 4 项
|
||||
(`drawer` / `modal` / `panel` / `main`),实际落点对不上就 `code = 1`。顺带挖出两个真问题:
|
||||
|
||||
- 入口 `sb_shot` 原来点文案 `"分镜与脚本"`,命中的是侧边栏里**同名的导航项**,
|
||||
而镜头卡是 `<article onClick>` 不是按钮——按文案永远点不中。
|
||||
现在 `click_any` 支持 `@` 前缀直接给 CSS 选择器,镜头卡挂了 `data-shot-card`。
|
||||
- 探针跑得比动画快:点完立刻量,量到 antd 水波纹 `.ant-wave` 正在胀开那一帧,
|
||||
报出"横向溢出 55px"。加 `settle()`(连续两次全页盒子指纹相同才量)从根上治,
|
||||
`metrics.TRANSIENT` 再兜一层——**瞬时残影不是版面**。
|
||||
|
||||
反向验证(没做这一步,闸门只是装饰):把 `sb_shot` 的期望表面临时改成 `modal`,
|
||||
audit 立刻红并打印"没量到该量的表面:期望 modal,实际 panel"、退出码 1 ✅;改回 `panel` 恢复绿色。
|
||||
|
||||
## 26.5 逐项验收(2026-11-02 收尾复跑,全部是工具原始读数)
|
||||
|
||||
`main.tsx` 修掉 26.7 那条之后重跑了一遍全量——那一行字把整站内容往下推了 30px,
|
||||
带着它读出来的数不能算验收。
|
||||
|
||||
| 判据 | 改前 | 改后(实测) |
|
||||
|---|---|---|
|
||||
| 页面直接 `import 'antd'` | 30 多个文件各调各的标准件 | **0**(`pages/` + `app/layout/` 合计,vocab 规则 1) |
|
||||
| 页面里的原生控件 | `<button>` 17 · `<input>` 132 · `<textarea>` 40 | **0 / 0 / 0**(vocab 规则 2) |
|
||||
| 页面体检 `--only page` | — | **EXIT=0**:1440/1280/900 × 明暗 6 组 × 14 视图 = 84 行,每行 `naked=0 misaligned=0 overflow=0 console=0`,未解释档位 0 |
|
||||
| 浮层体检 `--only overlay` | 上一轮 4 项「没量到该量的表面」 | **EXIT=0**:1440/900/560/430 × 明暗 8 组 × 10 用例 = 80 行全 0,`没量到该量的表面` **0 条**(`.local/r3-overlay-full.log`) |
|
||||
| 第 7 项 `surface`(26.9 新增) | 没有这条闸,抽屉整块在屏幕外也是绿的 | 80 行 `surface` 全绿:`fullyInView` 对六块 antd 抽屉全部成立(含 1440 下 `scrollY=699` 的 `lib_edit`),`onTop` 80/80;反向验证把 kit 改回 `absolute` → 430px **4 项红 / exit=1**,收紧到「完整落在视口内」之前只红 2 项 |
|
||||
| 下拉浮层(四档宽度都量) | 该翻不翻被压成 35px / 掉出屏幕 125px / 右溢 45px | 80 行里 72 行含下拉(另 8 行用例本来没有下拉),72 个样本每一条都是 `popW == trigW`、`inViewport: true`、`optClipped: false`;选项高 1440/900 桌面档 31、560/430 触摸档 36,两档各 36 个样本 |
|
||||
| 词汇表 `vocab.py` | 四条规则 | **六条规则全绿**:85 文件 · 皮肤常量 79(账 79,只降不升) |
|
||||
| 规则 5 反向验证 | 没有这条闸 | 摘掉 `ui/Input.tsx` 五个组件的 `forwardRef` → **exit=1 · 命中 4 条**,跨文件点名 `pages/Login.tsx:89 <Input ref=…>`、`pages/project/Storyboard.tsx:1460 <TextArea ref=…>`、`pages/project/AgentConsole.tsx:567`、`components/forms/SecretInput.tsx:93`;改回 → exit=0。往 `SecretInputProps` 塞一行 React 19 的 `ref?:` → **exit=1 点名 props**;改回 → exit=0 |
|
||||
| 规则 6 反向验证 | 没有这条闸 | 四例:标签之间放 `/* */` → 红;放 `// ` → 红;改成 `{/* */}` → 绿;放属性位置 → 绿 |
|
||||
| 表面自证反向验证 | 浮层用例找不到目标就兜底量 `main` | 把 `sb_shot` 的期望表面改成 `modal` → audit 立刻红并打印「期望 modal,实际 panel」、exit=1;改回 → 绿 |
|
||||
| `Select` 的 null 选项 | 4 个表面各一句 antd 告警 + 选完回显成灰色「请选择」 | 专项探针 4 个表面 **warning=0**、哨兵不外泄页面、`assets_new` 回显「不绑定」且 `kind=value`(不是 placeholder) |
|
||||
| `SecretInput` 的 ref | 页面拿到的是 antd 句柄,`.setSelectionRange()` 是 undefined | 专项探针:挂载即聚焦 `#login-user`;登录失败后 `#login-pass` 是 `INPUT`、`type=password`、`hasSetSel=True`,告警 0 |
|
||||
| `npx tsc --noEmit` / `npm run build` | — | **EXIT=0**:vite 8.3.4 · 3 176 modules · `ui` chunk 881.95 kB(gzip 278.63)· CSS 91.65 kB(gzip 17.49)· 最大页面 chunk `Storyboard` 61.59 kB(gzip 20.16) |
|
||||
| 目视 | 探针全绿时用户仍说「还是有很多问题」 | 看了 1440/900 总览与审核台、分镜检视器 + 展开的下拉、430 与 1440 的抽屉——**因此抓到 26.7 和 26.9 两条**;`430_light_ov_assets_gen.png` 改前画面里根本没有抽屉,改后完整可见 |
|
||||
|
||||
## 26.6 降级的代价:React 19 → 18 静默吞掉了什么
|
||||
|
||||
点名 18 就要付 18 的账。四处功能不是报错死的,是**不报错死的**:
|
||||
|
||||
| 死掉的功能 | 症状 | 根因 |
|
||||
|---|---|---|
|
||||
| 登录页自动聚焦用户名 | 打开页面光标不在输入框里 | `<Input ref>` 落在非 `forwardRef` 组件上 |
|
||||
| 分镜「✎ 改文案」滚到描述框 | 点了按钮,画面不动 | 同上(`TextArea`) |
|
||||
| 控制台复用指令定位光标 | 指令填进去了,光标不在末尾 | 同上,且页面拿到的是 antd 句柄不是 `<input>`(`.setSelectionRange` 是 `undefined`) |
|
||||
| 流程条滚到当前节点 | 长流程滚不回来看见的节点 | 同上(`Steps`) |
|
||||
|
||||
再加上三件废弃 / 行为差异:`ConfigProvider` 顶层的 `autoInsertSpaceInButton` 在 antd 5.29 已废弃,
|
||||
改成 `button={{ autoInsertSpace: false }}`;`Dropdown` 的 `dropdownRender` 改名 `popupRender`;
|
||||
`findDOMNode` 弃用告警唯一来源是顶栏 `Tile` 当 `Dropdown` 触发器。React Router 6 那边
|
||||
是 16 处 future flag 警告,用 `future={{ v7_startTransition: true }}` 一处收口。
|
||||
|
||||
**为什么 tsc 看不见**(复跑读数,不是转述):同一个非 `forwardRef` 组件、同一个 `ref={r}`,
|
||||
开标签里有没有 `{...(x as any)}` 展开,结论完全不同——
|
||||
|
||||
| 写法 | tsc |
|
||||
|---|---|
|
||||
| A `<Kit value="A" ref={r} {...(Any as any)} />`(展开在 ref **后**) | **沉默** |
|
||||
| B `<Kit value="B" ref={r} />` | `error TS2322: Type '{ value: string; ref: RefObject<HTMLInputElement>; }' is not assignable to type 'IntrinsicAttributes & Props'` |
|
||||
| C `<Kit {...(Any as any)} value="C" ref={r} />`(展开在 ref **前**) | **沉默** |
|
||||
|
||||
也就是说展开的位置都影响不了结果:**一个开标签里只要有 `as any` 展开,这个元素的属性检查(含 ref 类型)被整个吞掉**。
|
||||
另一半原因是 `ref?: React.Ref<HTMLInputElement>` 写在 props 里——那是 React 19 的写法,18 的类型照过、运行时照丢。
|
||||
两处叠起来,全站最像「有类型保护」的地方恰恰最没有保护。
|
||||
现在只剩 1 处这种展开(`components/forms/SecretInput.tsx:106`),它就是踩到这件事的那一处。
|
||||
|
||||
**为什么五项像素判据看不见**:ref 丢掉不改一个像素——页面长得一模一样,只有点了才发现。
|
||||
于是把 `console` 收成第六项判据。**代价立刻显形**:告警是 DEV-only 的,量 `:4173` 构建产物时这一项恒为 0,
|
||||
所以它只在 dev server 上有效(规范 §1.3 写死了这条口径)。
|
||||
|
||||
**而 console 判据也不够**:prod 里它聋。能同时在 prod 兜住 ref 契约的只有源码级闸——这就是词汇表规则 5 存在的全部理由。
|
||||
它第一次全量跑就抓到真 bug:`antd Warning: 'value' in Select options should not be 'null'`。
|
||||
那句告警不是洁癖——`{ value: null, label: '不绑定' }` 是**正确的业务语义**(接口收 null:不绑定声线、无台词、
|
||||
未指定说话人、不使用参考图、选择音效,共 10 处),antd 把 null 当「没有值」,选中之后**回显成灰色 placeholder「请选择」**,
|
||||
用户看不出自己已经选了「不绑定」。修法在 kit:`forms/Select.tsx` 内部把 null 折成哨兵 ` | ||||