refactor: 共享按钮尺寸令牌改用中性命名
--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 通过。
This commit is contained in:
1 parent
d34cb182e3
commit
29e5666d74
7 files changed
+14
-13
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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\{/);
|
||||
});
|
||||
@@ -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);
|
||||
|
||||
@@ -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/<templateKey>/weapp`、`dist/<templateKey>/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` 由配置中性化。
|
||||
|
||||
@@ -72,7 +72,7 @@ Runtime 合并标准品牌列和模板 config 时,标准列是共享品牌事
|
||||
|
||||
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 调整;模板样式不得复制基础尺寸,也不得重新声明整套居中规则。
|
||||
共享 reset 必须让微信 `<button>` 与 Taro H5 的 `taro-button-core` 一致:默认 flex、全宽、`min-height:var(--brand-button-height)`、文字居中,并重置 `appearance`、间距、边框和背景。局部按钮通过 `--brand-button-height` 或结构化 class 调整;模板样式不得复制基础尺寸,也不得重新声明整套居中规则。
|
||||
|
||||
## Taro 双端验收清单
|
||||
|
||||
|
||||
@@ -676,7 +676,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: var(--taro-button-height);
|
||||
min-height: var(--brand-button-height);
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
border-radius: 24px;
|
||||
|
||||
Reference in new issue
Block a user