Skip to content

refactor(ui): 抽取 P0 统一前端基础组件并完成首批页面试点 - #2110

Open
ClozyA wants to merge 1 commit into
devfrom
feat/ui-p0-foundation
Open

ClozyA wants to merge 1 commit into
devfrom
feat/ui-p0-foundation

Conversation

@ClozyA

@ClozyA ClozyA commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

摘要

  • 抽取并统一 P0 前端基础 UI 组件与确认弹窗服务(@/components/ui、@/composables/useConfirm),收口弹窗尺寸/标题栏避让/提交锁定/未保存关闭确认、页面表面自定义背景适配与加载/错误/空态展示。
  • 完成 6 个代表性组件与页面的首批试点迁移(UniversalPlanCreateDialog、AppearanceDescriptionModal、SettingsLeaveModal、QueueDeleteButton、history/index.vue、BAAHScriptEdit.vue),验证既有业务无破坏兼容。
  • 将 P0 统一组件选用表、目录归属与扩展约定写入 mas-frontend-ui 和 mas-frontend-standards Skills,供后续页面开发与 P1/P2 迁移直接复用。
frontend/src/
├── components/
│   ├── PageHeader.vue            # 扩展 subtitle / #title / #meta / #search
│   ├── PageSurface.vue           # 收编 .app-page-surface / .app-page-section
│   ├── NoData.vue                # 扩展 title / size 档位
│   └── ui/
│       ├── index.ts              # 统一导出入口
│       ├── AppModal.vue          # 统一弹窗基座(size/submitting/dirty/scroll/layer)
│       ├── ConfirmActionButton.vue
│       ├── AppPage.vue           # scroll / fill 页面根骨架
│       ├── SectionCard.vue       # 扩展 card / plain / sub 变体与可折叠态
│       ├── StateView.vue         # 加载 / 错误重试 / 空态 / 正文四态容器
│       └── ConfigEditShell.vue   # 配置编辑页统一外壳
├── composables/
│   ├── useConfirm.ts             # 统一确认弹窗服务(支持 Modal.useModal 上下文)
│   └── useConfirm.test.ts
└── styles/
    └── appOverlays.css           # 补充 AppModal none-scroll / full / blocking 规则

证据

静态与单测验证

  • vp lint .:0 errors,0 warnings(1124 个文件)。
  • vp fmt . --check:全部通过(1189 个文件)。
  • vue-tsc -p tsconfig.app.json --noEmit:0 errors。
  • vp test run src/composables/useConfirm.test.ts src/i18n/locales.test.ts:4/4 通过。
  • CSS 变量与暗色审计:本次改动文件 0 未定义变量,prefers-color-scheme 仅存在于 useTheme.ts。
  • Playwright 真实组件渲染核验(1280×720 与 960×480 低高度弹窗 + dirty 嵌套确认):确认 maskTop=32、modalTop=48 且弹窗与嵌套确认打开期间 32px 标题栏按钮均可点击。

Playwright 前后对比(55dacc670 -> f7667b3a9)

1. UniversalPlanCreateDialog(960×560 · 浅色)

  • 改动前:width=520px, top=48px, centered=false
  • 改动后:AppModal (size="sm"):width=480px, top=164px, centered=true, destroyOnClose, submitting 自动锁定关闭
Before (55dacc670) After (f7667b3a9)
Before UniversalPlanCreateDialog After UniversalPlanCreateDialog

2. AppearanceDescriptionModal(960×560 · 浅色)

  • 改动前:width=520px, top=48px, centered=false, 硬编码 z-index: 90
  • 改动后:AppModal (size="sm"):width=480px, top=163px, centered=true, 统一 z-index: 1000
Before (55dacc670) After (f7667b3a9)
Before AppearanceDescriptionModal After AppearanceDescriptionModal

3. QueueDeleteButton 高危确认(960×560 · 浅色)

  • 改动前:页面手写 Modal.useModal().confirm(),无统一 app-confirm-modal 类与按钮防重入
  • 改动后:ConfirmActionButton (risk="high") + useConfirm(modal),统一描边警告图标与异步防重入 loading
Before (55dacc670) After (f7667b3a9)
Before QueueDeleteButton After QueueDeleteButton
其余 4 组等价重构对比截图(SettingsLeaveModal / history / PageSurface / BAAHScriptEdit)

4. SettingsLeaveModal(960×560 · 深色,等价收敛至 AppModal)

Before (55dacc670) After (f7667b3a9)
Before SettingsLeaveModal After SettingsLeaveModal

5. history/index.vue(1280×720 · 自定义背景,AppPage + PageHeader + StateView,减少 52 行)

Before (55dacc670) After (f7667b3a9)
Before history After history

6. PageHeader + PageSurface(1280×720 · 自定义背景,收编 .app-page-surface 统一阴影/间距 Token)

Before (55dacc670) After (f7667b3a9)
Before PageSurface After PageSurface

7. BAAHScriptEdit.vue(1280×800 · 浅色,ConfigEditShell + SectionCard plain)

Before (55dacc670) After (f7667b3a9)
Before BAAHScriptEdit After BAAHScriptEdit

合并风险

Door: 双向门

仅新增共享 UI 基座与少量页面试点替换,现有 PageHeader / PageSurface / NoData / SectionCard 保持向下兼容。

Blast Radius: 中

除新建的 @/components/ui 原语外,触及 PageHeader、PageSurface、NoData、SectionCard 及 6 个试点视图;未改动后端接口、配置 schema 或既有遥测归属。

@ClozyA ClozyA added the skip-changelog 本 PR 没有用户可见改动,不需要 changelog.d 碎片 label Nov 22, 2026

Copy link
Copy Markdown
Contributor

总体结论:修改后合并

f7667b3 先用几个现有页面试统一组件,这个范围合适。dot酱会先拦一下新弹窗的关闭保护,免得后面每个编辑页都要自己补救。

[P2] 「放弃未保存更改」的确认回来时,还得看看弹窗是不是原来那个。 AppModal 在弹确认之前检查是否正在提交;等用户点完才回来时,却会直接关窗。等确认期间如果父组件开始保存,或者关闭后打开了另一份编辑,旧确认仍可能把正在保存的窗、甚至另一份编辑关掉。连续触发关闭也没有共用同一次确认。

建议每次打开只允许一个待决确认,确认回来后核对还是同一次打开、并且没在提交,再关窗。首批迁移的弹窗还没用 dirty,这不是在说试点页面已经丢了数据;但在把组件当作大家的默认入口前,值得把“旧确认不能关新窗口”补成一条组件回归。

不替新窗口按关闭的 dot酱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog 本 PR 没有用户可见改动,不需要 changelog.d 碎片

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants