feat: 完善后台可视化模板编辑与区域绑定

This commit is contained in:
que01 committed 2026-10-09 14:26:05 +08:00
1 parent 0b14b5a814
commit 5b85fe769f
18 files changed
+1620 -239

No files matched your search

@@ -2,10 +2,12 @@ import assert from "node:assert/strict";
import {
applyPresentationValues,
applyBrandPreviewValues,
applyStandardEntityValues,
filterSectionsForPreviewTarget,
presentationFieldName,
readPresentationValue,
} from "../src/features/brand/presentation-bindings.ts";
import { resolvePreviewSelection } from "../src/features/brand/preview-selection.ts";
const config = {
founder: "阿成",
@@ -148,3 +150,40 @@ const brandDraft = applyBrandPreviewValues(
assert.equal(brandDraft.description, "新简介");
assert.equal(brandDraft.address, "新地址");
assert.equal(brandDraft.config.visualPresentation.home.title, "新标题");
const entitySection = [
{
key: "card",
fields: [
{ key: "name", binding: "offering.name" },
{ key: "summary", binding: "offering.summary" },
{ key: "category", binding: "offering.config.categoryLabel" },
],
},
];
const updatedEntity = applyStandardEntityValues(
{ id: "one", name: "旧名称", summary: "旧简介", config: { categoryLabel: "分类" } },
"offering",
entitySection,
{ "card:name": "新名称", "card:summary": "新简介", "card:category": "新分类" },
);
assert.equal(updatedEntity.name, "新名称");
assert.equal(updatedEntity.summary, "新简介");
assert.equal(updatedEntity.id, "one");
assert.deepEqual(updatedEntity.config, { categoryLabel: "分类" });
assert.equal(readPresentationValue({}, "offering.name", undefined, updatedEntity), "新名称");
const targets = [
{ key: "brand.hero", label: "主视觉", source: "brand", page: "home" },
{ key: "offering.card", label: "餐品", source: "offering", page: "offerings" },
];
assert.deepEqual(resolvePreviewSelection("brand.hero", undefined, targets, "home"), {
targetKey: "brand.hero",
});
assert.deepEqual(resolvePreviewSelection("offering.card", "one", targets, "offerings"), {
targetKey: "offering.card",
recordId: "one",
});
assert.equal(resolvePreviewSelection("offering.card", undefined, targets, "offerings"), undefined);
assert.equal(resolvePreviewSelection("brand.hero", "one", targets, "home"), undefined);
assert.equal(resolvePreviewSelection("brand.hero", undefined, targets, "offerings"), undefined);