feat: 建立组件化模板预览基线并规划可视化编辑

This commit is contained in:
que01 committed 2026-10-09 12:32:24 +08:00
1 parent c5af790554
commit 0b14b5a814
46 files changed
+1880 -427

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
// 模板 CSS 使用 Taro 的 750 设计宽度,转换到预览容器单位。
export function templatePreviewCss() {
return {
postcssPlugin: "template-preview-css",
Once(root) {
const file = root.source?.input.file || "";
if (!file.includes("/packages/template-") || !file.endsWith("/taro/style.css")) return;
root.walkRules((rule) => {
rule.selector = rule.selector
.split(",")
.map(
(selector) =>
".component-template-preview__canvas " +
selector
.trim()
.replace(
/(^|[ >+~])(image|text|view)(?=[ .#:[>+~)]|$)/g,
(_, prefix, tag) => prefix + { image: "img", text: "span", view: "div" }[tag],
),
)
.join(", ");
});
root.walkDecls((declaration) => {
declaration.value = declaration.value.replace(
/(-?(?:[0-9]*[.])?[0-9]+)px/g,
(_, value) => Number((Number(value) / 7.5).toFixed(8)) + "cqw",
);
});
},
};
}