From 29e5666d7409a23d35bda9ac965ba1c18f40b912 Mon Sep 17 00:00:00 2001 From: que01 Date: Tue, 13 Oct 2026 23:30:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=85=B1=E4=BA=AB=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=B0=BA=E5=AF=B8=E4=BB=A4=E7=89=8C=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E4=B8=AD=E6=80=A7=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --taro-button-height / --taro-button-compact-height 是本仓库自有的共享令牌,却借用了 框架名。源码级中性命名比产物替换更彻底,也不会出现源码与产物两套名字,因此改为 --brand-button-height / --brand-button-compact-height,与既有的 brand-button 组件命名一致; 产物遮蔽仍按同一张表处理 Taro 自身的标识符。 验证:weapp 的 app-origin.wxss 输出 page{--brand-button-height:88rpx} 与 button{min-height:var(--brand-button-height)};H5 与后台产物的声明与引用同步改名; 六类产物残留指纹均为 0;H5 预览 11 项浏览器回归通过;遮蔽前后后台产物用生产静态 服务器跑同一套测试,失败内容逐字节一致;format、lint、typecheck 通过。 --- apps/admin/src/features/brand/ComponentTemplatePreview.css | 6 +++--- apps/taro/src/app.css | 6 +++--- apps/taro/test/build-contract.test.mjs | 4 ++-- apps/taro/test/mask-taro.test.mjs | 2 +- docs/adr/0025-build-output-stack-masking.md | 5 +++-- docs/template-completion-rules.md | 2 +- packages/template-acheng-campus-food/taro/style.css | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/admin/src/features/brand/ComponentTemplatePreview.css b/apps/admin/src/features/brand/ComponentTemplatePreview.css index 880a1b7..2d5fc72 100644 --- a/apps/admin/src/features/brand/ComponentTemplatePreview.css +++ b/apps/admin/src/features/brand/ComponentTemplatePreview.css @@ -49,8 +49,8 @@ } :where(.component-template-preview__canvas) { - --taro-button-height: 11.7333333cqw; - --taro-button-compact-height: 6.1333333cqw; + --brand-button-height: 11.7333333cqw; + --brand-button-compact-height: 6.1333333cqw; } .component-template-preview__canvas, @@ -68,7 +68,7 @@ align-items: center; justify-content: center; width: 100%; - min-height: var(--taro-button-height); + min-height: var(--brand-button-height); appearance: none; margin: 0; padding: 0; diff --git a/apps/taro/src/app.css b/apps/taro/src/app.css index 22bf89e..05126d3 100644 --- a/apps/taro/src/app.css +++ b/apps/taro/src/app.css @@ -1,7 +1,7 @@ page { background: #fafaf9; - --taro-button-height: 88px; - --taro-button-compact-height: 46px; + --brand-button-height: 88px; + --brand-button-compact-height: 46px; } body { margin: 0; @@ -19,7 +19,7 @@ button { align-items: center; justify-content: center; width: 100%; - min-height: var(--taro-button-height); + min-height: var(--brand-button-height); text-align: center; appearance: none; margin: 0; diff --git a/apps/taro/test/build-contract.test.mjs b/apps/taro/test/build-contract.test.mjs index 1f3fdf1..26d8a9e 100644 --- a/apps/taro/test/build-contract.test.mjs +++ b/apps/taro/test/build-contract.test.mjs @@ -35,10 +35,10 @@ for (const key of templateKeys) const appStyles = unmask(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, /--brand-button-height:\s*88rpx/); assert.match( appStyles, - /display:flex;align-items:center;justify-content:center;width:100%;min-height:var\(--taro-button-height\)/, + /display:flex;align-items:center;justify-content:center;width:100%;min-height:var\(--brand-button-height\)/, ); assert.doesNotMatch(appStyles, /(^|})\.h5-button\{/); }); diff --git a/apps/taro/test/mask-taro.test.mjs b/apps/taro/test/mask-taro.test.mjs index 557f99e..1cf1819 100644 --- a/apps/taro/test/mask-taro.test.mjs +++ b/apps/taro/test/mask-taro.test.mjs @@ -25,7 +25,7 @@ test("遮蔽表在测试与构建之间保持一致", () => { "taro_tmpl", "@tarojs/components", "taroWindowProvider", - "--taro-button-height", + "--taro-tabbar-height", ".taro-tabbar__tabbar", ]) assert.equal(masked(name), maskText(name, replacements), name); diff --git a/docs/adr/0025-build-output-stack-masking.md b/docs/adr/0025-build-output-stack-masking.md index 4f89959..db7050c 100644 --- a/docs/adr/0025-build-output-stack-masking.md +++ b/docs/adr/0025-build-output-stack-masking.md @@ -2,9 +2,9 @@ ## Context -模板预览(H5)与微信小程序产物都是外部可获取的材料:预览页面可以打开 DevTools 查看 DOM 与资源,小程序包也能从微信侧下载后反编译。Taro 的指纹在产物中大量出现且没有官方开关:`taro_tmpl`、`base.wxml`、`utils.wxs`、`comp.*`、`taro.js`、`taro-*-core` 自定义元素、`taroWindowProvider`、`taro_tabbar_page`、`--taro-button-height`、`project.config.json` 的 `projectname` 等。竞争对手据此可以判断预览与小程序都由 Taro 生成。 +模板预览(H5)与微信小程序产物都是外部可获取的材料:预览页面可以打开 DevTools 查看 DOM 与资源,小程序包也能从微信侧下载后反编译。Taro 的指纹在产物中大量出现且没有官方开关:`taro_tmpl`、`base.wxml`、`utils.wxs`、`comp.*`、`taro.js`、`taro-*-core` 自定义元素、`taroWindowProvider`、`taro_tabbar_page`、`project.config.json` 的 `projectname` 等。竞争对手据此可以判断预览与小程序都由 Taro 生成。 -后台静态站点同样对外可达:Traefik 把 `wechat.app.que01.top` 上除 `/api`、`/media` 以外的全部路径直接转发到 Admin 静态服务器,没有鉴权中间件,因此 `https://…/admin/assets/*.js` 可以直接下载。后台产物里带有模板 renderer 的 glob 路径(`packages/template-*/taro/index.tsx`)和按钮尺寸令牌(`--taro-button-height`),同样会暴露技术栈。 +后台静态站点同样对外可达:Traefik 把 `wechat.app.que01.top` 上除 `/api`、`/media` 以外的全部路径直接转发到 Admin 静态服务器,没有鉴权中间件,因此 `https://…/admin/assets/*.js` 可以直接下载。后台产物里带有模板 renderer 的 glob 路径(`packages/template-*/taro/index.tsx`),同样会暴露技术栈。 Taro 4.3 没有隐藏这些名称的配置项。名称分别硬编码在 `@tarojs/plugin-platform-weapp`、`@tarojs/vite-runner`、`@tarojs/runtime` 内部;官方 hook(`modifyBuildAssets`、`modifyMiniConfigs`、`modifyRunnerOpts`)只能改写构建产物与配置,覆盖不到运行时内部硬编码的标识符。 @@ -13,6 +13,7 @@ Taro 4.3 没有隐藏这些名称的配置项。名称分别硬编码在 `@taroj - 在 `apps/taro` 的生产构建脚本末尾增加构建后处理:`apps/taro/config/mask-taro.cjs` 读取 `apps/taro/config/mask.config.json`,对 `dist//weapp`、`dist//h5`、`dist/template-preview/h5` 做确定性改名;后台静态产物 `apps/admin/dist` 通过 `admin` 目标覆盖,接入根脚本 `build:admin:preview`。 - 同一张替换表同时作用于文件名和文本内容,因此 `taro.js` 与其引用会一起变成 `appkit.js`,`taro_tmpl` 与页面里的引用也保持同步,不需要维护两份映射。 - 只遮蔽 Taro 相关标识符;vite、rollup、rolldown 等通用打包工具的名称属于行业通用信息,不做处理。 +- 共享按钮尺寸令牌这类本仓库自有的命名不靠遮蔽处理,而是直接改成中性名:`--taro-button-height` / `--taro-button-compact-height` 改为 `--brand-button-height` / `--brand-button-compact-height`,与既有的 `brand-button` 组件命名保持一致。源码中性命名比产物替换更彻底,也不会让源码与产物出现两套名字。 - 长度 ≥ 40 的不透明串(内嵌 base64、摘要)保持原样,避免误改数据。 - 遮蔽后仍存在 `forbidden` 词表命中时构建失败(退出码 1),因此产物不会静默泄露。 - `project.config.json` 的 `projectname`、`description` 由配置中性化。 diff --git a/docs/template-completion-rules.md b/docs/template-completion-rules.md index a78fc92..90b5178 100644 --- a/docs/template-completion-rules.md +++ b/docs/template-completion-rules.md @@ -72,7 +72,7 @@ Runtime 合并标准品牌列和模板 config 时,标准列是共享品牌事 Taro 小程序构建默认会把 CSS 中的 HTML 标签选择器重写为 `.h5-`,但 React `