refactor: 将模板示例内容移入模板包
This commit is contained in:
1 parent
dd55af8d73
commit
6218ed395b
7 files changed
+517
-18
No files matched your search
@@ -289,6 +289,58 @@ export const generatedTemplatePackageRegistry = [
|
||||
}
|
||||
]
|
||||
},
|
||||
"sampleContent": {
|
||||
"food": {
|
||||
"templateKey": "food",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "package",
|
||||
"name": "示例·今日套餐",
|
||||
"summary": "现做家常套餐示例内容。",
|
||||
"categoryKey": "set-meal"
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·聚餐定制",
|
||||
"summary": "按人数和口味沟通定制餐品。",
|
||||
"categoryKey": "private-chef"
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "profile",
|
||||
"title": "关于主理人",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "从预订到取餐",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "date",
|
||||
"label": "用餐日期",
|
||||
"type": "date",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "number",
|
||||
"label": "用餐人数",
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"label": "联系方式",
|
||||
"type": "phone",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"capabilityKey": "booking"
|
||||
}
|
||||
},
|
||||
"renderers": {
|
||||
"home": "acheng-home",
|
||||
"offerings": "acheng-offerings",
|
||||
@@ -592,6 +644,228 @@ export const generatedTemplatePackageRegistry = [
|
||||
}
|
||||
]
|
||||
},
|
||||
"sampleContent": {
|
||||
"doors": {
|
||||
"templateKey": "doors",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "序章·入户门",
|
||||
"summary": "为别墅入口定制的整樘门系统",
|
||||
"categoryKey": "entrance-door"
|
||||
},
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "庭院·边界门",
|
||||
"summary": "连接建筑与庭院的定制门",
|
||||
"categoryKey": "garden-door"
|
||||
},
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "室内·静谧门",
|
||||
"summary": "统一室内空间秩序的户内门",
|
||||
"categoryKey": "interior-door"
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "一对一门系统设计咨询",
|
||||
"summary": "从现场到方案的完整设计沟通",
|
||||
"categoryKey": "custom"
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "profile",
|
||||
"title": "主理人的门作观",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "portfolio",
|
||||
"title": "别墅门系统案例",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "从测量到交付",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "材料与工艺标准",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "doorType",
|
||||
"label": "期望定制的门类型",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "入户大门(防暴铸铜 / 实木)",
|
||||
"value": "入户大门(防暴铸铜 / 实木)"
|
||||
},
|
||||
{
|
||||
"label": "庭院围墙门(耐候格栅 / 对开)",
|
||||
"value": "庭院围墙门(耐候格栅 / 对开)"
|
||||
},
|
||||
{
|
||||
"label": "全屋室内门系统(通顶隐形)",
|
||||
"value": "全屋室内门系统(通顶隐形)"
|
||||
},
|
||||
{
|
||||
"label": "背景墙一体门 / 密室门",
|
||||
"value": "背景墙一体门 / 密室门"
|
||||
},
|
||||
{
|
||||
"label": "整栋别墅门系统全案一体化",
|
||||
"value": "整栋别墅门系统全案一体化"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "cityArea",
|
||||
"label": "房屋 / 别墅所在城市与楼盘",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "projectStage",
|
||||
"label": "项目阶段",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "土建结构阶段(适合预埋加固)",
|
||||
"value": "土建结构阶段(适合预埋加固)"
|
||||
},
|
||||
{
|
||||
"label": "水电木工阶段(适合精确测距)",
|
||||
"value": "水电木工阶段(适合精确测距)"
|
||||
},
|
||||
{
|
||||
"label": "硬装收尾阶段",
|
||||
"value": "硬装收尾阶段"
|
||||
},
|
||||
{
|
||||
"label": "旧宅门体翻新改造",
|
||||
"value": "旧宅门体翻新改造"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "budgetRange",
|
||||
"label": "预估门系统投资预算",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"options": [
|
||||
{
|
||||
"label": "5 万 - 10 万",
|
||||
"value": "5 万 - 10 万"
|
||||
},
|
||||
{
|
||||
"label": "10 万 - 20 万",
|
||||
"value": "10 万 - 20 万"
|
||||
},
|
||||
{
|
||||
"label": "20 万 - 50 万(全宅全案)",
|
||||
"value": "20 万 - 50 万(全宅全案)"
|
||||
},
|
||||
{
|
||||
"label": "50 万以上(顶级孤品定制)",
|
||||
"value": "50 万以上(顶级孤品定制)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "needMeasure",
|
||||
"label": "是否需要主理人上门现场量房",
|
||||
"type": "radio",
|
||||
"required": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "需要(预约排期现场勘测)",
|
||||
"value": "需要(预约排期现场勘测)"
|
||||
},
|
||||
{
|
||||
"label": "暂不需要(先发图纸在线深化评估)",
|
||||
"value": "暂不需要(先发图纸在线深化评估)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "contactName",
|
||||
"label": "贵姓称谓",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "contactPhone",
|
||||
"label": "联系手机号(微信同号)",
|
||||
"type": "tel",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "specialNote",
|
||||
"label": "空间想法或特殊需求描述",
|
||||
"type": "textarea",
|
||||
"required": false
|
||||
}
|
||||
],
|
||||
"capabilityKey": "doors"
|
||||
},
|
||||
"personal": {
|
||||
"templateKey": "personal",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·品牌定位咨询",
|
||||
"summary": "梳理品牌定位与下一步行动。",
|
||||
"categoryKey": "consulting"
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·长期顾问支持",
|
||||
"summary": "围绕表达和转化提供持续支持。",
|
||||
"categoryKey": "advisory"
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{
|
||||
"type": "profile",
|
||||
"title": "关于主理人",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{
|
||||
"type": "process",
|
||||
"title": "合作方法",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "name",
|
||||
"label": "您的称呼",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "phone",
|
||||
"label": "联系方式",
|
||||
"type": "phone",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "remark",
|
||||
"label": "合作需求",
|
||||
"type": "textarea",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"capabilityKey": "inquiry"
|
||||
}
|
||||
},
|
||||
"renderers": {
|
||||
"home": "linjing-home",
|
||||
"offerings": "linjing-offerings",
|
||||
@@ -612,4 +886,4 @@ export const generatedTemplatePackageRegistry = [
|
||||
}
|
||||
];
|
||||
export const generatedTemplatePackageRegistryHash =
|
||||
"ff79864f3873fe627710c092622abd26212a8c25ab52c422ee4e22e95f4d2d73";
|
||||
"6d56212ec96d9b7b99a9e12aa278ca0927dc5e4472ec6ece3098a7d99842897b";
|
||||
@@ -225,6 +225,7 @@ export interface TemplatePackageManifest {
|
||||
fields: readonly { key: string; binding: string; label: string; required?: boolean }[];
|
||||
}[];
|
||||
};
|
||||
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
|
||||
}
|
||||
|
||||
export const templatePackageRegistry: readonly TemplatePackageManifest[] =
|
||||
@@ -270,7 +271,13 @@ export interface TemplateSampleContent {
|
||||
categoryKey: string;
|
||||
}>;
|
||||
trustContent: Array<{ type: string; title: string; content: string }>;
|
||||
fields: Array<{ key: string; label: string; type: string; required: boolean }>;
|
||||
fields: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
type: string;
|
||||
required: boolean;
|
||||
options?: Array<{ label: string; value: string }>;
|
||||
}>;
|
||||
capabilityKey: string;
|
||||
}
|
||||
|
||||
@@ -380,7 +387,10 @@ export const templateSampleContent: Record<BrandTemplateKey, TemplateSampleConte
|
||||
};
|
||||
|
||||
export function getTemplateSampleContent(templateKey: string): TemplateSampleContent | undefined {
|
||||
return templateSampleContent[templateKey as keyof typeof templateSampleContent];
|
||||
const packageSample = templatePackageRegistry.find((item) =>
|
||||
item.supportedIndustryTemplates.includes(templateKey as BrandTemplateKey),
|
||||
)?.sampleContent?.[templateKey as BrandTemplateKey];
|
||||
return packageSample ?? templateSampleContent[templateKey as keyof typeof templateSampleContent];
|
||||
}
|
||||
|
||||
const linjingEditorialManifest: VisualTemplateManifest = {
|
||||
|
||||
@@ -281,6 +281,35 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"sampleContent": {
|
||||
"food": {
|
||||
"templateKey": "food",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "package",
|
||||
"name": "示例·今日套餐",
|
||||
"summary": "现做家常套餐示例内容。",
|
||||
"categoryKey": "set-meal"
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·聚餐定制",
|
||||
"summary": "按人数和口味沟通定制餐品。",
|
||||
"categoryKey": "private-chef"
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{ "type": "profile", "title": "关于主理人", "content": "示例内容,待品牌主理人完善。" },
|
||||
{ "type": "process", "title": "从预订到取餐", "content": "示例内容,待品牌主理人完善。" }
|
||||
],
|
||||
"fields": [
|
||||
{ "key": "date", "label": "用餐日期", "type": "date", "required": true },
|
||||
{ "key": "number", "label": "用餐人数", "type": "number", "required": true },
|
||||
{ "key": "phone", "label": "联系方式", "type": "phone", "required": true }
|
||||
],
|
||||
"capabilityKey": "booking"
|
||||
}
|
||||
},
|
||||
"renderers": {
|
||||
"home": "acheng-home",
|
||||
"offerings": "acheng-offerings",
|
||||
|
||||
@@ -60,6 +60,14 @@ export type TemplateAdminManifest = {
|
||||
sections: TemplateAdminSection[];
|
||||
};
|
||||
|
||||
export type TemplateSampleContent = {
|
||||
templateKey: string;
|
||||
offerings: Array<Record<string, unknown>>;
|
||||
trustContent: Array<Record<string, unknown>>;
|
||||
fields: Array<Record<string, unknown>>;
|
||||
capabilityKey: string;
|
||||
};
|
||||
|
||||
export type TemplatePackageManifest = {
|
||||
packageKey: string;
|
||||
version: string;
|
||||
@@ -81,6 +89,7 @@ export type TemplatePackageManifest = {
|
||||
dataSlots: TemplateDataSlot[];
|
||||
assetSlots: TemplateAssetSlot[];
|
||||
admin: TemplateAdminManifest;
|
||||
sampleContent?: Record<string, TemplateSampleContent>;
|
||||
};
|
||||
|
||||
export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
@@ -149,5 +158,25 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
if (!manifest.entrypoints || typeof manifest.entrypoints[page] !== "string")
|
||||
errors.push(`entrypoints.${page} is required`);
|
||||
}
|
||||
if (manifest.sampleContent !== undefined) {
|
||||
for (const [industryKey, sample] of Object.entries(manifest.sampleContent)) {
|
||||
if (!manifest.supportedIndustryTemplates.includes(industryKey))
|
||||
errors.push(`sampleContent.${industryKey} is not a supported industry template`);
|
||||
if (sample.templateKey !== industryKey)
|
||||
errors.push(`sampleContent.${industryKey}.templateKey must match its key`);
|
||||
if (!Array.isArray(sample.offerings) || !Array.isArray(sample.trustContent))
|
||||
errors.push(`sampleContent.${industryKey} requires offerings and trustContent arrays`);
|
||||
if (!Array.isArray(sample.fields) || !sample.fields.length)
|
||||
errors.push(`sampleContent.${industryKey} requires fields`);
|
||||
for (const field of sample.fields ?? []) {
|
||||
if (typeof field.key !== "string" || typeof field.label !== "string")
|
||||
errors.push(`sampleContent.${industryKey} fields require key and label`);
|
||||
if (["select", "radio", "multi-select"].includes(String(field.type))) {
|
||||
if (!Array.isArray(field.options) || !field.options.length)
|
||||
errors.push(`sampleContent.${industryKey}.${String(field.key)} requires options`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
@@ -269,6 +269,150 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"sampleContent": {
|
||||
"doors": {
|
||||
"templateKey": "doors",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "序章·入户门",
|
||||
"summary": "为别墅入口定制的整樘门系统",
|
||||
"categoryKey": "entrance-door"
|
||||
},
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "庭院·边界门",
|
||||
"summary": "连接建筑与庭院的定制门",
|
||||
"categoryKey": "garden-door"
|
||||
},
|
||||
{
|
||||
"kind": "product",
|
||||
"name": "室内·静谧门",
|
||||
"summary": "统一室内空间秩序的户内门",
|
||||
"categoryKey": "interior-door"
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "一对一门系统设计咨询",
|
||||
"summary": "从现场到方案的完整设计沟通",
|
||||
"categoryKey": "custom"
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{ "type": "profile", "title": "主理人的门作观", "content": "示例内容,待品牌主理人完善。" },
|
||||
{
|
||||
"type": "portfolio",
|
||||
"title": "别墅门系统案例",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
},
|
||||
{ "type": "process", "title": "从测量到交付", "content": "示例内容,待品牌主理人完善。" },
|
||||
{
|
||||
"type": "credential",
|
||||
"title": "材料与工艺标准",
|
||||
"content": "示例内容,待品牌主理人完善。"
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "doorType",
|
||||
"label": "期望定制的门类型",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"options": [
|
||||
{ "label": "入户大门(防暴铸铜 / 实木)", "value": "入户大门(防暴铸铜 / 实木)" },
|
||||
{ "label": "庭院围墙门(耐候格栅 / 对开)", "value": "庭院围墙门(耐候格栅 / 对开)" },
|
||||
{ "label": "全屋室内门系统(通顶隐形)", "value": "全屋室内门系统(通顶隐形)" },
|
||||
{ "label": "背景墙一体门 / 密室门", "value": "背景墙一体门 / 密室门" },
|
||||
{ "label": "整栋别墅门系统全案一体化", "value": "整栋别墅门系统全案一体化" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "cityArea",
|
||||
"label": "房屋 / 别墅所在城市与楼盘",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "projectStage",
|
||||
"label": "项目阶段",
|
||||
"type": "select",
|
||||
"required": true,
|
||||
"options": [
|
||||
{ "label": "土建结构阶段(适合预埋加固)", "value": "土建结构阶段(适合预埋加固)" },
|
||||
{ "label": "水电木工阶段(适合精确测距)", "value": "水电木工阶段(适合精确测距)" },
|
||||
{ "label": "硬装收尾阶段", "value": "硬装收尾阶段" },
|
||||
{ "label": "旧宅门体翻新改造", "value": "旧宅门体翻新改造" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "budgetRange",
|
||||
"label": "预估门系统投资预算",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"options": [
|
||||
{ "label": "5 万 - 10 万", "value": "5 万 - 10 万" },
|
||||
{ "label": "10 万 - 20 万", "value": "10 万 - 20 万" },
|
||||
{ "label": "20 万 - 50 万(全宅全案)", "value": "20 万 - 50 万(全宅全案)" },
|
||||
{ "label": "50 万以上(顶级孤品定制)", "value": "50 万以上(顶级孤品定制)" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "needMeasure",
|
||||
"label": "是否需要主理人上门现场量房",
|
||||
"type": "radio",
|
||||
"required": true,
|
||||
"options": [
|
||||
{ "label": "需要(预约排期现场勘测)", "value": "需要(预约排期现场勘测)" },
|
||||
{
|
||||
"label": "暂不需要(先发图纸在线深化评估)",
|
||||
"value": "暂不需要(先发图纸在线深化评估)"
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "key": "contactName", "label": "贵姓称谓", "type": "text", "required": true },
|
||||
{
|
||||
"key": "contactPhone",
|
||||
"label": "联系手机号(微信同号)",
|
||||
"type": "tel",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"key": "specialNote",
|
||||
"label": "空间想法或特殊需求描述",
|
||||
"type": "textarea",
|
||||
"required": false
|
||||
}
|
||||
],
|
||||
"capabilityKey": "doors"
|
||||
},
|
||||
"personal": {
|
||||
"templateKey": "personal",
|
||||
"offerings": [
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·品牌定位咨询",
|
||||
"summary": "梳理品牌定位与下一步行动。",
|
||||
"categoryKey": "consulting"
|
||||
},
|
||||
{
|
||||
"kind": "service",
|
||||
"name": "示例·长期顾问支持",
|
||||
"summary": "围绕表达和转化提供持续支持。",
|
||||
"categoryKey": "advisory"
|
||||
}
|
||||
],
|
||||
"trustContent": [
|
||||
{ "type": "profile", "title": "关于主理人", "content": "示例内容,待品牌主理人完善。" },
|
||||
{ "type": "process", "title": "合作方法", "content": "示例内容,待品牌主理人完善。" }
|
||||
],
|
||||
"fields": [
|
||||
{ "key": "name", "label": "您的称呼", "type": "text", "required": true },
|
||||
{ "key": "phone", "label": "联系方式", "type": "phone", "required": true },
|
||||
{ "key": "remark", "label": "合作需求", "type": "textarea", "required": true }
|
||||
],
|
||||
"capabilityKey": "inquiry"
|
||||
}
|
||||
},
|
||||
"renderers": {
|
||||
"home": "linjing-home",
|
||||
"offerings": "linjing-offerings",
|
||||
|
||||
Reference in new issue
Block a user