Commit 95942b28 by 胡悦

chore(agent-admin/web): 删除本地UI包并清理规范,修复测试超时

- 删除 `workspace/agent-admin/web/packages/ui` 本地UI组件源码目录,消除误用入口
- 从 `tsconfig.app.json` 移除 `packages/ui/src` 的类型检查包含配置
- 更新根目录与后台的README、前端基础文档、OpenSpec规范,明确组件来源为 `tdesign-react`、`tdesign-icons-react` 和全局业务组件包 `@gl/business-components`
- 新增独立页面页头吸顶的OpenSpec规范、设计方案与实施任务
- 修复官网Agent展示配置编辑页的测试超时问题,将逐字输入改为一次性 change 事件避免并发超时
1 parent 0b898d58
Showing 20 changed files with 259 additions and 359 deletions
...@@ -132,3 +132,4 @@ ...@@ -132,3 +132,4 @@
- 2026-06-09:用户确认后已按 TDD 实施 `standardize-independent-page-right-actions`。全局 `web-desktop-ui-standard`、`frontend-conventions.md`、`component-guidelines.md` 与项目 `admin-shell` 规范已同步为“独立页左侧只放标题/说明,右侧放 `返回` 和其他页面级操作”;已迁移 Agent 新增/编辑、岗位标签新增/编辑、渠道活码新增/编辑、官网岗位展示新增/编辑、官网 Agent 展示配置页。聚焦测试通过 `5 files / 120 passed / 2 skipped`,`npm run typecheck`、`npm run build`、全局与项目 `openspec validate standardize-independent-page-right-actions --strict` 均通过;浏览器布局验证按用户要求由用户自行完成,OpenSpec tasks 中 4.5 保持未勾选。 - 2026-06-09:用户确认后已按 TDD 实施 `standardize-independent-page-right-actions`。全局 `web-desktop-ui-standard`、`frontend-conventions.md`、`component-guidelines.md` 与项目 `admin-shell` 规范已同步为“独立页左侧只放标题/说明,右侧放 `返回` 和其他页面级操作”;已迁移 Agent 新增/编辑、岗位标签新增/编辑、渠道活码新增/编辑、官网岗位展示新增/编辑、官网 Agent 展示配置页。聚焦测试通过 `5 files / 120 passed / 2 skipped`,`npm run typecheck`、`npm run build`、全局与项目 `openspec validate standardize-independent-page-right-actions --strict` 均通过;浏览器布局验证按用户要求由用户自行完成,OpenSpec tasks 中 4.5 保持未勾选。
- 2026-06-09:已核对并归档 `refine-search-filter-single-row-responsive`。归档前确认 `SearchFilter` 实现、组件/Demo 测试和 active spec 对齐:操作按钮进入同一响应式 flex 流,顺序为 `查询`、`重置`、`展开/收起`,按布局测量判断是否超过两行,并保持自然换行。验证通过 `openspec validate refine-search-filter-single-row-responsive --strict`、`npm test -- --run src/business-components/global-business-components.test.tsx src/routes/components/ComponentsDemoPage.test.tsx`、`npm run typecheck`、`npm run build`;随后 `openspec archive refine-search-filter-single-row-responsive --yes` 生成 `openspec/changes/archive/2026-06-09-refine-search-filter-single-row-responsive/`,并将规则合入 `openspec/specs/global-search-filter/spec.md`。归档后 `openspec validate global-search-filter --strict` 通过;OpenSpec telemetry 仍有 PostHog DNS 警告但退出码为 0。 - 2026-06-09:已核对并归档 `refine-search-filter-single-row-responsive`。归档前确认 `SearchFilter` 实现、组件/Demo 测试和 active spec 对齐:操作按钮进入同一响应式 flex 流,顺序为 `查询`、`重置`、`展开/收起`,按布局测量判断是否超过两行,并保持自然换行。验证通过 `openspec validate refine-search-filter-single-row-responsive --strict`、`npm test -- --run src/business-components/global-business-components.test.tsx src/routes/components/ComponentsDemoPage.test.tsx`、`npm run typecheck`、`npm run build`;随后 `openspec archive refine-search-filter-single-row-responsive --yes` 生成 `openspec/changes/archive/2026-06-09-refine-search-filter-single-row-responsive/`,并将规则合入 `openspec/specs/global-search-filter/spec.md`。归档后 `openspec validate global-search-filter --strict` 通过;OpenSpec telemetry 仍有 PostHog DNS 警告但退出码为 0。
- 2026-06-09:用户浏览器验证通过后,已补齐并归档 `standardize-independent-page-right-actions`。项目级 change 归档到 `workspace/agent-admin/web/openspec/changes/archive/2026-06-09-standardize-independent-page-right-actions/`,并合入 `openspec/specs/admin-shell/spec.md`;全局 change 归档到 `architecture-spec/openspec/changes/archive/2026-06-09-standardize-independent-page-right-actions/`,并合入 `openspec/specs/web-desktop-ui-standard/spec.md`。归档前后验证通过:两侧 `openspec validate standardize-independent-page-right-actions --strict`、相关独立页测试 `102 passed / 2 skipped`、`npm run typecheck`、`npm run build`、归档后 `openspec validate admin-shell --strict` 与 `openspec validate web-desktop-ui-standard --strict`。OpenSpec telemetry 仍因受限网络出现 PostHog DNS 警告但退出码为 0。 - 2026-06-09:用户浏览器验证通过后,已补齐并归档 `standardize-independent-page-right-actions`。项目级 change 归档到 `workspace/agent-admin/web/openspec/changes/archive/2026-06-09-standardize-independent-page-right-actions/`,并合入 `openspec/specs/admin-shell/spec.md`;全局 change 归档到 `architecture-spec/openspec/changes/archive/2026-06-09-standardize-independent-page-right-actions/`,并合入 `openspec/specs/web-desktop-ui-standard/spec.md`。归档前后验证通过:两侧 `openspec validate standardize-independent-page-right-actions --strict`、相关独立页测试 `102 passed / 2 skipped`、`npm run typecheck`、`npm run build`、归档后 `openspec validate admin-shell --strict` 与 `openspec validate web-desktop-ui-standard --strict`。OpenSpec telemetry 仍因受限网络出现 PostHog DNS 警告但退出码为 0。
- 2026-06-09:用户确认删除旧本地 UI 包后,已实施 `remove-local-ui-package`:删除 `workspace/agent-admin/web/packages/ui`,从 `tsconfig.app.json` 移除 `packages/ui/src`,更新 README、前端地基文档和 `admin-ui-runtime-dependency` 稳定规范,当前后台基础控件来源为 `tdesign-react`/`tdesign-icons-react`,业务组合能力来源为 `@gl/business-components`。全量测试中官网 Agent 展示配置编辑页的 101 字输入用例在并发下 5s 超时,已将该用例从逐字 `user.type` 改为一次 `fireEvent.change`,保持 100 字截断和计数断言。验证通过:`npm run scan:local-ui-runtime-deps`、`npm run typecheck`、`npm test`(51 files / 633 passed / 9 skipped)、`openspec validate remove-local-ui-package --strict`;OpenSpec telemetry 仍有 PostHog DNS 警告但退出码为 0。
# Design: 修复独立页面页头吸顶错位
## 方案
独立页面继续渲染在 `BusinessAdminShell` 的内容区内。页面自身不创建新的全屏 `fixed` header,也不通过 `margin-top`、`padding-top` 或 `height: calc(100vh - xx)` 为 fixed header 手动补位。
独立页面的页头操作区使用 sticky 吸顶:
- sticky 元素位于页面内容结构顶部。
- sticky 的 `top` 相对于后台内容滚动容器,默认为 `0`。
- sticky 页头必须具备不透明背景、边框和足够 `z-index`,避免内容滚动时视觉穿透。
- 页头右侧操作区必须 `shrink-0`,避免标题过长时挤压 `返回`、`保存` 等按钮。
## 实现策略
优先收敛独立页面页头的通用 class 或组件样式,减少各页面复制 `sticky top-0` 时出现细节漂移。若短期先改页面 class,也必须保持同一套布局规则。
需要重点检查以下页面类型:
- Agent 新增/编辑页。
- 岗位标签新增/编辑页。
- 员工渠道活码新增/编辑页。
- 官网岗位展示新增/编辑页。
- 官网 Agent 展示配置页。
## 风险与处理
- 风险:sticky 元素被外层异常 `overflow`、`transform` 或额外滚动容器影响。处理:验证 sticky 参照为后台内容滚动容器,并避免在独立页根节点再创建不必要的全屏滚动。
- 风险:页头吸顶后覆盖首段内容。处理:保持页头仍占据文档流位置,不使用 fixed,因此内容自然从页头后开始。
- 风险:长标题挤压操作按钮。处理:标题区域 `min-width: 0`,操作区 `shrink-0`。
## 验证
- 运行相关单元测试或组件测试。
- 运行类型检查。
- 使用浏览器打开一个长表单独立页,滚动页面,确认页头吸顶、操作按钮可点击、内容不穿透且无双滚动条。
# Proposal: 修复独立页面页头吸顶错位
## 背景
管理后台独立新增、编辑和配置页面已经要求页头操作区在滚动时保持可见,但当前实现和规范没有明确页头吸顶必须以内容滚动容器为参照,也没有明确禁止使用 `fixed` 加手动补位。页面滚动时容易出现页头、内容卡片和全局 header 的视觉错位。
## 目标
- 独立页面页头使用 `position: sticky` 在页面内容滚动容器内吸顶。
- 独立页面页头不得使用 `position: fixed` 脱离后台 shell 布局。
- 页面内容滚动时,页头背景、边框和层级保持稳定,滚动内容不得穿透或覆盖页头。
- 保持现有页面的返回、保存、校验、请求和路由行为不变。
## 非目标
- 不调整全局后台 shell 的菜单、面包屑、用户区和退出登录行为。
- 不改变列表页滚动模型、表格分页、筛选或虚拟滚动规则。
- 不改变独立页面字段、保存 payload、权限和业务状态。
## 影响范围
- 影响项目 OpenSpec:`openspec/specs/admin-shell/spec.md`。
- 影响前端实现:独立新增、编辑、配置页面的页头吸顶样式和必要的共享样式收敛。
- 影响验证:需要覆盖至少一个长表单独立页滚动时页头吸顶且不遮挡操作按钮。
# admin-shell Delta
## MODIFIED Requirements
### Requirement: 独立页面页头操作区
岗位 Agent 管理后台 SHALL 为新增、编辑、配置等独立页面提供一致且滚动可见的页头操作区。页头左侧只展示页面标题、说明和状态摘要等页面识别信息;页头右侧 MUST 展示 `返回` 和其他页面级操作按钮。独立页面页头 MUST 使用内容滚动容器内的 sticky 吸顶实现,不得使用 `position: fixed` 脱离后台 shell 布局。
#### Scenario: 独立页面右侧集中展示操作按钮
- **WHEN** 已登录用户打开新增、编辑、配置等独立页面
- **THEN** 独立页面页头左侧展示页面标题和必要说明
- **AND** 独立页面页头左侧不展示 `返回` 入口或其他按钮
- **AND** 独立页面页头右侧展示 `返回` 入口
- **AND** 独立页面页头右侧展示 `保存` 等主操作
- **AND** 独立页面页头右侧不展示 `取消` 按钮
#### Scenario: 右侧操作区按钮排序
- **WHEN** 独立页面页头右侧同时存在 `返回`、主操作和其他页面级操作
- **THEN** `返回` 位于右侧操作区内靠左位置
- **AND** 主操作位于右侧操作区内靠右位置
- **AND** 其他次级页面级操作位于 `返回` 和主操作之间,或收敛到更多操作菜单
#### Scenario: 滚动时保持页头操作区可见
- **WHEN** 已登录用户在新增、编辑、配置等独立页面向下滚动表单内容
- **THEN** 独立页面页头操作区使用 sticky 方式保持在内容滚动容器顶部可见
- **AND** 独立页面页头不得使用 fixed 定位或依赖页面级手动补位保持可见
- **AND** `返回` 和 `保存` 等页面级操作入口保持可点击
- **AND** 滚动内容不得覆盖页头操作区
- **AND** 页头右侧操作区不得被页面标题或说明挤压到不可见
# Tasks
## 1. OpenSpec
- [x] 1.1 新增 `admin-shell` 规范 delta,明确独立页面页头必须在内容滚动容器内 sticky 吸顶。
- [x] 1.2 明确独立页面页头不得使用 fixed 和手动补位。
- [x] 1.3 运行 `openspec validate fix-independent-page-sticky-header --strict`。
## 2. 实现
- [ ] 2.1 检查独立页面页头实现,识别导致 sticky 错位的外层滚动或样式问题。
- [ ] 2.2 收敛独立页面页头吸顶样式,保持 `返回`、`保存` 等操作在右侧可见。
- [ ] 2.3 清理独立页面中与 fixed header 补位相关的样式,如 `margin-top`、`padding-top` 或不必要的 `height: calc(...)`。
## 3. 验证
- [ ] 3.1 运行相关测试。
- [ ] 3.2 运行类型检查。
- [ ] 3.3 浏览器验证长表单独立页滚动时页头吸顶、无错位、无双滚动条、按钮可点击。
## Context
`migrate-admin-ui-to-global-tdesign` 已归档,后台运行时代码的 UI 依赖边界已经收敛:基础控件直接来自 `tdesign-react`,图标来自 `tdesign-icons-react`,业务组合能力来自 `@gl/business-components`。当前剩余问题是旧目录 `workspace/agent-admin/web/packages/ui` 仍存在,且 `tsconfig.app.json` 仍 include `packages/ui/src`。
## Goals / Non-Goals
**Goals:**
- 删除旧本地 UI 包源码目录,消除新的误用入口。
- 让后台 TypeScript 配置不再纳入旧包源码。
- 更新当前协作文档和稳定规范,使当前组件来源与实际实现一致。
- 保留运行时 import 扫描门禁,防止后续重新引入旧路径。
**Non-Goals:**
- 不修改页面交互、业务逻辑、接口契约或路由结构。
- 不迁移或重构 `@gl/business-components`。
- 不批量改写历史 archive 中的迁移记录。
- 不处理 `workspace/agent-admin/single-page`。
## Decisions
1. 删除旧目录,而不是仅标记废弃。
旧目录已经不再被 `web/src` 运行时代码引用,保留源码只会让搜索、IDE 补全和人工维护继续暴露过时入口。删除目录后,误用会直接变成路径不存在,边界更清楚。
2. 保留 `check:local-ui-runtime-deps` 和 `scan:local-ui-runtime-deps`。
即使旧目录删除,扫描脚本仍能防止运行时代码重新引入 `packages/ui` 风格的路径或相对旧路径引用。该门禁成本低,且与迁移验收目标一致。
3. 当前文档只更新活跃协作口径,历史 archive 不改写。
archive 是迁移过程记录,保留旧描述有助于追溯;当前 README、基础文档和稳定 spec 才代表最新工程约束。
## Risks / Trade-offs
- 历史迁移测试或文档如果仍假设旧目录存在,删除后可能暴露陈旧断言。缓解方式:先搜索当前引用,再只更新活跃配置、文档和必要测试。
- 删除旧组件测试会减少旧组件自身的测试覆盖,但这些组件已不是当前产品运行时能力。缓解方式:当前页面、全局业务组件和 TDesign 迁移后的测试继续覆盖实际用户路径。
- 若第三方或本地脚本仍手动读取 `web/packages/ui`,删除会使脚本失败。缓解方式:用 `rg` 和现有扫描命令确认当前仓库无运行时依赖,并在最终说明中标出删除范围。
## Migration Plan
1. 删除 `workspace/agent-admin/web/packages/ui`。
2. 更新 `tsconfig.app.json`,移除 `packages/ui/src`。
3. 更新当前 README、前端基础文档和 `admin-ui-runtime-dependency` 稳定规范。
4. 运行 `npm run scan:local-ui-runtime-deps`、`npm run typecheck`、`npm test` 和 `openspec validate remove-local-ui-package --strict`。
## Open Questions
无。
## Why
后台页面已经完成 TDesign 与全局业务组件迁移,`workspace/agent-admin/web/src` 对本地 `packages/ui` 的运行时 import 为 0。继续保留 `workspace/agent-admin/web/packages/ui` 会制造误用入口,并让当前构建配置和规范仍背负旧组件包。
## What Changes
- 删除 `workspace/agent-admin/web/packages/ui` 旧本地 UI 组件源码目录。
- 从后台应用 TypeScript 配置中移除 `packages/ui/src`。
- 更新当前后台 README、前端基础文档和稳定规范,把当前组件来源明确为 `tdesign-react`、`tdesign-icons-react` 和 `@gl/business-components`。
- 保留本地 UI 运行时依赖扫描脚本,继续作为防止 `web/src` 重新引入旧路径的门禁。
- 不修改后台页面业务逻辑、路由、接口契约和 `@gl/business-components`。
## Capabilities
### New Capabilities
- 无。
### Modified Capabilities
- `admin-ui-runtime-dependency`: 将旧本地 UI 包的策略从“迁移后暂时保留”调整为“清理删除,并从当前类型检查范围移除”。
## Impact
- 受影响目录:`workspace/agent-admin/web/packages/ui`。
- 受影响配置:`workspace/agent-admin/web/tsconfig.app.json`。
- 受影响文档:`workspace/agent-admin/web/README.md`、`workspace/agent-admin/web/docs/frontend-foundation.md`、`workspace/agent-admin/web/openspec/specs/admin-ui-runtime-dependency/spec.md`。
- 不影响后端 API、页面行为、根目录 `packages/business-components` 和历史 OpenSpec archive。
## MODIFIED Requirements
### Requirement: 后台运行时代码不再依赖本地 UI 包
系统 MUST 让 `workspace/agent-admin/web/src` 中的运行时代码不再从 `workspace/agent-admin/web/packages/ui` 或其子路径引入组件、类型或工具,并且后台应用类型检查范围 MUST 不再纳入旧本地 UI 包源码目录。
#### Scenario: 扫描后台运行时 import
- **WHEN** 对 `workspace/agent-admin/web/src` 执行本地 UI 包依赖扫描
- **THEN** 扫描结果不包含指向 `packages/ui` 或 `packages/ui/src` 的运行时 import
#### Scenario: 类型检查不纳入旧本地 UI 包
- **WHEN** 查看 `workspace/agent-admin/web/tsconfig.app.json`
- **THEN** `include` 不包含 `packages/ui/src`
## REMOVED Requirements
### Requirement: 旧本地 UI 包目录暂时保留
系统 MUST 在本轮迁移中保留 `workspace/agent-admin/web/packages/ui` 目录,不把旧源码删除作为零运行时依赖验收条件。
#### Scenario: 完成运行时依赖迁移
- **WHEN** `workspace/agent-admin/web/src` 已达到零本地 UI 包运行时依赖
- **THEN** `workspace/agent-admin/web/packages/ui` 目录仍可保留,等待后续独立清理
## ADDED Requirements
### Requirement: 旧本地 UI 包源码已删除
系统 MUST 删除 `workspace/agent-admin/web/packages/ui` 遗留源码目录,并且当前后台协作文档 MUST 不再把该目录描述为当前组件入口或保留目标。
#### Scenario: 旧本地 UI 包目录不存在
- **WHEN** 检查 `workspace/agent-admin/web/packages/ui`
- **THEN** 该路径不存在
#### Scenario: 当前文档说明新的组件来源
- **WHEN** 查看当前后台 README 和前端基础文档
- **THEN** 文档将基础控件来源描述为 `tdesign-react` / `tdesign-icons-react`
- **AND** 文档将业务组合组件来源描述为 `@gl/business-components`
- **AND** 文档不要求保留 `workspace/agent-admin/web/packages/ui`
## 1. 建立清理基线
- [x] 1.1 扫描 `workspace/agent-admin/web/src`,确认当前运行时代码对 `packages/ui` 为 0 import
- [x] 1.2 搜索当前配置、文档和测试中仍引用 `workspace/agent-admin/web/packages/ui` 或 `packages/ui/src` 的位置
## 2. 清理旧本地 UI 包
- [x] 2.1 删除 `workspace/agent-admin/web/packages/ui` 旧源码目录
- [x] 2.2 从 `workspace/agent-admin/web/tsconfig.app.json` 移除 `packages/ui/src`
- [x] 2.3 更新当前后台 README 和前端基础文档的组件来源说明
- [x] 2.4 更新 `admin-ui-runtime-dependency` 稳定规范,移除“旧本地 UI 包目录暂时保留”要求
## 3. 验证
- [x] 3.1 运行 `npm run scan:local-ui-runtime-deps`
- [x] 3.2 运行 `npm run typecheck`
- [x] 3.3 运行 `npm test`
- [x] 3.4 运行 `openspec validate remove-local-ui-package --strict`
# admin-ui-runtime-dependency Specification # admin-ui-runtime-dependency Specification
## Purpose ## Purpose
TBD - created by archiving change migrate-admin-ui-to-global-tdesign. Update Purpose after archive. 约束后台运行时代码的 UI 依赖边界:基础控件直接来自 TDesign,跨页面业务组合能力来自全局业务组件包,旧本地 UI 包不再作为当前源码入口保留。
## Requirements ## Requirements
### Requirement: 后台运行时代码不再依赖本地 UI 包 ### Requirement: 后台运行时代码不再依赖本地 UI 包
系统 MUST 让 `workspace/agent-admin/web/src` 中的运行时代码不再从 `workspace/agent-admin/web/packages/ui` 或其子路径引入组件、类型或工具。 系统 MUST 让 `workspace/agent-admin/web/src` 中的运行时代码不再从 `workspace/agent-admin/web/packages/ui` 或其子路径引入组件、类型或工具,并且后台应用类型检查范围 MUST 不再纳入旧本地 UI 包源码目录。
#### Scenario: 扫描后台运行时 import #### Scenario: 扫描后台运行时 import
- **WHEN** 对 `workspace/agent-admin/web/src` 执行本地 UI 包依赖扫描 - **WHEN** 对 `workspace/agent-admin/web/src` 执行本地 UI 包依赖扫描
- **THEN** 扫描结果不包含指向 `packages/ui` 或 `packages/ui/src` 的运行时 import - **THEN** 扫描结果不包含指向 `packages/ui` 或 `packages/ui/src` 的运行时 import
#### Scenario: 后台应用类型检查范围排除旧 UI 包
- **WHEN** 检查 `workspace/agent-admin/web/tsconfig.app.json`
- **THEN** `include` 不包含 `packages/ui/src`
### Requirement: 基础控件直接使用 TDesign ### Requirement: 基础控件直接使用 TDesign
后台页面、布局、Hook 和组件 Demo MUST 直接使用 `tdesign-react` 提供的基础控件,并在需要图标时直接使用 `tdesign-icons-react`。 后台页面、布局、Hook 和组件 Demo MUST 直接使用 `tdesign-react` 提供的基础控件,并在需要图标时直接使用 `tdesign-icons-react`。
...@@ -64,12 +68,18 @@ TBD - created by archiving change migrate-admin-ui-to-global-tdesign. Update Pur ...@@ -64,12 +68,18 @@ TBD - created by archiving change migrate-admin-ui-to-global-tdesign. Update Pur
- **THEN** 页面可展示并交互使用 TDesign 基础组件和全局业务组件 - **THEN** 页面可展示并交互使用 TDesign 基础组件和全局业务组件
- **AND** 页面不依赖旧本地 UI 包 - **AND** 页面不依赖旧本地 UI 包
### Requirement: 旧本地 UI 包目录暂时保留 ### Requirement: 旧本地 UI 包源码已删除
系统 MUST 在本轮迁移中保留 `workspace/agent-admin/web/packages/ui` 目录,不把旧源码删除作为零运行时依赖验收条件。 系统 MUST 删除 `workspace/agent-admin/web/packages/ui` 遗留源码目录,并且当前后台协作文档 MUST 不再把该目录描述为当前组件入口或保留目标。
#### Scenario: 检查旧源码目录
- **WHEN** 检查 `workspace/agent-admin/web/packages/ui`
- **THEN** 该路径不存在
#### Scenario: 完成运行时依赖迁移 #### Scenario: 检查当前后台协作文档
- **WHEN** `workspace/agent-admin/web/src` 已达到零本地 UI 包运行时依赖 - **WHEN** 阅读当前后台 README 和前端基础文档
- **THEN** `workspace/agent-admin/web/packages/ui` 目录仍可保留,等待后续独立清理 - **THEN** 文档说明基础控件来自 `tdesign-react` 或 `tdesign-icons-react`
- **AND** 文档说明业务组合能力来自 `@gl/business-components`
- **AND** 文档不要求保留 `workspace/agent-admin/web/packages/ui`
### Requirement: 本轮表单迁移保持页面级组合 ### Requirement: 本轮表单迁移保持页面级组合
系统 MUST 在本轮迁移中让编辑页直接使用 TDesign 表单能力,并且 MUST NOT 引入配置化表单渲染器或把复杂表单逻辑改写为配置协议。 系统 MUST 在本轮迁移中让编辑页直接使用 TDesign 表单能力,并且 MUST NOT 引入配置化表单渲染器或把复杂表单逻辑改写为配置协议。
...@@ -83,4 +93,3 @@ TBD - created by archiving change migrate-admin-ui-to-global-tdesign. Update Pur ...@@ -83,4 +93,3 @@ TBD - created by archiving change migrate-admin-ui-to-global-tdesign. Update Pur
- **WHEN** 编辑页包含上传、媒体墙、动态数组、多层级联动、复杂业务选择器或步骤表单 - **WHEN** 编辑页包含上传、媒体墙、动态数组、多层级联动、复杂业务选择器或步骤表单
- **THEN** 本轮继续使用页面级组合 - **THEN** 本轮继续使用页面级组合
- **AND** 系统不为这些内容扩展新的配置协议 - **AND** 系统不为这些内容扩展新的配置协议
.root {
display: grid;
width: 100%;
gap: var(--gl-spacing-md);
}
.fieldWidth {
width: 100%;
}
.fieldWidth[data-width='360'] {
max-width: 360px;
}
.fieldWidth[data-width='420'] {
max-width: 420px;
}
.fieldWidth[data-width='450'] {
max-width: 450px;
}
.fieldWidth[data-width] {
box-sizing: border-box;
}
.count {
color: var(--gl-color-text-secondary);
font-size: var(--gl-font-size-xs);
line-height: 18px;
}
.displayText {
min-height: var(--gl-control-height-md);
padding-top: 2px;
color: var(--gl-color-text-primary);
font-size: var(--gl-font-size-sm);
line-height: var(--gl-line-height-md);
}
.readonlyPill {
display: inline-flex;
min-height: var(--gl-control-height-md);
align-items: center;
padding: 0 var(--gl-spacing-sm);
border: 1px solid var(--gl-color-border-secondary);
border-radius: var(--gl-radius-sm);
background: var(--gl-color-bg-container);
color: var(--gl-color-text-primary);
}
.uploadBox {
display: grid;
gap: var(--gl-spacing-sm);
}
.uploadPreview {
display: grid;
gap: var(--gl-spacing-xs);
padding: var(--gl-spacing-sm);
border: 1px solid var(--gl-color-border-secondary);
border-radius: var(--gl-radius-sm);
background: var(--gl-color-bg-container);
}
.uploadMedia {
display: block;
width: 100%;
max-width: 320px;
max-height: 220px;
border-radius: 8px;
object-fit: cover;
}
.uploadVideo {
width: 100%;
max-width: 320px;
max-height: 220px;
border-radius: 8px;
background: #000;
}
.uploadName {
color: var(--gl-color-text-primary);
font-size: var(--gl-font-size-sm);
line-height: var(--gl-line-height-md);
word-break: break-all;
}
.uploadMeta {
color: var(--gl-color-text-secondary);
font-size: var(--gl-font-size-xs);
line-height: 18px;
}
.uploadActions {
display: flex;
flex-wrap: wrap;
gap: var(--gl-spacing-sm);
}
.uploadButton {
display: inline-flex;
min-height: var(--gl-control-height-md);
align-items: center;
justify-content: center;
padding: 0 var(--gl-spacing-md);
border: 1px solid var(--gl-color-border-primary);
border-radius: var(--gl-radius-sm);
background: var(--gl-color-bg-container);
color: var(--gl-color-text-primary);
cursor: pointer;
}
.uploadButton:disabled {
cursor: not-allowed;
opacity: 0.6;
}
.hiddenInput {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
clip-path: inset(50%);
white-space: nowrap;
}
.root {
display: grid;
gap: var(--gl-spacing-md);
}
.viewport {
overflow: hidden;
transition: max-height 240ms ease;
will-change: max-height;
}
.fields {
display: flex;
flex-wrap: wrap;
gap: var(--gl-spacing-md) var(--gl-spacing-lg);
align-items: flex-start;
}
.item {
box-sizing: border-box;
display: flex;
align-items: center;
gap: var(--gl-spacing-sm);
width: var(--gl-search-item-width, 284px);
min-width: 0;
}
.itemWide {
width: var(--gl-search-item-wide-width, 484px);
}
.label {
flex: 0 0 var(--gl-search-label-width, 72px);
min-width: 0;
overflow: hidden;
color: var(--gl-color-text-secondary);
text-align: right;
text-overflow: ellipsis;
white-space: nowrap;
font-size: var(--gl-font-size-sm);
line-height: var(--gl-line-height-md);
}
.control {
flex: 0 0 auto;
width: var(--gl-search-control-width, 200px);
min-width: 0;
}
.controlWide {
width: var(--gl-search-control-wide-width, 400px);
}
.footer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: var(--gl-spacing-sm);
}
.toggleButton {
display: inline-flex;
align-items: center;
gap: var(--gl-spacing-xs);
}
.toggleIcon {
transition: transform 240ms ease;
}
.toggleIconExpanded {
transform: rotate(180deg);
}
.searchButton,
.resetButton {
min-width: 88px;
}
import { fireEvent, render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { SearchFilter } from '../index';
describe('SearchFilter', () => {
it('renders default select all option and keeps number inputs digits only', () => {
const onSearch = vi.fn();
render(
<SearchFilter
fields={[
{ key: 'keyword', label: '关键词', type: 'input', defaultValue: '合同' },
{ key: 'count', label: '数量', type: 'numberInput' },
{
key: 'status',
label: '状态',
type: 'select',
options: [{ label: '启用', value: 'enabled' }],
},
]}
onSearch={onSearch}
/>,
);
fireEvent.change(screen.getByLabelText('数量'), { target: { value: '12a3' } });
fireEvent.click(screen.getByRole('button', { name: '搜索' }));
expect(screen.getByLabelText('数量')).toHaveValue('123');
expect(onSearch).toHaveBeenCalledWith({
keyword: '合同',
count: '123',
status: '',
});
});
it('uses default placeholders for input and number input while preserving explicit placeholders', () => {
render(
<SearchFilter
fields={[
{ key: 'keyword', label: '项目名称', type: 'input' },
{ key: 'code', label: '项目编号', type: 'numberInput' },
{ key: 'owner', label: '负责人', type: 'input', placeholder: '搜索负责人姓名' },
]}
/>,
);
expect(screen.getByLabelText('项目名称')).toHaveAttribute('placeholder', '搜索项目名称');
expect(screen.getByLabelText('项目编号')).toHaveAttribute('placeholder', '请输入数字');
expect(screen.getByLabelText('负责人')).toHaveAttribute('placeholder', '搜索负责人姓名');
});
it('shows expand and collapse controls when the configured fields exceed one visible row', () => {
render(
<SearchFilter
fields={[
{ key: 'keyword', label: '关键词', type: 'input' },
{ key: 'code', label: '编号', type: 'numberInput' },
{
key: 'status',
label: '状态',
type: 'select',
options: [{ label: '启用', value: 'enabled' }],
},
{ key: 'owner', label: '负责人', type: 'input' },
{ key: 'createdAt', label: '创建日期', type: 'datePicker' },
{ key: 'period', label: '时间范围', type: 'datePicker', range: true },
]}
/>,
);
expect(screen.getByRole('button', { name: '展开' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '搜索' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '重置' })).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '展开' }));
expect(screen.getByRole('button', { name: '收起' })).toBeInTheDocument();
});
it('resets field values and calls the reset callback', () => {
const onReset = vi.fn();
render(
<SearchFilter
fields={[
{ key: 'keyword', label: '关键词', type: 'input', defaultValue: '项目' },
{
key: 'status',
label: '状态',
type: 'select',
options: [{ label: '启用', value: 'enabled' }],
defaultValue: 'enabled',
},
]}
onReset={onReset}
/>,
);
fireEvent.change(screen.getByLabelText('关键词'), { target: { value: '合同' } });
fireEvent.click(screen.getByRole('button', { name: '重置' }));
expect(onReset).toHaveBeenCalledTimes(1);
expect(screen.getByLabelText('关键词')).toHaveValue('项目');
});
});
export type { ButtonProps } from './components/Button';
export { Button } from './components/Button';
export type { ColorInputProps, ColorPickerProps } from './components/Color';
export { ColorInput, ColorPicker } from './components/Color';
export type { CheckboxProps } from './components/Checkbox';
export { Checkbox } from './components/Checkbox';
export type { DatePickerProps, DateRangePickerProps } from './components/DatePicker';
export { DatePicker, DateRangePicker } from './components/DatePicker';
export type { AvatarProps, AvatarGroupProps, BadgeProps, CardProps, ProgressProps, StatisticProps, TagProps, TimelineItem } from './components/Display';
export { Avatar, AvatarGroup, Badge, Card, Progress, Statistic, Tag, Timeline } from './components/Display';
export type { AlertProps, DrawerProps, MessageItem, MessageProps, ModalProps, PopconfirmProps, TooltipProps } from './components/Feedback';
export { Alert, Drawer, Message, Modal, Popconfirm, Tooltip } from './components/Feedback';
export type { FormItemProps, FormProps, FormRule, FormValues } from './components/FormItem';
export { Form, FormItem } from './components/FormItem';
export type { InputProps, SearchInputProps } from './components/Input';
export { Input, SearchInput } from './components/Input';
export type { TextareaProps } from './components/Textarea';
export { Textarea } from './components/Textarea';
export type { CollapseItem, CollapseProps, EmptyProps, NavigationItem, NavigationProps, StatePlaceholderProps, StepsProps, TabsItem, TabsProps } from './components/Navigation';
export { Collapse, Empty, Navigation, Skeleton, SkeletonAvatar, SkeletonButton, SkeletonInput, SkeletonParagraph, StatePlaceholder, Steps, Tabs } from './components/Navigation';
export type { PaginationProps } from './components/Pagination';
export { Pagination } from './components/Pagination';
export type { RadioProps } from './components/Radio';
export { Radio } from './components/Radio';
export type { SelectOption, SelectProps } from './components/Select';
export { Select } from './components/Select';
export type { SearchFilterDateField, SearchFilterField, SearchFilterInputField, SearchFilterNumberInputField, SearchFilterProps, SearchFilterSelectField, SearchFilterValue, SearchFilterValues } from './components/SearchFilter';
export { SearchFilter } from './components/SearchFilter';
export type { SwitchProps } from './components/Switch';
export { Switch } from './components/Switch';
export type { TableColumn, TableProps } from './components/Table';
export { Table } from './components/Table';
export type { TreeSelectNode, TreeSelectProps } from './components/TreeSelect';
export { TreeSelect } from './components/TreeSelect';
export type { MediaWallItem, MediaWallProps, UploadDraggerProps, UploadFileItem, UploadFileStatus } from './components/Upload';
export { MediaWall, UploadDragger } from './components/Upload';
...@@ -395,7 +395,7 @@ describe('Agent display config edit modal', () => { ...@@ -395,7 +395,7 @@ describe('Agent display config edit modal', () => {
const longContent = '测'.repeat(101); const longContent = '测'.repeat(101);
await user.clear(contentInput); await user.clear(contentInput);
await user.type(contentInput, longContent); fireEvent.change(contentInput, { target: { value: longContent } });
expect(contentInput).toHaveValue('测'.repeat(100)); expect(contentInput).toHaveValue('测'.repeat(100));
expect(within(modal).getByText('100/100')).toBeInTheDocument(); expect(within(modal).getByText('100/100')).toBeInTheDocument();
await user.click(within(modal).getByRole('button', { name: '确定' })); await user.click(within(modal).getByRole('button', { name: '确定' }));
......
...@@ -28,5 +28,5 @@ ...@@ -28,5 +28,5 @@
"jsx": "react-jsx", "jsx": "react-jsx",
"types": ["vitest/globals", "@testing-library/jest-dom"] "types": ["vitest/globals", "@testing-library/jest-dom"]
}, },
"include": ["src", "packages/ui/src", "packages/contracts", "../../../packages/business-components/src"] "include": ["src", "packages/contracts", "../../../packages/business-components/src"]
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!