224 lines
7.4 KiB
TypeScript
224 lines
7.4 KiB
TypeScript
export const configPackageName = "personal-brand-config";
|
|
|
|
export type BrandTemplateKey = "personal" | "food";
|
|
export type VisualTemplateKey = "linjing-editorial" | "minimal-neutral";
|
|
export type CapabilityKey = "offerings" | "inquiry" | "booking";
|
|
|
|
export interface WorkflowDefinition {
|
|
key: string;
|
|
version: string;
|
|
initialState: string;
|
|
transitions: Record<string, readonly string[]>;
|
|
}
|
|
|
|
export interface CapabilityDefinition {
|
|
key: CapabilityKey;
|
|
version: string;
|
|
workflowKey?: string;
|
|
}
|
|
|
|
export const workflowRegistry = {
|
|
"booking.basic": {
|
|
key: "booking.basic",
|
|
version: "1.0.0",
|
|
initialState: "received",
|
|
transitions: {
|
|
received: ["contacting", "cancelled"],
|
|
contacting: ["confirmed", "cancelled"],
|
|
confirmed: ["completed", "cancelled"],
|
|
completed: [],
|
|
cancelled: [],
|
|
},
|
|
},
|
|
} as const satisfies Record<string, WorkflowDefinition>;
|
|
|
|
export const capabilityRegistry = {
|
|
offerings: { key: "offerings", version: "1.0.0" },
|
|
inquiry: { key: "inquiry", version: "1.0.0" },
|
|
booking: { key: "booking", version: "1.0.0", workflowKey: "booking.basic" },
|
|
} as const satisfies Record<CapabilityKey, CapabilityDefinition>;
|
|
|
|
export type BrandTemplateModuleType = "identity" | "trust" | "offering" | "inquiry" | "contact";
|
|
|
|
export interface BrandTemplateModuleDefinition {
|
|
key: string;
|
|
type: BrandTemplateModuleType;
|
|
title: string;
|
|
required: boolean;
|
|
}
|
|
export interface BrandTemplateFieldDefinition {
|
|
scope: string;
|
|
key: string;
|
|
label: string;
|
|
type: string;
|
|
required: boolean;
|
|
}
|
|
|
|
export interface BrandTemplateDefinition {
|
|
key: BrandTemplateKey;
|
|
version: string;
|
|
name: string;
|
|
description: string;
|
|
serviceCategories: string[];
|
|
trustContentTypes: string[];
|
|
modules: BrandTemplateModuleDefinition[];
|
|
fields: BrandTemplateFieldDefinition[];
|
|
capabilities: CapabilityKey[];
|
|
}
|
|
|
|
export interface VisualTemplateDefinition {
|
|
key: VisualTemplateKey;
|
|
version: string;
|
|
name: string;
|
|
description: string;
|
|
variants: Record<string, string>;
|
|
theme: { colors: Record<string, string>; radius: Record<string, string> };
|
|
layout?: { home: string[]; offerings: string[]; detail: string[]; profile: string[] };
|
|
}
|
|
|
|
export const visualTemplates: Record<VisualTemplateKey, VisualTemplateDefinition> = {
|
|
"linjing-editorial": {
|
|
key: "linjing-editorial",
|
|
version: "1.0.0",
|
|
name: "林境建筑画册",
|
|
description: "适合高端定制、建筑作品和项目型个人品牌。",
|
|
variants: { hero: "architectural", offeringList: "editorial", detail: "project-case" },
|
|
theme: {
|
|
colors: { background: "#F7F5F1", foreground: "#252525", accent: "#8A6846", dark: "#202221" },
|
|
radius: { card: "16rpx" },
|
|
},
|
|
layout: {
|
|
home: ["founder-card", "brand-hero", "trust-proof", "trust-manifesto", "offering-list"],
|
|
offerings: ["offering-list"],
|
|
detail: ["offering-detail"],
|
|
profile: ["profile"],
|
|
},
|
|
},
|
|
"minimal-neutral": {
|
|
key: "minimal-neutral",
|
|
version: "1.0.0",
|
|
name: "极简留白",
|
|
description: "适合咨询、设计和专业服务型个人品牌。",
|
|
variants: { hero: "minimal", offeringList: "square-card", detail: "service-process" },
|
|
theme: {
|
|
colors: { background: "#FAFAF8", foreground: "#202221", accent: "#4B5563", dark: "#202221" },
|
|
radius: { card: "8rpx" },
|
|
},
|
|
layout: {
|
|
home: ["brand-hero", "founder-card", "offering-list", "trust-proof"],
|
|
offerings: ["offering-list"],
|
|
detail: ["offering-detail"],
|
|
profile: ["profile"],
|
|
},
|
|
},
|
|
};
|
|
|
|
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
|
|
return visualTemplates[key as VisualTemplateKey];
|
|
}
|
|
|
|
export function canTransitionWorkflow(workflowKey: string, from: string, to: string): boolean {
|
|
const workflow = workflowRegistry[workflowKey as keyof typeof workflowRegistry] as
|
|
WorkflowDefinition | undefined;
|
|
return workflow ? from === to || workflow.transitions[from]?.includes(to) === true : false;
|
|
}
|
|
|
|
export function resolveCapabilities(keys: readonly CapabilityKey[]): CapabilityDefinition[] {
|
|
return keys.map((key) => capabilityRegistry[key]);
|
|
}
|
|
|
|
export const brandTemplates = {
|
|
personal: {
|
|
key: "personal",
|
|
version: "1.0.0",
|
|
name: "个人品牌",
|
|
description: "围绕定位、信任、作品与合作建立个人品牌。",
|
|
serviceCategories: ["consulting", "collaboration", "custom"],
|
|
trustContentTypes: [
|
|
"profile",
|
|
"experience",
|
|
"credential",
|
|
"portfolio",
|
|
"process",
|
|
"testimonial",
|
|
],
|
|
modules: [
|
|
{ key: "identity", type: "identity", title: "品牌身份", required: true },
|
|
{ key: "trust", type: "trust", title: "信任内容", required: true },
|
|
{ key: "offerings", type: "offering", title: "业务提供项", required: true },
|
|
{ key: "inquiry", type: "inquiry", title: "联系与咨询", required: true },
|
|
{ key: "contact", type: "contact", title: "品牌表达", required: true },
|
|
],
|
|
fields: [
|
|
{ scope: "profile", key: "name", label: "品牌名称", type: "text", required: true },
|
|
{ scope: "profile", key: "tagline", label: "一句话定位", type: "text", required: true },
|
|
{ scope: "profile", key: "audience", label: "服务对象", type: "textarea", required: true },
|
|
{
|
|
scope: "profile",
|
|
key: "valueProposition",
|
|
label: "提供的价值",
|
|
type: "textarea",
|
|
required: true,
|
|
},
|
|
{
|
|
scope: "profile",
|
|
key: "trustProof",
|
|
label: "信任证明入口",
|
|
type: "textarea",
|
|
required: true,
|
|
},
|
|
],
|
|
capabilities: ["offerings", "inquiry"],
|
|
},
|
|
food: {
|
|
key: "food",
|
|
version: "1.0.0",
|
|
name: "餐饮模板",
|
|
description: "适用于餐饮服务与套餐预约的行业模板。",
|
|
serviceCategories: ["food-package", "private-chef", "custom"],
|
|
trustContentTypes: [
|
|
"profile",
|
|
"experience",
|
|
"credential",
|
|
"portfolio",
|
|
"process",
|
|
"testimonial",
|
|
],
|
|
modules: [
|
|
{ key: "identity", type: "identity", title: "品牌身份", required: true },
|
|
{ key: "trust", type: "trust", title: "信任内容", required: true },
|
|
{ key: "offerings", type: "offering", title: "菜单与服务", required: true },
|
|
{ key: "inquiry", type: "inquiry", title: "预约与咨询", required: true },
|
|
{ key: "contact", type: "contact", title: "品牌表达", required: true },
|
|
],
|
|
fields: [
|
|
{ scope: "profile", key: "name", label: "品牌名称", type: "text", required: true },
|
|
{ scope: "profile", key: "tagline", label: "一句话定位", type: "text", required: true },
|
|
{ scope: "profile", key: "audience", label: "服务对象", type: "textarea", required: true },
|
|
{
|
|
scope: "profile",
|
|
key: "valueProposition",
|
|
label: "提供的价值",
|
|
type: "textarea",
|
|
required: true,
|
|
},
|
|
{
|
|
scope: "profile",
|
|
key: "trustProof",
|
|
label: "信任证明入口",
|
|
type: "textarea",
|
|
required: true,
|
|
},
|
|
],
|
|
capabilities: ["offerings", "inquiry", "booking"],
|
|
},
|
|
} satisfies Record<BrandTemplateKey, BrandTemplateDefinition>;
|
|
|
|
export function isBrandTemplateKey(value: string): value is BrandTemplateKey {
|
|
return Object.prototype.hasOwnProperty.call(brandTemplates, value);
|
|
}
|
|
|
|
export function getBrandTemplate(key: string): BrandTemplateDefinition | undefined {
|
|
return isBrandTemplateKey(key) ? brandTemplates[key] : undefined;
|
|
}
|