refactor: 拆分模板配置契约与注册逻辑

This commit is contained in:
que01 committed 2026-10-12 03:26:43 +08:00
1 parent 7e1dd543fb
commit d0902d6568
12 files changed
+1025 -945

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
import type { BrandTemplateKey } from "./template-keys.js";
import type { VisualTemplateKey } from "./template-keys.js";
import type { VisualTemplateDefinition } from "./brand-contracts.js";
export const visualTemplates: Record<VisualTemplateKey, VisualTemplateDefinition> = {
"linjing-editorial": {
key: "linjing-editorial",
version: "1.0.0",
name: "林境建筑画册",
description: "适合高端定制、建筑作品和项目型个人品牌。",
supportedIndustryTemplates: ["personal", "doors"],
variants: { hero: "architectural", offeringList: "editorial", detail: "project-case" },
theme: {
colors: { background: "#F7F5F1", foreground: "#252525", accent: "#8A6846", dark: "#202221" },
radius: { card: "16rpx" },
},
layout: {
home: ["founder-card", "brand-hero", "trust-proof", "trust-manifesto", "offering-list"],
offerings: ["offering-list"],
detail: ["offering-detail"],
profile: ["profile"],
},
},
"acheng-campus-food": {
key: "acheng-campus-food",
version: "1.0.0",
name: "阿成校园餐",
description: "适合校园餐饮、套餐预订和团体定制的暖橙菜单视觉。",
supportedIndustryTemplates: ["food"],
variants: { hero: "stall-board", offeringList: "menu-card", detail: "dish-detail" },
theme: {
colors: { background: "#FFF8F0", foreground: "#29231F", accent: "#E87532", dark: "#3B2118" },
radius: { card: "24rpx" },
},
layout: {
home: ["founder-card", "brand-hero", "trust-proof", "offering-list"],
offerings: ["offering-list"],
detail: ["offering-detail"],
profile: ["profile"],
},
},
};
export function listVisualTemplateKeys(): VisualTemplateKey[] {
return Object.keys(visualTemplates) as VisualTemplateKey[];
}
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
return visualTemplates[key as VisualTemplateKey];
}
export function getDefaultVisualTemplateKey(industryTemplateKey: string): VisualTemplateKey {
return (
listVisualTemplateKeys().find((key) =>
visualTemplates[key].supportedIndustryTemplates.includes(
industryTemplateKey as BrandTemplateKey,
),
) ?? "linjing-editorial"
);
}