feat: 新增独立工坊宣传模板及配置导入验证

This commit is contained in:
que01 committed 2026-10-15 17:44:52 +08:00
1 parent bf4bbf81c7
commit 04e42b3a80
43 files changed
+5726 -13

No files matched your search

+19 -3
View File
@@ -1,12 +1,15 @@
import type { BrandTemplateKey } from "./template-keys.js";
import { getDefaultVisualTemplateKey } from "./visual-templates.js";
import { templatePackageRegistry } from "./template-packages.js";
export interface TemplateSampleContent {
templateKey: BrandTemplateKey;
brandConfig?: Record<string, unknown>;
inquiryFormName: string;
offerings: Array<{
kind: "service" | "product" | "package" | "subscription";
name: string;
coverUrl?: string;
summary: string;
categoryKey: string;
}>;
@@ -136,9 +139,22 @@ export const templateSampleContent = {
doors: doorsSampleContent,
} as const;
export function getTemplateSampleContent(templateKey: string): TemplateSampleContent | undefined {
const packageSample = templatePackageRegistry.find((item) =>
item.supportedIndustryTemplates.includes(templateKey),
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];
}