feat: 完善模板驱动的品牌内容工作台

This commit is contained in:
que01 committed 2026-09-25 05:21:42 +08:00
1 parent 77224ea51f
commit dd55af8d73
46 files changed
+2204 -295

No files matched your search

@@ -0,0 +1,58 @@
import assert from "node:assert/strict";
import {
applyPresentationValues,
presentationFieldName,
readPresentationValue,
} from "../src/features/brand/presentation-bindings.ts";
const config = {
founder: "阿成",
visualPresentation: {
home: { worksTitle: "原标题", preserveMe: "保留" },
inquiry: { subtitle: "原说明" },
},
unrelatedSetting: true,
};
const sections = [
{
key: "home",
fields: [
{ key: "founder", binding: "brand.config.founder" },
{ key: "worksTitle", binding: "brand.config.visualPresentation.home.worksTitle" },
],
},
];
const next = applyPresentationValues(config, sections, {
[presentationFieldName("home", "founder")]: "阿成主理人",
[presentationFieldName("home", "worksTitle")]: "今日套餐",
});
assert.equal(readPresentationValue(next, "brand.config.founder"), "阿成主理人");
assert.equal(
readPresentationValue(next, "brand.config.visualPresentation.home.worksTitle"),
"今日套餐",
);
assert.equal(next.visualPresentation.home.preserveMe, "保留");
assert.equal(next.visualPresentation.inquiry.subtitle, "原说明");
assert.equal(next.unrelatedSetting, true);
assert.equal(config.founder, "阿成");
const unsafe = applyPresentationValues(
{ founder: "原主理人" },
[
{
key: "unsafe",
fields: [
{ key: "tenant", binding: "brand.id" },
{ key: "prototype", binding: "brand.config.__proto__.polluted" },
],
},
],
{
[presentationFieldName("unsafe", "tenant")]: "other-brand",
[presentationFieldName("unsafe", "prototype")]: "yes",
},
);
assert.deepEqual(unsafe, { founder: "原主理人" });
assert.equal({}.polluted, undefined);