feat: 完善模板驱动的品牌内容工作台

This commit is contained in:
que01 committed 2026-09-25 05:21:42 +08:00
1 parent 77224ea51f
commit dd55af8d73
46 files changed
+2204 -295

No files matched your search

+47 -42
View File
@@ -1,5 +1,7 @@
export const configPackageName = "personal-brand-config";
import { generatedTemplatePackageRegistry } from "./generated-template-packages.js";
export type BrandTemplateKey = "personal" | "food" | "doors";
export type VisualTemplateKey = "linjing-editorial" | "acheng-campus-food";
export type CapabilityKey = "offerings" | "inquiry" | "booking" | "quote-request";
@@ -93,7 +95,7 @@ export interface VisualTemplateDefinition {
version: string;
name: string;
description: string;
supportedIndustryTemplates: BrandTemplateKey[];
supportedIndustryTemplates: readonly BrandTemplateKey[];
variants: Record<string, string>;
theme: { colors: Record<string, string>; radius: Record<string, string> };
layout?: { home: string[]; offerings: string[]; detail: string[]; profile: string[] };
@@ -187,54 +189,57 @@ export interface TemplatePackageManifest {
displayName: string;
visualTemplateKey: VisualTemplateKey;
runtimeContract: "1.0";
supportedIndustryTemplates: BrandTemplateKey[];
entrypoints: Record<VisualPageKey, string>;
requiredCapabilities: CapabilityKey[];
supportedIndustryTemplates: readonly BrandTemplateKey[];
entrypoints: Readonly<Record<string, string>>;
requiredCapabilities: readonly CapabilityKey[];
defaultBrandSlug: string;
navigation: readonly {
key: string;
label: string;
page: string;
iconPath?: string;
selectedIconPath?: string;
}[];
renderers: Readonly<Record<string, string>>;
runtimeOwnedPages: readonly string[];
dataSlots: readonly {
key: string;
source: string;
required: boolean;
description: string;
}[];
assetSlots: readonly {
key: string;
binding: string;
target: "brand" | "offering" | "trust";
label: string;
help: string;
required: boolean;
}[];
admin: {
sections: readonly {
key: string;
title: string;
description: string;
target: "brand" | "offering" | "trust" | "inquiry";
fields: readonly { key: string; binding: string; label: string; required?: boolean }[];
}[];
};
}
export const templatePackageRegistry: readonly TemplatePackageManifest[] = [
{
packageKey: "linjing-editorial",
version: "1.0.0",
displayName: "林境建筑画册",
visualTemplateKey: "linjing-editorial",
runtimeContract: "1.0",
supportedIndustryTemplates: ["personal", "doors"],
entrypoints: {
home: "pages/index/index",
offerings: "pages/services/index",
detail: "pages/offering/detail",
inquiry: "pages/inquiry/index",
success: "pages/inquiry-success/index",
records: "pages/records/index",
profile: "pages/bookings/index",
},
requiredCapabilities: ["offerings", "inquiry"],
},
{
packageKey: "acheng-campus-food",
version: "1.0.0",
displayName: "阿成校园餐",
visualTemplateKey: "acheng-campus-food",
runtimeContract: "1.0",
supportedIndustryTemplates: ["food"],
entrypoints: {
home: "pages/index/index",
offerings: "pages/services/index",
detail: "pages/offering/detail",
inquiry: "pages/inquiry/index",
success: "pages/inquiry-success/index",
records: "pages/records/index",
profile: "pages/bookings/index",
},
requiredCapabilities: ["offerings", "inquiry", "booking"],
},
];
export const templatePackageRegistry: readonly TemplatePackageManifest[] =
generatedTemplatePackageRegistry;
export function getTemplatePackageManifest(key: string): TemplatePackageManifest | undefined {
return templatePackageRegistry.find((item) => item.packageKey === key);
}
export function getTemplatePackageManifestForVisualKey(
visualTemplateKey: string,
): 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");