refactor: 统一模板契约并修复预览版本
This commit is contained in:
1 parent
cd2992c00a
commit
50b87e48de
56 files changed
+7849
-5756
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -147,5 +147,5 @@ export interface TemplatePackageManifest {
|
||||
}[];
|
||||
overrides?: readonly string[];
|
||||
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
|
||||
previewFixture?: Partial<Record<BrandTemplateKey, TemplatePreviewFixture>>;
|
||||
previewFixture: Readonly<Partial<Record<BrandTemplateKey, TemplatePreviewFixture>>>;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { generatedTemplatePackageRegistry } from "./generated-template-packages.js";
|
||||
import type { TemplatePackageManifest } from "./template-package-manifest.js";
|
||||
export { validateTemplatePackageManifest } from "@personal-brand/template-contract";
|
||||
|
||||
export const templatePackageRegistry: readonly TemplatePackageManifest[] =
|
||||
generatedTemplatePackageRegistry;
|
||||
@@ -13,24 +14,3 @@ export function getTemplatePackageManifestForVisualKey(
|
||||
): TemplatePackageManifest | undefined {
|
||||
return templatePackageRegistry.find((item) => item.visualTemplateKey === visualTemplateKey);
|
||||
}
|
||||
|
||||
export function validateTemplatePackageManifest(manifest: TemplatePackageManifest): string[] {
|
||||
const errors: string[] = [];
|
||||
if (!manifest.packageKey.trim()) errors.push("packageKey is required");
|
||||
if (!manifest.version.trim()) errors.push("version is required");
|
||||
if (manifest.runtimeContract !== "1.0") errors.push("unsupported runtimeContract");
|
||||
if (!manifest.supportedIndustryTemplates.length)
|
||||
errors.push("supportedIndustryTemplates must not be empty");
|
||||
for (const page of [
|
||||
"home",
|
||||
"offerings",
|
||||
"detail",
|
||||
"inquiry",
|
||||
"success",
|
||||
"records",
|
||||
"profile",
|
||||
] as const) {
|
||||
if (!manifest.entrypoints[page]?.trim()) errors.push(`entrypoints.${page} is required`);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import { getDefaultVisualTemplateKey } from "./visual-templates.js";
|
||||
import { templatePackageRegistry } from "./template-packages.js";
|
||||
|
||||
export interface TemplateSampleContent {
|
||||
templateKey: BrandTemplateKey;
|
||||
@@ -33,132 +31,3 @@ export interface TemplateSampleContent {
|
||||
}>;
|
||||
capabilityKey: string;
|
||||
}
|
||||
|
||||
const doorsSampleContent: TemplateSampleContent = {
|
||||
templateKey: "doors",
|
||||
inquiryFormName: "门系统咨询表单",
|
||||
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: "credential", title: "主理人的门作观", content: "示例内容,待品牌主理人完善。" },
|
||||
{ type: "case", title: "别墅门系统案例", content: "示例内容,待品牌主理人完善。" },
|
||||
{ type: "process", title: "从测量到交付", content: "示例内容,待品牌主理人完善。" },
|
||||
{ type: "credential", title: "材料与工艺标准", content: "示例内容,待品牌主理人完善。" },
|
||||
],
|
||||
fields: [
|
||||
{ key: "projectType", label: "项目类型", type: "select", required: false },
|
||||
{ key: "projectStage", label: "项目阶段", type: "select", required: false },
|
||||
{ key: "siteDescription", label: "项目概况", type: "textarea", required: false },
|
||||
{ key: "phone", label: "联系方式", type: "phone", required: true },
|
||||
],
|
||||
capabilityKey: "doors",
|
||||
};
|
||||
|
||||
const foodSampleContent: TemplateSampleContent = {
|
||||
templateKey: "food",
|
||||
inquiryFormName: "餐品预订与定制表单",
|
||||
offerings: [
|
||||
{
|
||||
kind: "package",
|
||||
name: "示例·今日套餐",
|
||||
summary: "现做家常套餐示例内容。",
|
||||
categoryKey: "set-meal",
|
||||
priceAmount: 2800,
|
||||
},
|
||||
{
|
||||
kind: "service",
|
||||
name: "示例·聚餐定制",
|
||||
summary: "按人数和口味沟通定制餐品。",
|
||||
categoryKey: "private-chef",
|
||||
},
|
||||
],
|
||||
trustContent: [
|
||||
{ type: "credential", 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",
|
||||
};
|
||||
|
||||
const personalSampleContent: TemplateSampleContent = {
|
||||
templateKey: "personal",
|
||||
inquiryFormName: "合作咨询表单",
|
||||
offerings: [
|
||||
{
|
||||
kind: "service",
|
||||
name: "示例·品牌定位咨询",
|
||||
summary: "梳理品牌定位与下一步行动。",
|
||||
categoryKey: "consulting",
|
||||
},
|
||||
{
|
||||
kind: "service",
|
||||
name: "示例·长期顾问支持",
|
||||
summary: "围绕表达和转化提供持续支持。",
|
||||
categoryKey: "advisory",
|
||||
},
|
||||
],
|
||||
trustContent: [
|
||||
{ type: "credential", 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",
|
||||
};
|
||||
|
||||
export const templateSampleContent = {
|
||||
personal: personalSampleContent,
|
||||
food: foodSampleContent,
|
||||
doors: doorsSampleContent,
|
||||
} as const;
|
||||
|
||||
export function getTemplateSampleContent(
|
||||
templateKey: string,
|
||||
visualTemplateKey?: string,
|
||||
): TemplateSampleContent | undefined {
|
||||
const selected = visualTemplateKey
|
||||
? templatePackageRegistry.find(
|
||||
(item) =>
|
||||
item.packageKey === visualTemplateKey &&
|
||||
item.supportedIndustryTemplates.includes(templateKey),
|
||||
)
|
||||
: undefined;
|
||||
if (selected) return selected.sampleContent?.[templateKey];
|
||||
const packageSample = templatePackageRegistry.find(
|
||||
(item) =>
|
||||
item.packageKey === getDefaultVisualTemplateKey(templateKey) &&
|
||||
item.supportedIndustryTemplates.includes(templateKey),
|
||||
)?.sampleContent?.[templateKey];
|
||||
return packageSample ?? templateSampleContent[templateKey as keyof typeof templateSampleContent];
|
||||
}
|
||||
@@ -67,13 +67,3 @@ export const visualTemplateKeys = listVisualTemplateKeys();
|
||||
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
|
||||
return visualTemplates[key];
|
||||
}
|
||||
|
||||
export function getDefaultVisualTemplateKey(industryTemplateKey: string): VisualTemplateKey {
|
||||
return (
|
||||
listVisualTemplateKeys().find((key) =>
|
||||
getVisualTemplate(key)?.supportedIndustryTemplates.includes(industryTemplateKey),
|
||||
) ?? defaultVisualTemplateKey
|
||||
);
|
||||
}
|
||||
|
||||
export const defaultVisualTemplateKey = "linjing-editorial" satisfies VisualTemplateKey;
|
||||
Reference in new issue
Block a user