refactor: 拆分模板配置契约与注册逻辑
This commit is contained in:
1 parent
7e1dd543fb
commit
d0902d6568
12 files changed
+1025
-945
No files matched your search
@@ -0,0 +1,282 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import type { VisualTemplateKey } from "./template-keys.js";
|
||||
import type { VisualTemplateDefinition, VisualTemplateManifest } from "./brand-contracts.js";
|
||||
|
||||
const linjingEditorialManifest: VisualTemplateManifest = {
|
||||
schemaVersion: "1.0",
|
||||
key: "linjing-editorial",
|
||||
version: "1.0.0",
|
||||
name: "林境建筑画册",
|
||||
description: "以个人品牌信任为主线、以高端项目作品为表达重点的编辑式视觉模板。",
|
||||
supportedIndustryTemplates: ["personal", "doors"],
|
||||
brandFirst: true,
|
||||
tokens: {
|
||||
colors: {
|
||||
background: "#F7F5F1",
|
||||
surface: "#FFFFFF",
|
||||
foreground: "#252525",
|
||||
muted: "#77736C",
|
||||
accent: "#8A6846",
|
||||
dark: "#202221",
|
||||
},
|
||||
spacing: { page: "32rpx", section: "56rpx", module: "24rpx" },
|
||||
typography: { display: "56rpx", heading: "36rpx", body: "28rpx", caption: "22rpx" },
|
||||
radius: { card: "16rpx", button: "999rpx", media: "12rpx" },
|
||||
shadows: { card: "0 8rpx 32rpx rgba(32,34,33,0.08)" },
|
||||
},
|
||||
assets: [
|
||||
{ key: "brand.logo", label: "品牌标志", required: false, kind: "logo" },
|
||||
{
|
||||
key: "home.hero",
|
||||
label: "首页首屏图",
|
||||
required: true,
|
||||
kind: "image",
|
||||
aspectRatio: "16:9",
|
||||
},
|
||||
{
|
||||
key: "offering.cover",
|
||||
label: "业务提供项封面",
|
||||
required: true,
|
||||
kind: "image",
|
||||
aspectRatio: "1:1",
|
||||
},
|
||||
{
|
||||
key: "profile.portrait",
|
||||
label: "主理人肖像",
|
||||
required: false,
|
||||
kind: "image",
|
||||
aspectRatio: "1:1",
|
||||
},
|
||||
{ key: "brand.texture", label: "品牌底纹", required: false, kind: "texture" },
|
||||
],
|
||||
dataSlots: [
|
||||
{
|
||||
key: "brand.identity",
|
||||
source: "brand",
|
||||
required: true,
|
||||
description: "品牌名、定位和主理人身份",
|
||||
},
|
||||
{ key: "brand.hero", source: "brand", required: true, description: "品牌首屏表达和行动入口" },
|
||||
{ key: "trust.proof", source: "trust", required: true, description: "经历、资质、案例和方法" },
|
||||
{
|
||||
key: "offerings.list",
|
||||
source: "offering",
|
||||
required: true,
|
||||
description: "可展示的业务提供项",
|
||||
},
|
||||
{
|
||||
key: "offering.detail",
|
||||
source: "offering",
|
||||
required: true,
|
||||
description: "单个提供项的详情内容",
|
||||
},
|
||||
{ key: "inquiry.form", source: "inquiry", required: true, description: "品牌咨询或预约表单" },
|
||||
{
|
||||
key: "records.items",
|
||||
source: "records",
|
||||
required: true,
|
||||
description: "用户提交后的跟进记录",
|
||||
},
|
||||
{
|
||||
key: "profile.contact",
|
||||
source: "profile",
|
||||
required: true,
|
||||
description: "联系方式和合作预期",
|
||||
},
|
||||
],
|
||||
pages: [
|
||||
{
|
||||
key: "home",
|
||||
title: "首页",
|
||||
renderer: "linjing-home",
|
||||
modules: [
|
||||
{
|
||||
key: "identity",
|
||||
type: "brand-identity",
|
||||
variant: "editorial-card",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
assetSlots: ["brand.logo"],
|
||||
},
|
||||
{
|
||||
key: "hero",
|
||||
type: "hero",
|
||||
variant: "architectural",
|
||||
required: true,
|
||||
dataSlots: ["brand.hero"],
|
||||
assetSlots: ["home.hero"],
|
||||
},
|
||||
{
|
||||
key: "proof",
|
||||
type: "trust",
|
||||
variant: "proof-strip",
|
||||
required: true,
|
||||
dataSlots: ["trust.proof"],
|
||||
},
|
||||
{
|
||||
key: "offerings",
|
||||
type: "offering-list",
|
||||
variant: "editorial-list",
|
||||
required: true,
|
||||
dataSlots: ["offerings.list"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
{
|
||||
key: "contact",
|
||||
type: "contact",
|
||||
variant: "quiet-footer",
|
||||
required: true,
|
||||
dataSlots: ["profile.contact"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "offerings",
|
||||
title: "业务提供项",
|
||||
renderer: "linjing-offerings",
|
||||
modules: [
|
||||
{
|
||||
key: "offerings",
|
||||
type: "offering-list",
|
||||
variant: "editorial-grid",
|
||||
required: true,
|
||||
dataSlots: ["offerings.list"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "detail",
|
||||
title: "提供项详情",
|
||||
renderer: "linjing-offering-detail",
|
||||
modules: [
|
||||
{
|
||||
key: "detail",
|
||||
type: "offering-detail",
|
||||
variant: "project-case",
|
||||
required: true,
|
||||
dataSlots: ["offering.detail"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "inquiry",
|
||||
title: "咨询与预约",
|
||||
renderer: "linjing-inquiry",
|
||||
modules: [
|
||||
{
|
||||
key: "inquiry",
|
||||
type: "inquiry-form",
|
||||
variant: "editorial-form",
|
||||
required: true,
|
||||
dataSlots: ["inquiry.form"],
|
||||
capability: "inquiry",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "success",
|
||||
title: "提交成功",
|
||||
renderer: "linjing-success",
|
||||
modules: [
|
||||
{
|
||||
key: "success",
|
||||
type: "success-summary",
|
||||
variant: "editorial-confirmation",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "records",
|
||||
title: "我的记录",
|
||||
renderer: "linjing-records",
|
||||
modules: [
|
||||
{
|
||||
key: "records",
|
||||
type: "records-list",
|
||||
variant: "timeline",
|
||||
required: true,
|
||||
dataSlots: ["records.items"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "profile",
|
||||
title: "主理人与我",
|
||||
renderer: "linjing-profile",
|
||||
modules: [
|
||||
{
|
||||
key: "identity",
|
||||
type: "brand-identity",
|
||||
variant: "profile-editorial",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
assetSlots: ["profile.portrait"],
|
||||
},
|
||||
{
|
||||
key: "contact",
|
||||
type: "contact",
|
||||
variant: "contact-sheet",
|
||||
required: true,
|
||||
dataSlots: ["profile.contact"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
capabilities: ["offerings", "inquiry"],
|
||||
};
|
||||
|
||||
export const visualTemplateManifests: Record<VisualTemplateKey, VisualTemplateManifest> = {
|
||||
"linjing-editorial": linjingEditorialManifest,
|
||||
"acheng-campus-food": {
|
||||
...linjingEditorialManifest,
|
||||
key: "acheng-campus-food",
|
||||
version: "1.0.0",
|
||||
name: "阿成校园餐",
|
||||
description: "面向校园餐饮摊贩的菜单、出摊动态和团体预订视觉模板。",
|
||||
supportedIndustryTemplates: ["food"],
|
||||
tokens: {
|
||||
...linjingEditorialManifest.tokens,
|
||||
colors: {
|
||||
background: "#FFF8F0",
|
||||
surface: "#FFFFFF",
|
||||
foreground: "#29231F",
|
||||
muted: "#7A6A60",
|
||||
accent: "#E87532",
|
||||
dark: "#3B2118",
|
||||
},
|
||||
radius: { card: "24rpx", button: "999rpx", media: "20rpx" },
|
||||
},
|
||||
pages: linjingEditorialManifest.pages.map((pageDefinition) => {
|
||||
const renderer =
|
||||
pageDefinition.key === "home"
|
||||
? "acheng-home"
|
||||
: pageDefinition.key === "offerings"
|
||||
? "acheng-offerings"
|
||||
: pageDefinition.key === "profile"
|
||||
? "acheng-profile"
|
||||
: pageDefinition.renderer;
|
||||
return renderer ? { ...pageDefinition, renderer } : pageDefinition;
|
||||
}),
|
||||
capabilities: ["offerings", "inquiry", "booking"],
|
||||
},
|
||||
};
|
||||
|
||||
export function getVisualTemplateManifest(key: string): VisualTemplateManifest | undefined {
|
||||
return visualTemplateManifests[key as VisualTemplateKey];
|
||||
}
|
||||
|
||||
export function isVisualTemplateCompatible(
|
||||
visualTemplate: VisualTemplateDefinition | VisualTemplateManifest,
|
||||
industryTemplateKey: string,
|
||||
): boolean {
|
||||
return visualTemplate.supportedIndustryTemplates.includes(
|
||||
industryTemplateKey as BrandTemplateKey,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user