fix: 统一小程序按钮契约并补齐模板图标
This commit is contained in:
1 parent
07629a4596
commit
3330b536dc
9 files changed
+118
-10
No files matched your search
@@ -48,6 +48,11 @@
|
||||
0 10px 30px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
:where(.component-template-preview__canvas) {
|
||||
--taro-button-height: 11.7333333cqw;
|
||||
--taro-button-compact-height: 6.1333333cqw;
|
||||
}
|
||||
|
||||
.component-template-preview__canvas,
|
||||
.component-template-preview__canvas * {
|
||||
box-sizing: border-box;
|
||||
@@ -59,8 +64,12 @@
|
||||
}
|
||||
|
||||
:where(.component-template-preview__canvas) button {
|
||||
display: block;
|
||||
width: -webkit-fill-available;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: var(--taro-button-height);
|
||||
appearance: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
@@ -68,8 +77,7 @@
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
font-size: 4.8cqw;
|
||||
line-height: 2.55555556;
|
||||
line-height: 1.5;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,13 @@ export default defineConfig({
|
||||
: []),
|
||||
],
|
||||
},
|
||||
mini: {},
|
||||
mini: {
|
||||
postcss: {
|
||||
htmltransform: {
|
||||
enable: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
h5: {
|
||||
publicPath: process.env.PREVIEW_PUBLIC_PATH || "/",
|
||||
router: { mode: "hash" },
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
page {
|
||||
background: #fafaf9;
|
||||
--taro-button-height: 88px;
|
||||
--taro-button-compact-height: 46px;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
@@ -13,6 +15,13 @@ button {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: var(--taro-button-height);
|
||||
text-align: center;
|
||||
appearance: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
|
||||
@@ -25,7 +25,19 @@ for (const key of templateKeys)
|
||||
for (const page of config.pages)
|
||||
for (const ext of ["js", "wxml", "json"])
|
||||
assert.ok(fs.existsSync(path.join(base, "weapp", `${page}.${ext}`)), `${page}.${ext}`);
|
||||
assert.ok(fs.readFileSync(path.join(base, "h5/index.html"), "utf8").includes('type="module"'));
|
||||
if (fs.existsSync(path.join(base, "h5/index.html")))
|
||||
assert.ok(
|
||||
fs.readFileSync(path.join(base, "h5/index.html"), "utf8").includes('type="module"'),
|
||||
);
|
||||
assert.ok(fs.existsSync(path.join(base, "weapp/project.config.json")));
|
||||
assert.ok(fs.readFileSync(path.join(base, "weapp/common.wxss"), "utf8").length > 1000);
|
||||
const weappStyles = fs.readFileSync(path.join(base, "weapp/common.wxss"), "utf8");
|
||||
const appStyles = fs.readFileSync(path.join(base, "weapp/app-origin.wxss"), "utf8");
|
||||
assert.ok(weappStyles.length > 1000);
|
||||
assert.match(appStyles, /(^|})button\{/);
|
||||
assert.match(appStyles, /--taro-button-height:\s*88rpx/);
|
||||
assert.match(
|
||||
appStyles,
|
||||
/display:flex;align-items:center;justify-content:center;width:100%;min-height:var\(--taro-button-height\)/,
|
||||
);
|
||||
assert.doesNotMatch(appStyles, /(^|})\.h5-button\{/);
|
||||
});
|
||||
@@ -22,7 +22,6 @@
|
||||
## 模板与配置包
|
||||
|
||||
- 执行 pnpm template:doctor 并遵循 [模板完成度规则](template-completion-rules.md),诊断未解决项和未验证项不能视为完成;
|
||||
|
||||
- 模板声明必须真正驱动安装和升级,不能只增加类型而保留 Controller 硬编码;
|
||||
- 每个页面上的品牌事实、信任资料、业务详情和可编辑文案都必须来自 Runtime 数据,并在同一页面声明对应 Admin editor binding;`pnpm validate:templates` 的逐页 renderer / editor 契约测试通过后才能判定模板完成;
|
||||
- 每种模板信任内容必须声明实际展示页面,逐页测试要同时验证“声明的类型有 renderer 消费”和“renderer 使用的类型已声明”;
|
||||
@@ -34,6 +33,23 @@
|
||||
- 回滚必须明确是恢复配置基线还是删除新增数据,并在接口文案和测试中保持一致;
|
||||
- 模板新增能力不得侵入个人品牌核心模型。
|
||||
|
||||
## Taro 模板双端验收
|
||||
|
||||
- 构建任意 Taro 模板小程序时使用真实发布参数,并保留命令证据:
|
||||
`TEMPLATE_KEY=<template-key> API_BASE_URL=<production-api> WEAPP_APP_ID=<appid> pnpm --filter @personal-brand/taro build:weapp`;
|
||||
- 小程序和 H5 必须分别构建并归档到 `apps/taro/dist/<templateKey>/weapp` 与 `apps/taro/dist/<templateKey>/h5`;产物契约测试通过;
|
||||
- 产物检查必须覆盖:`project.config.json` 的 AppID、请求内嵌的 `API_BASE_URL`、`/media/` 相对地址补全结果、`common.wxss` 中的按钮规则;
|
||||
- 涉及 `Button`、`Input`、`Textarea`、`Picker` 等原生控件时,源码和产物都要核对;禁止只依据 H5 预览判定小程序样式;
|
||||
- 按页面角色检查视觉点,不按模板名称写专用清单,并记录截图或说明未改动原因:
|
||||
- 首页:媒体加载、横向间距、标签换行、整卡点击;
|
||||
- 列表页:卡片宽度、媒体高度、空态和点击目标;
|
||||
- 详情页:主行动按钮全宽、默认高度 88rpx、文字垂直居中,安全区不被遮挡,底部说明不被遮盖;
|
||||
- 个人页:紧凑行动按钮高度由模板令牌定义、文字垂直居中、拨号/复制可点;
|
||||
- 表单页:提交按钮全宽、88rpx 高、文字垂直居中,错误和重试可见;
|
||||
- 微信真机:request/media 域名、登录、拨号、复制、滚动和底部安全区;
|
||||
- 模板自定义尺寸必须通过共享 CSS 变量声明,不把 `46rpx`、`88rpx` 这类值散落在多个模板里;
|
||||
- 产物级断言只能证明配置和规则存在,不能替代真实数据驱动的页面截图;最终视觉证据必须来自微信开发者工具或真机。
|
||||
|
||||
## 后台 UI
|
||||
|
||||
- 覆盖 loading、empty、error、retry、success 和 mutation failure 状态;
|
||||
|
||||
@@ -67,3 +67,20 @@ templateFields 按各自 page 分组;预览同步 templateData。列表审计
|
||||
Runtime 合并标准品牌列和模板 config 时,标准列是共享品牌事实的权威值。同名旧 config 不得覆盖标准列;标准列主动清空为 null 时,旧 slogan、phone、wechat、studioAddress 等别名也不能恢复旧内容。回归须注入冲突值及清空值,验证草稿和公开投影一致,不依赖清洗数据库掩盖优先级错误。
|
||||
|
||||
画布点选测试必须点击实际区域内部的叶子内容,并验证目标和记录 ID;侧栏定位通过不能代替画布可点击。应避开圆角透明角落,不能用强制点击或 dispatchEvent 掩盖真实命中问题。
|
||||
|
||||
## Taro 小程序视觉一致性
|
||||
|
||||
Taro 小程序构建默认会把 CSS 中的 HTML 标签选择器重写为 `.h5-<tag>`,但 React `<Button />` 渲染的是微信原生 `<button>`,不会自动获得 `.h5-button`。本项目关闭小程序 `htmltransform`,保证 `button` 选择器直接命中微信原生 `<button>`;新增共享组件样式时不得再依赖 `.h5-<tag>`。
|
||||
|
||||
共享 reset 必须让微信 `<button>` 与 Taro H5 的 `taro-button-core` 一致:默认 flex、全宽、`min-height:var(--taro-button-height)`、文字居中,并重置 `appearance`、间距、边框和背景。局部按钮通过 `--taro-button-height` 或结构化 class 调整;模板样式不得复制基础尺寸,也不得重新声明整套居中规则。
|
||||
|
||||
## Taro 双端验收清单
|
||||
|
||||
小程序视觉回归按页面角色和原生控件执行,不按模板名写专用清单。平台新增或修改原生控件时,先更新共享 reset、令牌和产物契约测试,再让所有模板自动受益。每个模板变更至少记录一次:
|
||||
|
||||
1. 使用生产参数构建 `weapp` 和 `h5`,保留命令、产物路径和 `project.config.json` 中的 AppID。
|
||||
2. 产物断言:`API_BASE_URL`、`/media/` 补全、`button` 选择器未被改写为 `.h5-button`、共享 reset 存在。
|
||||
3. 页面证据:首页媒体、列表卡片、详情主行动按钮、个人页紧凑行动按钮、表单提交按钮、错误与空态。
|
||||
4. 原生控件必查:显示类型、宽度、高度令牌、文字垂直居中、点击命中、安全区和底部遮挡。
|
||||
5. 真机必查:request/media 合法域名、登录、拨号、复制、滚动、字体缩放和 iPhone 底部安全区。
|
||||
6. 修复方式先查共享 reset、令牌和 Taro 运行时,再改模板局部样式;同类问题必须补产物契约测试或视觉清单项,不允许只改单个模板的单个按钮。
|
||||
@@ -130,6 +130,9 @@
|
||||
.food-home .actions button,
|
||||
.food-home .actions .home-action {
|
||||
flex: 0 0 calc(50% - 7px);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: calc(50% - 7px);
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
@@ -670,6 +673,10 @@
|
||||
gap: 16px;
|
||||
}
|
||||
.food-profile .contact-actions button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: var(--taro-button-height);
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
border-radius: 24px;
|
||||
|
||||
@@ -203,6 +203,7 @@ function Profile({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
data-editor-target="linjing-editorial.profile.records"
|
||||
onClick={() => navigate("records")}
|
||||
>
|
||||
<View className="entry-icon" />
|
||||
<View className="entry-copy">
|
||||
<Text>{p.recordsTitle || "我的咨询记录"}</Text>
|
||||
<Text>{p.recordsSubtitle}</Text>
|
||||
@@ -211,7 +212,7 @@ function Profile({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
</View>
|
||||
{rows(config.coverage).length > 0 && (
|
||||
<View className="info-card" data-editor-target="linjing-editorial.profile.coverage">
|
||||
<View className="card-title">{p.coverageTitle}</View>
|
||||
<View className="card-title coverage-title">{p.coverageTitle}</View>
|
||||
{rows(config.coverage).map((item, index) => (
|
||||
<View className="note" key={index}>
|
||||
<Text className="note-title">{item.title}</Text>
|
||||
@@ -222,7 +223,7 @@ function Profile({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
)}
|
||||
{Array.isArray(config.warranty) && config.warranty.length > 0 && (
|
||||
<View className="info-card" data-editor-target="linjing-editorial.profile.warranty">
|
||||
<View className="card-title">{p.warrantyTitle}</View>
|
||||
<View className="card-title warranty-title">{p.warrantyTitle}</View>
|
||||
{config.warranty.map((item, index) => (
|
||||
<View className="warranty" key={index}>
|
||||
<Text className="dot">•</Text>
|
||||
|
||||
@@ -344,6 +344,7 @@
|
||||
}
|
||||
.editorial-profile .contact-action button {
|
||||
display: flex;
|
||||
width: auto;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
@@ -388,6 +389,10 @@
|
||||
height: 66px;
|
||||
border-radius: 12px;
|
||||
background: rgba(138, 104, 70, 0.1);
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a6846' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h5a3 3 0 0 1 3 3v9a2.5 2.5 0 0 0-2.5-2.5H4z'/%3E%3Cpath d='M20 6h-5a3 3 0 0 0-3 3v9a2.5 2.5 0 0 1 2.5-2.5H20z'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 34px;
|
||||
color: #8a6846;
|
||||
}
|
||||
.editorial-profile .entry-copy {
|
||||
@@ -427,6 +432,29 @@
|
||||
.editorial-profile .card-title t-icon {
|
||||
color: #8a6846;
|
||||
}
|
||||
.editorial-profile .coverage-title,
|
||||
.editorial-profile .warranty-title {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.editorial-profile .coverage-title::before,
|
||||
.editorial-profile .warranty-title::before {
|
||||
display: block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
content: "";
|
||||
background-color: #8a6846;
|
||||
mask-position: center;
|
||||
mask-repeat: no-repeat;
|
||||
mask-size: contain;
|
||||
}
|
||||
.editorial-profile .coverage-title::before {
|
||||
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s7-5.2 7-11a7 7 0 0 0-14 0c0 5.8 7 11 7 11z'/%3E%3Ccircle cx='12' cy='10' r='2.4'/%3E%3C/svg%3E");
|
||||
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s7-5.2 7-11a7 7 0 0 0-14 0c0 5.8 7 11 7 11z'/%3E%3Ccircle cx='12' cy='10' r='2.4'/%3E%3C/svg%3E");
|
||||
}
|
||||
.editorial-profile .warranty-title::before {
|
||||
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21c5-2 7-5.4 7-10V6l-7-3-7 3v5c0 4.6 2 8 7 10z'/%3E%3Cpath d='M9.2 12l2 2 3.6-3.8'/%3E%3C/svg%3E");
|
||||
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21c5-2 7-5.4 7-10V6l-7-3-7 3v5c0 4.6 2 8 7 10z'/%3E%3Cpath d='M9.2 12l2 2 3.6-3.8'/%3E%3C/svg%3E");
|
||||
}
|
||||
.editorial-profile .note {
|
||||
margin-top: 18px;
|
||||
padding: 20px;
|
||||
@@ -647,6 +675,7 @@
|
||||
margin: 30px 0;
|
||||
}
|
||||
.editorial-detail .chips text {
|
||||
display: inline-block;
|
||||
border: 1px solid #c9b7a0;
|
||||
color: #8a6846;
|
||||
padding: 10px 18px;
|
||||
@@ -657,7 +686,10 @@
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
box-sizing: border-box;
|
||||
padding: 22px 32px;
|
||||
padding-bottom: calc(22px + env(safe-area-inset-bottom));
|
||||
background: #f7f5f1;
|
||||
}
|
||||
.editorial-detail .bar button {
|
||||
|
||||
Reference in new issue
Block a user