Skip to content

UI 协议设计缺陷与重复规范合并修正提案 #805

@hotlong

Description

@hotlong

问题概述

在全面审查了 packages/spec/src/ui 目录下的主要 UI 协议(包括 page、component、dashboard、theme、widget、action、animation 等 19 个核心 schema 文件)后,发现存在命名冲突、概念重复、部分 schema 设计不一致、条件校验缺失及部分通用 schema 存放位置不合理的问题,具体如下:


2. DashboardWidget 无唯一 id,导致 targetWidgets 无法引用

  • DashboardWidgetSchema 添加必选 idname 字段(建议使用 SnakeCaseIdentifierSchema)。
  • 相关全局过滤器等 schema 引用需联动修改。

3. Action/WidgetActionType/ActionSchema.type 重复并不一致

  • 统一所有 action 类型来源,dashboard、view、component 相关 action 类型都应引用 ActionSchema。
  • WidgetActionType 增加缺失的 scriptapi 类型,或直接完全复用 ActionSchema.type。
  • 把 dashboard header action 等 schema 的结构调整为 ActionRef + inline。

5. PageType 设计与条件校验

  • PageTypeSchema 枚举类型过多,部分 type 与 ListView 类型重叠。
  • 建议用 discriminatedUnion 或 .superRefine 实现 PageSchema 的类型/字段依赖条件校验(如 record_review 类型下 recordReview 必填等)。

6. Animation 设计重复、命名不统一

  • theme.zod 与 animation.zod 分别定义动画 token 与运行时配置,easing 命名风格不一致(camelCase 与 snake_case)。
  • 统一 easing 命名风格为 snake_case。
  • animation.zod 支持使用 theme token。

7. 各 schema 的 responsive/performance 配置统一化

  • ListView、Component、Dashboard 等应支持统一的 ResponsiveConfigSchema,确保 UI 适配逻辑一致。

8. 共享协议放置位置

  • HttpMethodSchema、HttpRequestSchema 等协议建议迁移到 shared/data 模块,避免耦合 view 层定义。

9. 其他一致性/命名问题

  • theme.zod.ts 内 type/value 命名建议统一为 ThemeModeSchema、DensityModeSchema 等,避免 TS 类型与 const 冲突。

Metadata

Metadata

Labels

No labels
No labels
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions