refactor: 拆分模板配置契约与注册逻辑
This commit is contained in:
1 parent
7e1dd543fb
commit
d0902d6568
12 files changed
+1025
-945
No files matched your search
@@ -0,0 +1,48 @@
|
||||
# 0023. 代码结构与重构标准
|
||||
|
||||
## Context
|
||||
|
||||
项目已进入多模板、多品牌和完整编辑发布阶段。Admin 页面、API Client、Config 包和部分 API Controller 出现超过 500 行甚至 900 行的文件。页面组件内同时存在查询、mutation、表单同步、预览映射和业务校验;API Client 将所有资源类型和方法集中在单个文件;Config 包将契约、注册表、示例内容和查询函数混在一个索引中。这种结构已经开始增加回归风险、review 成本和模板扩展成本。
|
||||
|
||||
项目已有交付清单要求接口授权、集成测试、数据迁移、UI 状态和生产构建一起验证。但缺少专门的代码结构标准,无法在功能继续增长前约束模块边界。
|
||||
|
||||
## Decision
|
||||
|
||||
建立 `docs/code-standards.md` 作为前后端共享结构标准,并按技术边界补充专门规则:
|
||||
|
||||
- Admin React 页面由页面组件、hooks、纯函数领域工具、feature 组件和 shared components 组成;页面组件不承载完整 API 调用和多领域状态。
|
||||
- API Controller 只处理路由、DTO、状态码、响应形状和传输入口;授权、Prisma、模板安装、快照组装和工作流推进进入 Service 或领域模块。
|
||||
- API Client 按资源拆分类型和方法模块,`index.ts` 只做聚合导出和 Client 组装。
|
||||
- Config 与模板包按 manifest、runtime、admin 契约、示例内容、注册表和查询函数拆分。
|
||||
- 超过 500 行的文件必须给出拆分计划;超过 800 行应拆分。
|
||||
- 结构重构优先保持外部行为不变,授权测试、品牌隔离测试、API Client 测试和生产构建必须保留并通过。
|
||||
|
||||
重构在专用分支完成,必须经过相关包测试、全仓 lint、typecheck、Admin 或相关应用生产构建后合并。
|
||||
|
||||
## Alternatives
|
||||
|
||||
1. 继续只在功能交付清单中约束行为:不能阻止模块继续膨胀,review 成本和冲突风险会继续上升。
|
||||
2. 引入统一组件框架或后端 CQRS 框架:改动范围过大,会打断当前产品主线,且对现有热点没有直接收益。
|
||||
3. 只按行数机械拆分:会生成缺少领域含义的小文件,降低可读性。
|
||||
|
||||
## Consequences
|
||||
|
||||
### Positive
|
||||
|
||||
- Admin 编辑器、工作台、业务和信任内容可以复用同一种状态与表单边界。
|
||||
- API 授权和持久化边界更容易测试。
|
||||
- API Client 和 Config 契约变更的影响面更清晰。
|
||||
- 模板新增与多品牌扩展不再依赖膨胀的单一索引。
|
||||
|
||||
### Negative
|
||||
|
||||
- 短期内会出现更多文件,需要依赖明确的领域命名。
|
||||
- 旧代码迁移需要多轮完成,不能一次替换所有结构。
|
||||
|
||||
## Migration Plan
|
||||
|
||||
1. 在 `refactor/code-standards` 分支先落地标准。
|
||||
2. 优先重构当前热点:品牌编辑器、工作台、API Client、Config 包和 Admin Workspace Controller。
|
||||
3. 每轮重构保持公共导出、endpoint、请求响应和授权行为兼容。
|
||||
4. 后续新增文件直接按标准执行;旧文件在改动该领域时逐步迁移。
|
||||
5. 分支通过全部相关测试和生产构建后合并回 `main`。
|
||||
@@ -0,0 +1,124 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import type { CapabilityKey } from "./template-keys.js";
|
||||
import type { VisualTemplateKey } from "./template-keys.js";
|
||||
|
||||
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;
|
||||
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[] };
|
||||
}
|
||||
|
||||
export type VisualPageKey =
|
||||
"home" | "offerings" | "detail" | "inquiry" | "success" | "records" | "profile";
|
||||
|
||||
export type VisualModuleType =
|
||||
| "brand-identity"
|
||||
| "hero"
|
||||
| "trust"
|
||||
| "offering-list"
|
||||
| "offering-detail"
|
||||
| "inquiry-form"
|
||||
| "success-summary"
|
||||
| "records-list"
|
||||
| "contact";
|
||||
|
||||
export interface VisualTokenSet {
|
||||
colors: Record<string, string>;
|
||||
spacing: Record<string, string>;
|
||||
typography: Record<string, string>;
|
||||
radius: Record<string, string>;
|
||||
shadows?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface VisualAssetSlot {
|
||||
key: string;
|
||||
label: string;
|
||||
required: boolean;
|
||||
kind: "image" | "icon" | "logo" | "texture";
|
||||
aspectRatio?: string;
|
||||
fallback?: string;
|
||||
}
|
||||
|
||||
export interface VisualDataSlot {
|
||||
key: string;
|
||||
source: "brand" | "trust" | "offering" | "inquiry" | "records" | "profile";
|
||||
required: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface VisualModuleDefinition {
|
||||
key: string;
|
||||
type: VisualModuleType;
|
||||
variant: string;
|
||||
required: boolean;
|
||||
dataSlots?: string[];
|
||||
assetSlots?: string[];
|
||||
capability?: CapabilityKey;
|
||||
}
|
||||
|
||||
export interface VisualPageDefinition {
|
||||
key: VisualPageKey;
|
||||
title: string;
|
||||
renderer?: string;
|
||||
modules: VisualModuleDefinition[];
|
||||
}
|
||||
|
||||
export interface VisualTemplateManifest {
|
||||
schemaVersion: "1.0";
|
||||
key: VisualTemplateKey;
|
||||
version: string;
|
||||
name: string;
|
||||
description: string;
|
||||
supportedIndustryTemplates: BrandTemplateKey[];
|
||||
brandFirst: true;
|
||||
tokens: VisualTokenSet;
|
||||
pages: VisualPageDefinition[];
|
||||
assets: VisualAssetSlot[];
|
||||
dataSlots: VisualDataSlot[];
|
||||
capabilities: CapabilityKey[];
|
||||
}
|
||||
|
||||
export interface TemplatePackage {
|
||||
manifest: VisualTemplateManifest;
|
||||
industryTemplateKey: BrandTemplateKey;
|
||||
content: Record<string, unknown>;
|
||||
forms: Record<string, unknown>[];
|
||||
capabilityConfig: Record<string, unknown>;
|
||||
fixtures: {
|
||||
runtime: Record<string, unknown>;
|
||||
visual: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import type { BrandTemplateDefinition } from "./brand-contracts.js";
|
||||
|
||||
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"],
|
||||
},
|
||||
doors: {
|
||||
key: "doors",
|
||||
version: "1.0.0",
|
||||
name: "高端门窗模板",
|
||||
description: "适用于别墅门、院门、室内门与定制门窗服务的行业模板。",
|
||||
serviceCategories: ["entrance-door", "garden-door", "interior-door", "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"],
|
||||
},
|
||||
} 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;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import type { CapabilityKey } from "./template-keys.js";
|
||||
|
||||
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" },
|
||||
"quote-request": { key: "quote-request", version: "1.0.0" },
|
||||
} as const satisfies Record<CapabilityKey, CapabilityDefinition>;
|
||||
|
||||
export const capabilityPlugins = {
|
||||
inquiry: {
|
||||
key: "inquiry",
|
||||
version: "1.0.0",
|
||||
displayName: "通用咨询",
|
||||
purpose: "inquiry",
|
||||
requiredModules: ["inquiry", "records", "success-summary"],
|
||||
apiContract: "/customer/inquiry-submissions",
|
||||
configSchema: "capability.inquiry.v1",
|
||||
},
|
||||
"quote-request": {
|
||||
key: "quote-request",
|
||||
version: "1.0.0",
|
||||
displayName: "报价咨询",
|
||||
purpose: "quote-request",
|
||||
requiredModules: ["inquiry", "records", "success-summary"],
|
||||
apiContract: "/customer/inquiry-submissions",
|
||||
configSchema: "capability.quote-request.v1",
|
||||
},
|
||||
} as const;
|
||||
+11
-945
@@ -1,946 +1,12 @@
|
||||
export * from "./brand-contracts.js";
|
||||
export * from "./brand-templates.js";
|
||||
export * from "./capability-contracts.js";
|
||||
export * from "./template-keys.js";
|
||||
export * from "./template-packages.js";
|
||||
export * from "./template-package-manifest.js";
|
||||
export * from "./template-sample-content.js";
|
||||
export * from "./visual-manifests.js";
|
||||
export * from "./visual-templates.js";
|
||||
export * from "./workflow.js";
|
||||
|
||||
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";
|
||||
|
||||
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" },
|
||||
"quote-request": { key: "quote-request", version: "1.0.0" },
|
||||
} as const satisfies Record<CapabilityKey, CapabilityDefinition>;
|
||||
|
||||
export const capabilityPlugins = {
|
||||
inquiry: {
|
||||
key: "inquiry",
|
||||
version: "1.0.0",
|
||||
displayName: "通用咨询",
|
||||
purpose: "inquiry",
|
||||
requiredModules: ["inquiry", "records", "success-summary"],
|
||||
apiContract: "/customer/inquiry-submissions",
|
||||
configSchema: "capability.inquiry.v1",
|
||||
},
|
||||
"quote-request": {
|
||||
key: "quote-request",
|
||||
version: "1.0.0",
|
||||
displayName: "报价咨询",
|
||||
purpose: "quote-request",
|
||||
requiredModules: ["inquiry", "records", "success-summary"],
|
||||
apiContract: "/customer/inquiry-submissions",
|
||||
configSchema: "capability.quote-request.v1",
|
||||
},
|
||||
} as const;
|
||||
|
||||
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;
|
||||
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[] };
|
||||
}
|
||||
|
||||
export type VisualPageKey =
|
||||
"home" | "offerings" | "detail" | "inquiry" | "success" | "records" | "profile";
|
||||
|
||||
export type VisualModuleType =
|
||||
| "brand-identity"
|
||||
| "hero"
|
||||
| "trust"
|
||||
| "offering-list"
|
||||
| "offering-detail"
|
||||
| "inquiry-form"
|
||||
| "success-summary"
|
||||
| "records-list"
|
||||
| "contact";
|
||||
|
||||
export interface VisualTokenSet {
|
||||
colors: Record<string, string>;
|
||||
spacing: Record<string, string>;
|
||||
typography: Record<string, string>;
|
||||
radius: Record<string, string>;
|
||||
shadows?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface VisualAssetSlot {
|
||||
key: string;
|
||||
label: string;
|
||||
required: boolean;
|
||||
kind: "image" | "icon" | "logo" | "texture";
|
||||
aspectRatio?: string;
|
||||
fallback?: string;
|
||||
}
|
||||
|
||||
export interface VisualDataSlot {
|
||||
key: string;
|
||||
source: "brand" | "trust" | "offering" | "inquiry" | "records" | "profile";
|
||||
required: boolean;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface VisualModuleDefinition {
|
||||
key: string;
|
||||
type: VisualModuleType;
|
||||
variant: string;
|
||||
required: boolean;
|
||||
dataSlots?: string[];
|
||||
assetSlots?: string[];
|
||||
capability?: CapabilityKey;
|
||||
}
|
||||
|
||||
export interface VisualPageDefinition {
|
||||
key: VisualPageKey;
|
||||
title: string;
|
||||
renderer?: string;
|
||||
modules: VisualModuleDefinition[];
|
||||
}
|
||||
|
||||
export interface VisualTemplateManifest {
|
||||
schemaVersion: "1.0";
|
||||
key: VisualTemplateKey;
|
||||
version: string;
|
||||
name: string;
|
||||
description: string;
|
||||
supportedIndustryTemplates: BrandTemplateKey[];
|
||||
brandFirst: true;
|
||||
tokens: VisualTokenSet;
|
||||
pages: VisualPageDefinition[];
|
||||
assets: VisualAssetSlot[];
|
||||
dataSlots: VisualDataSlot[];
|
||||
capabilities: CapabilityKey[];
|
||||
}
|
||||
|
||||
export interface TemplatePackage {
|
||||
manifest: VisualTemplateManifest;
|
||||
industryTemplateKey: BrandTemplateKey;
|
||||
content: Record<string, unknown>;
|
||||
forms: Record<string, unknown>[];
|
||||
capabilityConfig: Record<string, unknown>;
|
||||
fixtures: {
|
||||
runtime: Record<string, unknown>;
|
||||
visual: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface TemplatePackageManifest {
|
||||
packageKey: string;
|
||||
version: string;
|
||||
displayName: string;
|
||||
visualTemplateKey: VisualTemplateKey;
|
||||
runtimeContract: "1.0";
|
||||
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;
|
||||
}[];
|
||||
templateFields?: readonly {
|
||||
key: string;
|
||||
page?: string;
|
||||
binding?: string;
|
||||
label: string;
|
||||
help?: string;
|
||||
input: string;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
required?: boolean;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
options?: readonly { value: string; label: 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;
|
||||
page: string;
|
||||
target: "brand" | "offering" | "trust" | "inquiry";
|
||||
previewTargets?: readonly {
|
||||
key: string;
|
||||
label: string;
|
||||
composite?: boolean;
|
||||
children?: readonly string[];
|
||||
}[];
|
||||
fields: readonly {
|
||||
key: string;
|
||||
binding: string;
|
||||
label: string;
|
||||
input: string;
|
||||
help?: string;
|
||||
required?: boolean;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
options?: readonly { value: string; label: string }[];
|
||||
previewTarget?: string;
|
||||
}[];
|
||||
}[];
|
||||
};
|
||||
trustContentTypes?: readonly {
|
||||
type: string;
|
||||
label: string;
|
||||
adminFields: {
|
||||
title: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
summaryHelp?: string;
|
||||
summaryPlaceholder?: string;
|
||||
};
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
maxPublishedItems?: number;
|
||||
hideStandardFields?: readonly ("summary" | "content")[];
|
||||
configFields?: readonly {
|
||||
key: string;
|
||||
binding: string;
|
||||
label: string;
|
||||
input: string;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
required?: boolean;
|
||||
}[];
|
||||
}[];
|
||||
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
|
||||
}
|
||||
|
||||
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");
|
||||
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;
|
||||
}
|
||||
|
||||
export interface TemplateSampleContent {
|
||||
templateKey: BrandTemplateKey;
|
||||
inquiryFormName: string;
|
||||
offerings: Array<{
|
||||
kind: "service" | "product" | "package" | "subscription";
|
||||
name: string;
|
||||
summary: string;
|
||||
categoryKey: string;
|
||||
}>;
|
||||
trustContent: Array<{
|
||||
type: string;
|
||||
title: string;
|
||||
content: string;
|
||||
summary?: string;
|
||||
config?: Record<string, unknown>;
|
||||
}>;
|
||||
fields: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
type: string;
|
||||
required: boolean;
|
||||
options?: Array<{ label: string; value: string }>;
|
||||
}>;
|
||||
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",
|
||||
},
|
||||
{
|
||||
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: Record<BrandTemplateKey, TemplateSampleContent> = {
|
||||
personal: personalSampleContent,
|
||||
food: foodSampleContent,
|
||||
doors: doorsSampleContent,
|
||||
};
|
||||
|
||||
export function getTemplateSampleContent(templateKey: string): TemplateSampleContent | undefined {
|
||||
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 = {
|
||||
schemaVersion: "1.0",
|
||||
key: "linjing-editorial",
|
||||
version: "1.0.0",
|
||||
name: "林境建筑画册",
|
||||
description: "以个人品牌信任为主线、以高端项目作品为表达重点的编辑式视觉模板。",
|
||||
supportedIndustryTemplates: ["personal", "doors"],
|
||||
brandFirst: true,
|
||||
tokens: {
|
||||
colors: {
|
||||
background: "#F7F5F1",
|
||||
surface: "#FFFFFF",
|
||||
foreground: "#252525",
|
||||
muted: "#77736C",
|
||||
accent: "#8A6846",
|
||||
dark: "#202221",
|
||||
},
|
||||
spacing: { page: "32rpx", section: "56rpx", module: "24rpx" },
|
||||
typography: { display: "56rpx", heading: "36rpx", body: "28rpx", caption: "22rpx" },
|
||||
radius: { card: "16rpx", button: "999rpx", media: "12rpx" },
|
||||
shadows: { card: "0 8rpx 32rpx rgba(32,34,33,0.08)" },
|
||||
},
|
||||
assets: [
|
||||
{ key: "brand.logo", label: "品牌标志", required: false, kind: "logo" },
|
||||
{
|
||||
key: "home.hero",
|
||||
label: "首页首屏图",
|
||||
required: true,
|
||||
kind: "image",
|
||||
aspectRatio: "16:9",
|
||||
},
|
||||
{
|
||||
key: "offering.cover",
|
||||
label: "业务提供项封面",
|
||||
required: true,
|
||||
kind: "image",
|
||||
aspectRatio: "1:1",
|
||||
},
|
||||
{
|
||||
key: "profile.portrait",
|
||||
label: "主理人肖像",
|
||||
required: false,
|
||||
kind: "image",
|
||||
aspectRatio: "1:1",
|
||||
},
|
||||
{ key: "brand.texture", label: "品牌底纹", required: false, kind: "texture" },
|
||||
],
|
||||
dataSlots: [
|
||||
{
|
||||
key: "brand.identity",
|
||||
source: "brand",
|
||||
required: true,
|
||||
description: "品牌名、定位和主理人身份",
|
||||
},
|
||||
{ key: "brand.hero", source: "brand", required: true, description: "品牌首屏表达和行动入口" },
|
||||
{ key: "trust.proof", source: "trust", required: true, description: "经历、资质、案例和方法" },
|
||||
{
|
||||
key: "offerings.list",
|
||||
source: "offering",
|
||||
required: true,
|
||||
description: "可展示的业务提供项",
|
||||
},
|
||||
{
|
||||
key: "offering.detail",
|
||||
source: "offering",
|
||||
required: true,
|
||||
description: "单个提供项的详情内容",
|
||||
},
|
||||
{ key: "inquiry.form", source: "inquiry", required: true, description: "品牌咨询或预约表单" },
|
||||
{
|
||||
key: "records.items",
|
||||
source: "records",
|
||||
required: true,
|
||||
description: "用户提交后的跟进记录",
|
||||
},
|
||||
{
|
||||
key: "profile.contact",
|
||||
source: "profile",
|
||||
required: true,
|
||||
description: "联系方式和合作预期",
|
||||
},
|
||||
],
|
||||
pages: [
|
||||
{
|
||||
key: "home",
|
||||
title: "首页",
|
||||
renderer: "linjing-home",
|
||||
modules: [
|
||||
{
|
||||
key: "identity",
|
||||
type: "brand-identity",
|
||||
variant: "editorial-card",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
assetSlots: ["brand.logo"],
|
||||
},
|
||||
{
|
||||
key: "hero",
|
||||
type: "hero",
|
||||
variant: "architectural",
|
||||
required: true,
|
||||
dataSlots: ["brand.hero"],
|
||||
assetSlots: ["home.hero"],
|
||||
},
|
||||
{
|
||||
key: "proof",
|
||||
type: "trust",
|
||||
variant: "proof-strip",
|
||||
required: true,
|
||||
dataSlots: ["trust.proof"],
|
||||
},
|
||||
{
|
||||
key: "offerings",
|
||||
type: "offering-list",
|
||||
variant: "editorial-list",
|
||||
required: true,
|
||||
dataSlots: ["offerings.list"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
{
|
||||
key: "contact",
|
||||
type: "contact",
|
||||
variant: "quiet-footer",
|
||||
required: true,
|
||||
dataSlots: ["profile.contact"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "offerings",
|
||||
title: "业务提供项",
|
||||
renderer: "linjing-offerings",
|
||||
modules: [
|
||||
{
|
||||
key: "offerings",
|
||||
type: "offering-list",
|
||||
variant: "editorial-grid",
|
||||
required: true,
|
||||
dataSlots: ["offerings.list"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "detail",
|
||||
title: "提供项详情",
|
||||
renderer: "linjing-offering-detail",
|
||||
modules: [
|
||||
{
|
||||
key: "detail",
|
||||
type: "offering-detail",
|
||||
variant: "project-case",
|
||||
required: true,
|
||||
dataSlots: ["offering.detail"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "inquiry",
|
||||
title: "咨询与预约",
|
||||
renderer: "linjing-inquiry",
|
||||
modules: [
|
||||
{
|
||||
key: "inquiry",
|
||||
type: "inquiry-form",
|
||||
variant: "editorial-form",
|
||||
required: true,
|
||||
dataSlots: ["inquiry.form"],
|
||||
capability: "inquiry",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "success",
|
||||
title: "提交成功",
|
||||
renderer: "linjing-success",
|
||||
modules: [
|
||||
{
|
||||
key: "success",
|
||||
type: "success-summary",
|
||||
variant: "editorial-confirmation",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "records",
|
||||
title: "我的记录",
|
||||
renderer: "linjing-records",
|
||||
modules: [
|
||||
{
|
||||
key: "records",
|
||||
type: "records-list",
|
||||
variant: "timeline",
|
||||
required: true,
|
||||
dataSlots: ["records.items"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "profile",
|
||||
title: "主理人与我",
|
||||
renderer: "linjing-profile",
|
||||
modules: [
|
||||
{
|
||||
key: "identity",
|
||||
type: "brand-identity",
|
||||
variant: "profile-editorial",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
assetSlots: ["profile.portrait"],
|
||||
},
|
||||
{
|
||||
key: "contact",
|
||||
type: "contact",
|
||||
variant: "contact-sheet",
|
||||
required: true,
|
||||
dataSlots: ["profile.contact"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
capabilities: ["offerings", "inquiry"],
|
||||
};
|
||||
|
||||
export const visualTemplateManifests: Record<VisualTemplateKey, VisualTemplateManifest> = {
|
||||
"linjing-editorial": linjingEditorialManifest,
|
||||
"acheng-campus-food": {
|
||||
...linjingEditorialManifest,
|
||||
key: "acheng-campus-food",
|
||||
version: "1.0.0",
|
||||
name: "阿成校园餐",
|
||||
description: "面向校园餐饮摊贩的菜单、出摊动态和团体预订视觉模板。",
|
||||
supportedIndustryTemplates: ["food"],
|
||||
tokens: {
|
||||
...linjingEditorialManifest.tokens,
|
||||
colors: {
|
||||
background: "#FFF8F0",
|
||||
surface: "#FFFFFF",
|
||||
foreground: "#29231F",
|
||||
muted: "#7A6A60",
|
||||
accent: "#E87532",
|
||||
dark: "#3B2118",
|
||||
},
|
||||
radius: { card: "24rpx", button: "999rpx", media: "20rpx" },
|
||||
},
|
||||
pages: linjingEditorialManifest.pages.map((pageDefinition) => {
|
||||
const renderer =
|
||||
pageDefinition.key === "home"
|
||||
? "acheng-home"
|
||||
: pageDefinition.key === "offerings"
|
||||
? "acheng-offerings"
|
||||
: pageDefinition.key === "profile"
|
||||
? "acheng-profile"
|
||||
: pageDefinition.renderer;
|
||||
return renderer ? { ...pageDefinition, renderer } : pageDefinition;
|
||||
}),
|
||||
capabilities: ["offerings", "inquiry", "booking"],
|
||||
},
|
||||
};
|
||||
|
||||
export function getVisualTemplateManifest(key: string): VisualTemplateManifest | undefined {
|
||||
return visualTemplateManifests[key as VisualTemplateKey];
|
||||
}
|
||||
|
||||
export function isVisualTemplateCompatible(
|
||||
visualTemplate: VisualTemplateDefinition | VisualTemplateManifest,
|
||||
industryTemplateKey: string,
|
||||
): boolean {
|
||||
return visualTemplate.supportedIndustryTemplates.includes(
|
||||
industryTemplateKey as BrandTemplateKey,
|
||||
);
|
||||
}
|
||||
|
||||
export const visualTemplates: Record<VisualTemplateKey, VisualTemplateDefinition> = {
|
||||
"linjing-editorial": {
|
||||
key: "linjing-editorial",
|
||||
version: "1.0.0",
|
||||
name: "林境建筑画册",
|
||||
description: "适合高端定制、建筑作品和项目型个人品牌。",
|
||||
supportedIndustryTemplates: ["personal", "doors"],
|
||||
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"],
|
||||
},
|
||||
},
|
||||
"acheng-campus-food": {
|
||||
key: "acheng-campus-food",
|
||||
version: "1.0.0",
|
||||
name: "阿成校园餐",
|
||||
description: "适合校园餐饮、套餐预订和团体定制的暖橙菜单视觉。",
|
||||
supportedIndustryTemplates: ["food"],
|
||||
variants: { hero: "stall-board", offeringList: "menu-card", detail: "dish-detail" },
|
||||
theme: {
|
||||
colors: { background: "#FFF8F0", foreground: "#29231F", accent: "#E87532", dark: "#3B2118" },
|
||||
radius: { card: "24rpx" },
|
||||
},
|
||||
layout: {
|
||||
home: ["founder-card", "brand-hero", "trust-proof", "offering-list"],
|
||||
offerings: ["offering-list"],
|
||||
detail: ["offering-detail"],
|
||||
profile: ["profile"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export function listVisualTemplateKeys(): VisualTemplateKey[] {
|
||||
return Object.keys(visualTemplates) as VisualTemplateKey[];
|
||||
}
|
||||
|
||||
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
|
||||
return visualTemplates[key as VisualTemplateKey];
|
||||
}
|
||||
|
||||
export function getDefaultVisualTemplateKey(industryTemplateKey: string): VisualTemplateKey {
|
||||
return (
|
||||
listVisualTemplateKeys().find((key) =>
|
||||
visualTemplates[key].supportedIndustryTemplates.includes(
|
||||
industryTemplateKey as BrandTemplateKey,
|
||||
),
|
||||
) ?? "linjing-editorial"
|
||||
);
|
||||
}
|
||||
|
||||
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"],
|
||||
},
|
||||
doors: {
|
||||
key: "doors",
|
||||
version: "1.0.0",
|
||||
name: "高端门窗模板",
|
||||
description: "适用于别墅门、院门、室内门与定制门窗服务的行业模板。",
|
||||
serviceCategories: ["entrance-door", "garden-door", "interior-door", "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"],
|
||||
},
|
||||
} 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;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export type BrandTemplateKey = "personal" | "food" | "doors";
|
||||
export type VisualTemplateKey = "linjing-editorial" | "acheng-campus-food";
|
||||
export type CapabilityKey = "offerings" | "inquiry" | "booking" | "quote-request";
|
||||
@@ -0,0 +1,108 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import type { CapabilityKey } from "./template-keys.js";
|
||||
import type { VisualTemplateKey } from "./template-keys.js";
|
||||
import type { TemplateSampleContent } from "./template-sample-content.js";
|
||||
|
||||
export interface TemplatePackageManifest {
|
||||
packageKey: string;
|
||||
version: string;
|
||||
displayName: string;
|
||||
visualTemplateKey: VisualTemplateKey;
|
||||
runtimeContract: "1.0";
|
||||
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;
|
||||
}[];
|
||||
templateFields?: readonly {
|
||||
key: string;
|
||||
page?: string;
|
||||
binding?: string;
|
||||
label: string;
|
||||
help?: string;
|
||||
input: string;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
required?: boolean;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
options?: readonly { value: string; label: 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;
|
||||
page: string;
|
||||
target: "brand" | "offering" | "trust" | "inquiry";
|
||||
previewTargets?: readonly {
|
||||
key: string;
|
||||
label: string;
|
||||
composite?: boolean;
|
||||
children?: readonly string[];
|
||||
}[];
|
||||
fields: readonly {
|
||||
key: string;
|
||||
binding: string;
|
||||
label: string;
|
||||
input: string;
|
||||
help?: string;
|
||||
required?: boolean;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
options?: readonly { value: string; label: string }[];
|
||||
previewTarget?: string;
|
||||
}[];
|
||||
}[];
|
||||
};
|
||||
trustContentTypes?: readonly {
|
||||
type: string;
|
||||
label: string;
|
||||
adminFields: {
|
||||
title: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
summaryHelp?: string;
|
||||
summaryPlaceholder?: string;
|
||||
};
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
maxPublishedItems?: number;
|
||||
hideStandardFields?: readonly ("summary" | "content")[];
|
||||
configFields?: readonly {
|
||||
key: string;
|
||||
binding: string;
|
||||
label: string;
|
||||
input: string;
|
||||
itemFields?: readonly { key: string; label: string; input?: string; required?: boolean }[];
|
||||
itemValueKey?: string;
|
||||
required?: boolean;
|
||||
}[];
|
||||
}[];
|
||||
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { generatedTemplatePackageRegistry } from "./generated-template-packages.js";
|
||||
import type { TemplatePackageManifest } from "./template-package-manifest.js";
|
||||
|
||||
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");
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import { templatePackageRegistry } from "./template-packages.js";
|
||||
|
||||
export interface TemplateSampleContent {
|
||||
templateKey: BrandTemplateKey;
|
||||
inquiryFormName: string;
|
||||
offerings: Array<{
|
||||
kind: "service" | "product" | "package" | "subscription";
|
||||
name: string;
|
||||
summary: string;
|
||||
categoryKey: string;
|
||||
}>;
|
||||
trustContent: Array<{
|
||||
type: string;
|
||||
title: string;
|
||||
content: string;
|
||||
summary?: string;
|
||||
config?: Record<string, unknown>;
|
||||
}>;
|
||||
fields: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
type: string;
|
||||
required: boolean;
|
||||
options?: Array<{ label: string; value: string }>;
|
||||
}>;
|
||||
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",
|
||||
},
|
||||
{
|
||||
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: Record<BrandTemplateKey, TemplateSampleContent> = {
|
||||
personal: personalSampleContent,
|
||||
food: foodSampleContent,
|
||||
doors: doorsSampleContent,
|
||||
};
|
||||
|
||||
export function getTemplateSampleContent(templateKey: string): TemplateSampleContent | undefined {
|
||||
const packageSample = templatePackageRegistry.find((item) =>
|
||||
item.supportedIndustryTemplates.includes(templateKey as BrandTemplateKey),
|
||||
)?.sampleContent?.[templateKey as BrandTemplateKey];
|
||||
return packageSample ?? templateSampleContent[templateKey as keyof typeof templateSampleContent];
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import type { VisualTemplateKey } from "./template-keys.js";
|
||||
import type { VisualTemplateDefinition, VisualTemplateManifest } from "./brand-contracts.js";
|
||||
|
||||
const linjingEditorialManifest: VisualTemplateManifest = {
|
||||
schemaVersion: "1.0",
|
||||
key: "linjing-editorial",
|
||||
version: "1.0.0",
|
||||
name: "林境建筑画册",
|
||||
description: "以个人品牌信任为主线、以高端项目作品为表达重点的编辑式视觉模板。",
|
||||
supportedIndustryTemplates: ["personal", "doors"],
|
||||
brandFirst: true,
|
||||
tokens: {
|
||||
colors: {
|
||||
background: "#F7F5F1",
|
||||
surface: "#FFFFFF",
|
||||
foreground: "#252525",
|
||||
muted: "#77736C",
|
||||
accent: "#8A6846",
|
||||
dark: "#202221",
|
||||
},
|
||||
spacing: { page: "32rpx", section: "56rpx", module: "24rpx" },
|
||||
typography: { display: "56rpx", heading: "36rpx", body: "28rpx", caption: "22rpx" },
|
||||
radius: { card: "16rpx", button: "999rpx", media: "12rpx" },
|
||||
shadows: { card: "0 8rpx 32rpx rgba(32,34,33,0.08)" },
|
||||
},
|
||||
assets: [
|
||||
{ key: "brand.logo", label: "品牌标志", required: false, kind: "logo" },
|
||||
{
|
||||
key: "home.hero",
|
||||
label: "首页首屏图",
|
||||
required: true,
|
||||
kind: "image",
|
||||
aspectRatio: "16:9",
|
||||
},
|
||||
{
|
||||
key: "offering.cover",
|
||||
label: "业务提供项封面",
|
||||
required: true,
|
||||
kind: "image",
|
||||
aspectRatio: "1:1",
|
||||
},
|
||||
{
|
||||
key: "profile.portrait",
|
||||
label: "主理人肖像",
|
||||
required: false,
|
||||
kind: "image",
|
||||
aspectRatio: "1:1",
|
||||
},
|
||||
{ key: "brand.texture", label: "品牌底纹", required: false, kind: "texture" },
|
||||
],
|
||||
dataSlots: [
|
||||
{
|
||||
key: "brand.identity",
|
||||
source: "brand",
|
||||
required: true,
|
||||
description: "品牌名、定位和主理人身份",
|
||||
},
|
||||
{ key: "brand.hero", source: "brand", required: true, description: "品牌首屏表达和行动入口" },
|
||||
{ key: "trust.proof", source: "trust", required: true, description: "经历、资质、案例和方法" },
|
||||
{
|
||||
key: "offerings.list",
|
||||
source: "offering",
|
||||
required: true,
|
||||
description: "可展示的业务提供项",
|
||||
},
|
||||
{
|
||||
key: "offering.detail",
|
||||
source: "offering",
|
||||
required: true,
|
||||
description: "单个提供项的详情内容",
|
||||
},
|
||||
{ key: "inquiry.form", source: "inquiry", required: true, description: "品牌咨询或预约表单" },
|
||||
{
|
||||
key: "records.items",
|
||||
source: "records",
|
||||
required: true,
|
||||
description: "用户提交后的跟进记录",
|
||||
},
|
||||
{
|
||||
key: "profile.contact",
|
||||
source: "profile",
|
||||
required: true,
|
||||
description: "联系方式和合作预期",
|
||||
},
|
||||
],
|
||||
pages: [
|
||||
{
|
||||
key: "home",
|
||||
title: "首页",
|
||||
renderer: "linjing-home",
|
||||
modules: [
|
||||
{
|
||||
key: "identity",
|
||||
type: "brand-identity",
|
||||
variant: "editorial-card",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
assetSlots: ["brand.logo"],
|
||||
},
|
||||
{
|
||||
key: "hero",
|
||||
type: "hero",
|
||||
variant: "architectural",
|
||||
required: true,
|
||||
dataSlots: ["brand.hero"],
|
||||
assetSlots: ["home.hero"],
|
||||
},
|
||||
{
|
||||
key: "proof",
|
||||
type: "trust",
|
||||
variant: "proof-strip",
|
||||
required: true,
|
||||
dataSlots: ["trust.proof"],
|
||||
},
|
||||
{
|
||||
key: "offerings",
|
||||
type: "offering-list",
|
||||
variant: "editorial-list",
|
||||
required: true,
|
||||
dataSlots: ["offerings.list"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
{
|
||||
key: "contact",
|
||||
type: "contact",
|
||||
variant: "quiet-footer",
|
||||
required: true,
|
||||
dataSlots: ["profile.contact"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "offerings",
|
||||
title: "业务提供项",
|
||||
renderer: "linjing-offerings",
|
||||
modules: [
|
||||
{
|
||||
key: "offerings",
|
||||
type: "offering-list",
|
||||
variant: "editorial-grid",
|
||||
required: true,
|
||||
dataSlots: ["offerings.list"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "detail",
|
||||
title: "提供项详情",
|
||||
renderer: "linjing-offering-detail",
|
||||
modules: [
|
||||
{
|
||||
key: "detail",
|
||||
type: "offering-detail",
|
||||
variant: "project-case",
|
||||
required: true,
|
||||
dataSlots: ["offering.detail"],
|
||||
assetSlots: ["offering.cover"],
|
||||
capability: "offerings",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "inquiry",
|
||||
title: "咨询与预约",
|
||||
renderer: "linjing-inquiry",
|
||||
modules: [
|
||||
{
|
||||
key: "inquiry",
|
||||
type: "inquiry-form",
|
||||
variant: "editorial-form",
|
||||
required: true,
|
||||
dataSlots: ["inquiry.form"],
|
||||
capability: "inquiry",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "success",
|
||||
title: "提交成功",
|
||||
renderer: "linjing-success",
|
||||
modules: [
|
||||
{
|
||||
key: "success",
|
||||
type: "success-summary",
|
||||
variant: "editorial-confirmation",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "records",
|
||||
title: "我的记录",
|
||||
renderer: "linjing-records",
|
||||
modules: [
|
||||
{
|
||||
key: "records",
|
||||
type: "records-list",
|
||||
variant: "timeline",
|
||||
required: true,
|
||||
dataSlots: ["records.items"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "profile",
|
||||
title: "主理人与我",
|
||||
renderer: "linjing-profile",
|
||||
modules: [
|
||||
{
|
||||
key: "identity",
|
||||
type: "brand-identity",
|
||||
variant: "profile-editorial",
|
||||
required: true,
|
||||
dataSlots: ["brand.identity"],
|
||||
assetSlots: ["profile.portrait"],
|
||||
},
|
||||
{
|
||||
key: "contact",
|
||||
type: "contact",
|
||||
variant: "contact-sheet",
|
||||
required: true,
|
||||
dataSlots: ["profile.contact"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
capabilities: ["offerings", "inquiry"],
|
||||
};
|
||||
|
||||
export const visualTemplateManifests: Record<VisualTemplateKey, VisualTemplateManifest> = {
|
||||
"linjing-editorial": linjingEditorialManifest,
|
||||
"acheng-campus-food": {
|
||||
...linjingEditorialManifest,
|
||||
key: "acheng-campus-food",
|
||||
version: "1.0.0",
|
||||
name: "阿成校园餐",
|
||||
description: "面向校园餐饮摊贩的菜单、出摊动态和团体预订视觉模板。",
|
||||
supportedIndustryTemplates: ["food"],
|
||||
tokens: {
|
||||
...linjingEditorialManifest.tokens,
|
||||
colors: {
|
||||
background: "#FFF8F0",
|
||||
surface: "#FFFFFF",
|
||||
foreground: "#29231F",
|
||||
muted: "#7A6A60",
|
||||
accent: "#E87532",
|
||||
dark: "#3B2118",
|
||||
},
|
||||
radius: { card: "24rpx", button: "999rpx", media: "20rpx" },
|
||||
},
|
||||
pages: linjingEditorialManifest.pages.map((pageDefinition) => {
|
||||
const renderer =
|
||||
pageDefinition.key === "home"
|
||||
? "acheng-home"
|
||||
: pageDefinition.key === "offerings"
|
||||
? "acheng-offerings"
|
||||
: pageDefinition.key === "profile"
|
||||
? "acheng-profile"
|
||||
: pageDefinition.renderer;
|
||||
return renderer ? { ...pageDefinition, renderer } : pageDefinition;
|
||||
}),
|
||||
capabilities: ["offerings", "inquiry", "booking"],
|
||||
},
|
||||
};
|
||||
|
||||
export function getVisualTemplateManifest(key: string): VisualTemplateManifest | undefined {
|
||||
return visualTemplateManifests[key as VisualTemplateKey];
|
||||
}
|
||||
|
||||
export function isVisualTemplateCompatible(
|
||||
visualTemplate: VisualTemplateDefinition | VisualTemplateManifest,
|
||||
industryTemplateKey: string,
|
||||
): boolean {
|
||||
return visualTemplate.supportedIndustryTemplates.includes(
|
||||
industryTemplateKey as BrandTemplateKey,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { BrandTemplateKey } from "./template-keys.js";
|
||||
import type { VisualTemplateKey } from "./template-keys.js";
|
||||
import type { VisualTemplateDefinition } from "./brand-contracts.js";
|
||||
|
||||
export const visualTemplates: Record<VisualTemplateKey, VisualTemplateDefinition> = {
|
||||
"linjing-editorial": {
|
||||
key: "linjing-editorial",
|
||||
version: "1.0.0",
|
||||
name: "林境建筑画册",
|
||||
description: "适合高端定制、建筑作品和项目型个人品牌。",
|
||||
supportedIndustryTemplates: ["personal", "doors"],
|
||||
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"],
|
||||
},
|
||||
},
|
||||
"acheng-campus-food": {
|
||||
key: "acheng-campus-food",
|
||||
version: "1.0.0",
|
||||
name: "阿成校园餐",
|
||||
description: "适合校园餐饮、套餐预订和团体定制的暖橙菜单视觉。",
|
||||
supportedIndustryTemplates: ["food"],
|
||||
variants: { hero: "stall-board", offeringList: "menu-card", detail: "dish-detail" },
|
||||
theme: {
|
||||
colors: { background: "#FFF8F0", foreground: "#29231F", accent: "#E87532", dark: "#3B2118" },
|
||||
radius: { card: "24rpx" },
|
||||
},
|
||||
layout: {
|
||||
home: ["founder-card", "brand-hero", "trust-proof", "offering-list"],
|
||||
offerings: ["offering-list"],
|
||||
detail: ["offering-detail"],
|
||||
profile: ["profile"],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export function listVisualTemplateKeys(): VisualTemplateKey[] {
|
||||
return Object.keys(visualTemplates) as VisualTemplateKey[];
|
||||
}
|
||||
|
||||
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
|
||||
return visualTemplates[key as VisualTemplateKey];
|
||||
}
|
||||
|
||||
export function getDefaultVisualTemplateKey(industryTemplateKey: string): VisualTemplateKey {
|
||||
return (
|
||||
listVisualTemplateKeys().find((key) =>
|
||||
visualTemplates[key].supportedIndustryTemplates.includes(
|
||||
industryTemplateKey as BrandTemplateKey,
|
||||
),
|
||||
) ?? "linjing-editorial"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { WorkflowDefinition } from "./capability-contracts.js";
|
||||
import type { CapabilityDefinition } from "./capability-contracts.js";
|
||||
import { capabilityRegistry, workflowRegistry } from "./capability-contracts.js";
|
||||
import type { CapabilityKey } from "./template-keys.js";
|
||||
|
||||
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]);
|
||||
}
|
||||
Reference in new issue
Block a user