平台与端
组件库按两个正交轴组织:平台(pc / mobile)决定用哪些组件与命名空间;端(css / h5 原生 / react / vue2 / vue3 / uniapp)决定同一组件在哪个技术栈里怎么实现。完整文档见仓库根 PLATFORMS.md。
覆盖矩阵
| 平台 ↓ / 端 → | css | h5 原生 | react | vue2 | vue3 | uniapp |
| 移动端(47) | ✅ 47 | ✅ 47 | ✅ 47 | ✅ 47 | ✅ 47 | ✅ 47 |
| PC(103) | ✅ 103 | ✅ 103 | ✅ 103 | ✅ 103 | ✅ 103 | 3 / 103(试点) |
✅ = 该平台组件清单在此端已全覆盖;数字 = 已实现 / 总数。
uni-app 是一个端,不是第三个平台
| 列 | 实现位置 | 目标产物 | 关键约束 |
| 移动端 × uni-app |
frameworks-mobile/*.uniapp.vue(47 个) |
app-plus(App)/ mp-weixin(微信小程序)/ h5 |
uni 基础组件(view/text)+ rpx + touch 事件(小程序与 App 端没有 DOM,也没有 PointerEvent) |
| PC × uni-app |
frameworks-uniapp-pc/*.uniapp.vue(3 个试点,见 ROADMAP S7-P26) |
H5(PC 浏览器)/ PC 容器 |
类名与 PC 的 frameworks/*.css 逐字一致(btn / kole-input / kole-card),令牌取 PC 的 --kole-*,尺寸保持 px |
目录与命名映射
| 维度 | PC 端 | 移动端 | 共享 |
| 实现目录 | frameworks/(515) | frameworks-mobile/(282) | 否 |
| 契约 | .design_library/kole-ui/components/(103) | .design_library/kole-ui-mobile/components/(47) | 否 |
| 索引(唯一真源) | components/index.json | kole-ui-mobile/components/index.json | 否 |
| 类名前缀 | kole-(含既有短名 btn) | kole-m-(状态类 is-*) | 否 |
| 令牌前缀 | --kole-*(75) | --kole-m-*(15) | 颜色 / 字体 / 圆角 / 阴影同源(@import) |
| 导出名 | KoleButton | KoleMNavBar | 否 |
| 测试页 | tests/<slug>.html(103) | tests/mobile/<slug>.html(47) | 共享断言引擎 tests/_runtime.js |
| 回归报告 | tests/report.json | tests/mobile-report.json | 否 |
| 文档站 | site/(SPA 路由) | site/m/(静态页,不进 PC 路由表) | 否 |
| 自包含数据 | site/data.json | site/m/data.mobile.json | 否 |
| 分发产物 | dist/components|react|vue3|vue2 | dist/mobile/* | 否 |
| 构建脚本 | build-site.ps1 + build-dist.mjs | build-mobile.mjs + build-uniapp.mjs | 否 |
隔离规则(硬约束)
- 移动端实现只能在
frameworks-mobile/;PC 实现只能在 frameworks/。两端的文件数都有断言(395 / 282)。
- 移动端类名只能是
kole-m-<name> 或状态类 is-<state>;移动端样式不得出现硬编码十六进制颜色。
- 移动端样式只能引用
--kole-* 或 --kole-m-* 令牌,且令牌必须真实存在。
- PC 侧的目录、数据、测试、分发里不得出现任何移动端痕迹(零
kole-m- 命中、零 frameworks-mobile/ 引用)。
- 移动端构建脚本自带写入守卫:
build-mobile.mjs 只允许写 site/m/、tests/mobile/、dist/mobile/;build-uniapp.mjs 只允许写 dist/uniapp-pc/。越界直接抛错退出。
- PC 的
site/data.json(一次请求拿到全部 PC 组件)保持不变;移动端另起 site/m/data.mobile.json,两端互不引用。
门禁命令
| 命令 | 检查什么 |
npm run verify:isolation | PC 零污染 / 移动端自洽(6 端文件齐全、契约字段完整、类名与令牌前缀合规)/ 分发隔离(PC 聚合样式无移动端类、manifest 与索引一致、exports 两套并存) |
npm run verify:uniapp | 8 个 uni-app SFC:三段结构 / node --check 语法 / 标签配平 / 禁 DOM API / 手势必须 touch / 只用 uni 基础组件 / 前缀隔离 / 单位策略 |
npm run verify:mobile-docs | 本站的完整性:每个组件页的必备小节、侧栏是否列全、契约 API 是否与 6 端源码逐名一致、每个声明的端是否有代码块 |
npm run verify:mobile-site | 浏览器实测:HTTP 200 / 控制台 0 错误 / 演示帧真实渲染 / 令牌生效 / 未引 PC 站样式 / 320–768px 无横向溢出 |
npm run regression:mobile | 移动端断言回归(含触控行为断言),报告落 tests/mobile-report.json |
npm run regression | PC 侧断言回归(103 页)—— 改移动端后也必须保持 100% |
新增一个移动端组件(六步)
- 在
.design_library/kole-ui-mobile/spec/移动端规格.md 补一节:用途 / 结构 / 变体维度 / 状态 / 交互与触控 / 无障碍 / doNotInvent / unknowns —— 规格是契约的授权来源,先写规格再写代码。
- 在
.design_library/kole-ui-mobile/components/index.json 登记:slug(不得与 PC 的 103 个撞名)、frameworksPrefix、category、specSection、contract、files(6 个端的文件名必须全部声明)。
- 写 6 个端实现到
frameworks-mobile/:<Prefix>.{css,html,jsx,vue2.vue,vue3.vue,uniapp.vue}。html 是演示页,需含 .demo 容器与 data-assert / data-behavior。
- 写契约
components/<slug>.json:sourceKind: authored-spec、provenance: authored-in-repo,usageHints / anatomy / interaction / accessibility 逐字取自规格,api 与各端源码逐名一致。
npm run build:mobile 重建数据、文档站、测试页与分发包。
npm run verify:isolation && npm run verify:uniapp && npm run verify:mobile-docs && npm run regression:mobile 全绿才算完成。