From 3330b536dc622a4684b8a0eef4a5916750a16a59 Mon Sep 17 00:00:00 2001 From: que01 Date: Tue, 13 Oct 2026 11:12:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=8C=89=E9=92=AE=E5=A5=91=E7=BA=A6=E5=B9=B6=E8=A1=A5?= =?UTF-8?q?=E9=BD=90=E6=A8=A1=E6=9D=BF=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../brand/ComponentTemplatePreview.css | 16 +++++++--- apps/taro/config/index.ts | 8 ++++- apps/taro/src/app.css | 9 ++++++ apps/taro/test/build-contract.test.mjs | 16 ++++++++-- docs/engineering-delivery-checklist.md | 18 ++++++++++- docs/template-completion-rules.md | 17 ++++++++++ .../taro/style.css | 7 ++++ .../template-linjing-editorial/taro/index.tsx | 5 +-- .../template-linjing-editorial/taro/style.css | 32 +++++++++++++++++++ 9 files changed, 118 insertions(+), 10 deletions(-) diff --git a/apps/admin/src/features/brand/ComponentTemplatePreview.css b/apps/admin/src/features/brand/ComponentTemplatePreview.css index b293e17..3134f4c 100644 --- a/apps/admin/src/features/brand/ComponentTemplatePreview.css +++ b/apps/admin/src/features/brand/ComponentTemplatePreview.css @@ -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; } diff --git a/apps/taro/config/index.ts b/apps/taro/config/index.ts index c9f968b..d739061 100644 --- a/apps/taro/config/index.ts +++ b/apps/taro/config/index.ts @@ -71,7 +71,13 @@ export default defineConfig({ : []), ], }, - mini: {}, + mini: { + postcss: { + htmltransform: { + enable: false, + }, + }, + }, h5: { publicPath: process.env.PREVIEW_PUBLIC_PATH || "/", router: { mode: "hash" }, diff --git a/apps/taro/src/app.css b/apps/taro/src/app.css index bbbc7eb..22bf89e 100644 --- a/apps/taro/src/app.css +++ b/apps/taro/src/app.css @@ -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; diff --git a/apps/taro/test/build-contract.test.mjs b/apps/taro/test/build-contract.test.mjs index 6d783d6..52d09d5 100644 --- a/apps/taro/test/build-contract.test.mjs +++ b/apps/taro/test/build-contract.test.mjs @@ -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\{/); }); diff --git a/docs/engineering-delivery-checklist.md b/docs/engineering-delivery-checklist.md index 36ee845..5578466 100644 --- a/docs/engineering-delivery-checklist.md +++ b/docs/engineering-delivery-checklist.md @@ -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= API_BASE_URL= WEAPP_APP_ID= pnpm --filter @personal-brand/taro build:weapp`; +- 小程序和 H5 必须分别构建并归档到 `apps/taro/dist//weapp` 与 `apps/taro/dist//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 状态; diff --git a/docs/template-completion-rules.md b/docs/template-completion-rules.md index 50b8592..a78fc92 100644 --- a/docs/template-completion-rules.md +++ b/docs/template-completion-rules.md @@ -67,3 +67,20 @@ templateFields 按各自 page 分组;预览同步 templateData。列表审计 Runtime 合并标准品牌列和模板 config 时,标准列是共享品牌事实的权威值。同名旧 config 不得覆盖标准列;标准列主动清空为 null 时,旧 slogan、phone、wechat、studioAddress 等别名也不能恢复旧内容。回归须注入冲突值及清空值,验证草稿和公开投影一致,不依赖清洗数据库掩盖优先级错误。 画布点选测试必须点击实际区域内部的叶子内容,并验证目标和记录 ID;侧栏定位通过不能代替画布可点击。应避开圆角透明角落,不能用强制点击或 dispatchEvent 掩盖真实命中问题。 + +## Taro 小程序视觉一致性 + +Taro 小程序构建默认会把 CSS 中的 HTML 标签选择器重写为 `.h5-`,但 React `