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

+42 -1
View File
@@ -59,6 +59,40 @@ export type BrandPresentationUpdate = Partial<
Record<string, string>
>
>;
export interface TemplateAdminField {
key: string;
binding: string;
label: string;
help?: string;
input: "text" | "textarea" | "phone" | "image" | "number";
required?: boolean;
maxLength?: number;
placeholder?: string;
}
export interface TemplateAdminSection {
key: string;
title: string;
description: string;
target: "brand" | "offering" | "trust" | "inquiry";
fields: TemplateAdminField[];
}
export interface AdminTemplateContent {
displayName: string;
admin: { sections: TemplateAdminSection[] };
assetSlots: Array<{
key: string;
binding: string;
target: "brand" | "offering" | "trust";
label: string;
help: string;
required: boolean;
kind: "image" | "logo" | "portrait" | "texture";
aspectRatio?: string;
}>;
}
export interface OfferingUpdate {
name?: string;
description?: string;
@@ -630,6 +664,7 @@ export class ApiClient {
fields: BrandFieldDefinition[];
offerings: Offering[];
forms: unknown[];
templateContent: AdminTemplateContent | null;
}> {
return this.request("/admin/workspace");
}
@@ -638,7 +673,13 @@ export class ApiClient {
}
getAdminReleaseReadiness(): Promise<{
ready: boolean;
checks: Array<{ key: string; label: string; passed: boolean }>;
checks: Array<{
key: string;
label: string;
passed: boolean;
help?: string;
destination?: string;
}>;
}> {
return this.request("/admin/releases/readiness");
}
+3
View File
@@ -0,0 +1,3 @@
import type { TemplatePackageManifest } from "./index.js";
export declare const generatedTemplatePackageRegistry: readonly TemplatePackageManifest[];
export declare const generatedTemplatePackageRegistryHash: string;
@@ -0,0 +1,615 @@
// prettier-ignore
export const generatedTemplatePackageRegistry = [
{
"packageKey": "acheng-campus-food",
"version": "1.0.0",
"displayName": "阿成校园餐",
"defaultBrandSlug": "default-brand",
"runtimeContract": "1.0",
"supportedIndustryTemplates": [
"food"
],
"entrypoints": {
"home": "pages/index/index",
"offerings": "pages/services/index",
"service": "pages/stall-service/index",
"detail": "pages/offering/detail",
"inquiry": "pages/inquiry/index",
"success": "pages/inquiry-success/index",
"records": "pages/records/index",
"profile": "pages/bookings/index"
},
"navigation": [
{
"key": "home",
"label": "首页/摊位",
"page": "home",
"iconPath": "assets/tab/home.png",
"selectedIconPath": "assets/tab/home-selected.png"
},
{
"key": "dishes",
"label": "套餐餐品",
"page": "offerings",
"iconPath": "assets/tab/dishes.png",
"selectedIconPath": "assets/tab/dishes-selected.png"
},
{
"key": "service",
"label": "出摊服务",
"page": "service",
"iconPath": "assets/tab/service.png",
"selectedIconPath": "assets/tab/service-selected.png"
},
{
"key": "owner",
"label": "主理人",
"page": "profile",
"iconPath": "assets/tab/owner.png",
"selectedIconPath": "assets/tab/owner-selected.png"
},
{
"key": "booking",
"label": "定制/咨询",
"page": "inquiry",
"iconPath": "assets/tab/booking.png",
"selectedIconPath": "assets/tab/booking-selected.png"
}
],
"requiredCapabilities": [
"offerings",
"inquiry",
"booking"
],
"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": "访客自己的预订记录"
}
],
"assetSlots": [
{
"key": "brand.portrait",
"binding": "brand.avatarUrl",
"target": "brand",
"label": "主理人照片",
"help": "用于首页和主理人页,建议使用清晰正面照片。",
"required": false,
"kind": "portrait",
"aspectRatio": "1:1"
},
{
"key": "brand.stallHero",
"binding": "brand.config.heroImage",
"target": "brand",
"label": "出摊现场主图",
"help": "展示真实摊位、餐品或取餐场景,避免使用无关的通用图片。",
"required": true,
"kind": "image",
"aspectRatio": "16:9"
},
{
"key": "offering.cover",
"binding": "offering.coverUrl",
"target": "offering",
"label": "餐品或服务封面",
"help": "每项餐品或服务使用一张清晰图片,方便访客快速选择。",
"required": true,
"kind": "image",
"aspectRatio": "1:1"
}
],
"admin": {
"sections": [
{
"key": "identity",
"title": "摊位与主理人",
"description": "让访客知道谁在出餐、在哪里可以找到你。",
"target": "brand",
"fields": [
{
"key": "founder",
"binding": "brand.config.founder",
"label": "主理人姓名",
"input": "text",
"required": true,
"placeholder": "例如:阿成"
},
{
"key": "portrait",
"binding": "brand.config.avatarUrl",
"label": "主理人照片",
"help": "使用清晰、真实的照片,让顾客知道是谁在认真做餐。",
"input": "image"
},
{
"key": "title",
"binding": "brand.config.title",
"label": "你的身份",
"help": "例如:校园餐饮主理人。",
"input": "text",
"required": true
},
{
"key": "slogan",
"binding": "brand.config.slogan",
"label": "想对顾客说的一句话",
"input": "textarea",
"maxLength": 80
},
{
"key": "studioAddress",
"binding": "brand.config.studioAddress",
"label": "出摊地点或服务范围",
"input": "text",
"required": true
},
{
"key": "phone",
"binding": "brand.config.phone",
"label": "公开联系电话",
"input": "phone"
},
{
"key": "wechat",
"binding": "brand.config.wechat",
"label": "公开微信号",
"input": "text"
}
]
},
{
"key": "home",
"title": "首页出摊信息",
"description": "说明今天在哪里、何时营业,以及餐品有什么特点。",
"target": "brand",
"fields": [
{
"key": "stallTitle",
"binding": "brand.config.visualPresentation.home.stallTitle",
"label": "出摊信息标题",
"input": "text",
"placeholder": "例如:今日出摊点"
},
{
"key": "heroImage",
"binding": "brand.config.heroImage",
"label": "出摊现场主图",
"help": "展示真实摊位、餐品或取餐场景,建议使用横向图片。",
"input": "image",
"required": true
},
{
"key": "stallTime",
"binding": "brand.config.visualPresentation.home.stallTime",
"label": "营业时间说明",
"input": "text",
"placeholder": "例如:17:00 - 22:30 · 今日营业中"
},
{
"key": "worksTitle",
"binding": "brand.config.visualPresentation.home.worksTitle",
"label": "招牌餐品标题",
"input": "text"
},
{
"key": "manifestoTitle",
"binding": "brand.config.visualPresentation.home.manifestoTitle",
"label": "出餐承诺标题",
"input": "text"
}
]
},
{
"key": "menu",
"title": "菜单页说明",
"description": "帮助顾客理解日常餐品和团体定制的选择方式。",
"target": "brand",
"fields": [
{
"key": "title",
"binding": "brand.config.visualPresentation.offerings.title",
"label": "菜单页标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.offerings.subtitle",
"label": "菜单页说明",
"input": "textarea",
"maxLength": 120
}
]
},
{
"key": "booking",
"title": "预订与定制",
"description": "告诉顾客提交信息后会如何确认餐品和时间。",
"target": "inquiry",
"fields": [
{
"key": "title",
"binding": "brand.config.visualPresentation.inquiry.title",
"label": "预订页面标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.inquiry.subtitle",
"label": "预订说明",
"input": "textarea",
"maxLength": 120
},
{
"key": "submitLabel",
"binding": "brand.config.visualPresentation.inquiry.submitLabel",
"label": "提交按钮文字",
"input": "text",
"placeholder": "例如:提交预订需求"
}
]
}
]
},
"renderers": {
"home": "acheng-home",
"offerings": "acheng-offerings",
"profile": "acheng-profile"
},
"runtimeOwnedPages": [
"detail",
"inquiry",
"success",
"records"
],
"ownedPaths": [
"components/templates/acheng-home",
"components/templates/acheng-offerings",
"components/templates/acheng-profile",
"pages/index",
"pages/services",
"pages/bookings",
"pages/inquiry",
"pages/stall-service",
"pages/offering",
"pages/inquiry-success",
"pages/records"
],
"visualTemplateKey": "acheng-campus-food"
},
{
"packageKey": "linjing-editorial",
"version": "1.0.0",
"displayName": "林境建筑画册",
"defaultBrandSlug": "linjing-doors",
"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"
},
"navigation": [
{
"key": "home",
"label": "首页",
"page": "home",
"iconPath": "assets/tab/home.png",
"selectedIconPath": "assets/tab/home-selected.png"
},
{
"key": "offerings",
"label": "案例与体系",
"page": "offerings",
"iconPath": "assets/tab/works.png",
"selectedIconPath": "assets/tab/works-selected.png"
},
{
"key": "profile",
"label": "主理人与我",
"page": "profile",
"iconPath": "assets/tab/profile.png",
"selectedIconPath": "assets/tab/profile-selected.png"
}
],
"requiredCapabilities": [
"offerings",
"inquiry"
],
"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": "访客自己的咨询记录"
}
],
"assetSlots": [
{
"key": "brand.portrait",
"binding": "brand.avatarUrl",
"target": "brand",
"label": "主理人肖像",
"help": "用于主理人与我页面,建议使用正式、清晰的照片。",
"required": false,
"kind": "portrait",
"aspectRatio": "1:1"
},
{
"key": "brand.projectHero",
"binding": "brand.config.heroImage",
"target": "brand",
"label": "首页项目主图",
"help": "展示真实别墅、入户门或空间细节,体现品牌审美和项目能力。",
"required": true,
"kind": "image",
"aspectRatio": "16:9"
},
{
"key": "offering.cover",
"binding": "offering.coverUrl",
"target": "offering",
"label": "案例封面",
"help": "每个案例使用一张项目实拍或可信效果图。",
"required": true,
"kind": "image",
"aspectRatio": "4:3"
}
],
"admin": {
"sections": [
{
"key": "identity",
"title": "主理人与联系方式",
"description": "让业主清楚谁负责项目,以及如何联系你。",
"target": "brand",
"fields": [
{
"key": "founder",
"binding": "brand.config.founder",
"label": "主理人姓名",
"input": "text",
"required": true
},
{
"key": "portrait",
"binding": "brand.config.avatarUrl",
"label": "主理人肖像",
"help": "建议使用正式、清晰的个人照片。",
"input": "image"
},
{
"key": "title",
"binding": "brand.config.title",
"label": "身份或职位",
"input": "text",
"required": true,
"placeholder": "例如:别墅门系统主理人"
},
{
"key": "slogan",
"binding": "brand.config.slogan",
"label": "主理人主张",
"input": "textarea",
"maxLength": 100
},
{
"key": "studioAddress",
"binding": "brand.config.studioAddress",
"label": "服务区域或工作室地址",
"input": "text",
"required": true
},
{
"key": "phone",
"binding": "brand.config.phone",
"label": "公开联系电话",
"input": "phone"
},
{
"key": "wechat",
"binding": "brand.config.wechat",
"label": "公开微信号",
"input": "text"
}
]
},
{
"key": "home",
"title": "首页品牌表达",
"description": "用简洁的语言解释你的项目方法、代表作品和合作流程。",
"target": "brand",
"fields": [
{
"key": "founderBadge",
"binding": "brand.config.visualPresentation.home.founderBadge",
"label": "主理人标签",
"input": "text",
"placeholder": "例如:亲自主理 / 10 年经验"
},
{
"key": "heroImage",
"binding": "brand.config.heroImage",
"label": "首页项目主图",
"help": "展示真实别墅、入户门或空间细节,体现项目能力。",
"input": "image",
"required": true
},
{
"key": "proofTitle",
"binding": "brand.config.visualPresentation.home.proofTitle",
"label": "信任介绍标题",
"input": "text"
},
{
"key": "worksTitle",
"binding": "brand.config.visualPresentation.home.worksTitle",
"label": "代表案例标题",
"input": "text"
},
{
"key": "flowTitle",
"binding": "brand.config.visualPresentation.home.flowTitle",
"label": "项目流程标题",
"input": "text"
}
]
},
{
"key": "cases",
"title": "案例与体系",
"description": "说明案例页展示的内容,让业主能快速找到相近项目。",
"target": "offering",
"fields": [
{
"key": "worksEyebrow",
"binding": "brand.config.visualPresentation.offerings.worksEyebrow",
"label": "案例页辅助标题",
"input": "text"
},
{
"key": "worksTitle",
"binding": "brand.config.visualPresentation.offerings.worksTitle",
"label": "案例页主标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.offerings.subtitle",
"label": "案例页说明",
"input": "textarea",
"maxLength": 140
}
]
},
{
"key": "consultation",
"title": "咨询说明",
"description": "明确访客提交后会得到怎样的回应,减少无效咨询。",
"target": "inquiry",
"fields": [
{
"key": "title",
"binding": "brand.config.visualPresentation.inquiry.title",
"label": "咨询页面标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.inquiry.subtitle",
"label": "咨询说明",
"input": "textarea",
"maxLength": 140
},
{
"key": "submitLabel",
"binding": "brand.config.visualPresentation.inquiry.submitLabel",
"label": "提交按钮文字",
"input": "text"
}
]
}
]
},
"renderers": {
"home": "linjing-home",
"offerings": "linjing-offerings",
"profile": "linjing-profile"
},
"runtimeOwnedPages": [
"detail",
"inquiry",
"success",
"records"
],
"ownedPaths": [
"components/templates/linjing-home",
"components/templates/linjing-offerings",
"components/templates/linjing-profile"
],
"visualTemplateKey": "linjing-editorial"
}
];
export const generatedTemplatePackageRegistryHash =
"ff79864f3873fe627710c092622abd26212a8c25ab52c422ee4e22e95f4d2d73";
+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");
@@ -53,6 +53,234 @@
}
],
"requiredCapabilities": ["offerings", "inquiry", "booking"],
"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": "访客自己的预订记录"
}
],
"assetSlots": [
{
"key": "brand.portrait",
"binding": "brand.avatarUrl",
"target": "brand",
"label": "主理人照片",
"help": "用于首页和主理人页,建议使用清晰正面照片。",
"required": false,
"kind": "portrait",
"aspectRatio": "1:1"
},
{
"key": "brand.stallHero",
"binding": "brand.config.heroImage",
"target": "brand",
"label": "出摊现场主图",
"help": "展示真实摊位、餐品或取餐场景,避免使用无关的通用图片。",
"required": true,
"kind": "image",
"aspectRatio": "16:9"
},
{
"key": "offering.cover",
"binding": "offering.coverUrl",
"target": "offering",
"label": "餐品或服务封面",
"help": "每项餐品或服务使用一张清晰图片,方便访客快速选择。",
"required": true,
"kind": "image",
"aspectRatio": "1:1"
}
],
"admin": {
"sections": [
{
"key": "identity",
"title": "摊位与主理人",
"description": "让访客知道谁在出餐、在哪里可以找到你。",
"target": "brand",
"fields": [
{
"key": "founder",
"binding": "brand.config.founder",
"label": "主理人姓名",
"input": "text",
"required": true,
"placeholder": "例如:阿成"
},
{
"key": "portrait",
"binding": "brand.config.avatarUrl",
"label": "主理人照片",
"help": "使用清晰、真实的照片,让顾客知道是谁在认真做餐。",
"input": "image"
},
{
"key": "title",
"binding": "brand.config.title",
"label": "你的身份",
"help": "例如:校园餐饮主理人。",
"input": "text",
"required": true
},
{
"key": "slogan",
"binding": "brand.config.slogan",
"label": "想对顾客说的一句话",
"input": "textarea",
"maxLength": 80
},
{
"key": "studioAddress",
"binding": "brand.config.studioAddress",
"label": "出摊地点或服务范围",
"input": "text",
"required": true
},
{
"key": "phone",
"binding": "brand.config.phone",
"label": "公开联系电话",
"input": "phone"
},
{
"key": "wechat",
"binding": "brand.config.wechat",
"label": "公开微信号",
"input": "text"
}
]
},
{
"key": "home",
"title": "首页出摊信息",
"description": "说明今天在哪里、何时营业,以及餐品有什么特点。",
"target": "brand",
"fields": [
{
"key": "stallTitle",
"binding": "brand.config.visualPresentation.home.stallTitle",
"label": "出摊信息标题",
"input": "text",
"placeholder": "例如:今日出摊点"
},
{
"key": "heroImage",
"binding": "brand.config.heroImage",
"label": "出摊现场主图",
"help": "展示真实摊位、餐品或取餐场景,建议使用横向图片。",
"input": "image",
"required": true
},
{
"key": "stallTime",
"binding": "brand.config.visualPresentation.home.stallTime",
"label": "营业时间说明",
"input": "text",
"placeholder": "例如:17:00 - 22:30 · 今日营业中"
},
{
"key": "worksTitle",
"binding": "brand.config.visualPresentation.home.worksTitle",
"label": "招牌餐品标题",
"input": "text"
},
{
"key": "manifestoTitle",
"binding": "brand.config.visualPresentation.home.manifestoTitle",
"label": "出餐承诺标题",
"input": "text"
}
]
},
{
"key": "menu",
"title": "菜单页说明",
"description": "帮助顾客理解日常餐品和团体定制的选择方式。",
"target": "brand",
"fields": [
{
"key": "title",
"binding": "brand.config.visualPresentation.offerings.title",
"label": "菜单页标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.offerings.subtitle",
"label": "菜单页说明",
"input": "textarea",
"maxLength": 120
}
]
},
{
"key": "booking",
"title": "预订与定制",
"description": "告诉顾客提交信息后会如何确认餐品和时间。",
"target": "inquiry",
"fields": [
{
"key": "title",
"binding": "brand.config.visualPresentation.inquiry.title",
"label": "预订页面标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.inquiry.subtitle",
"label": "预订说明",
"input": "textarea",
"maxLength": 120
},
{
"key": "submitLabel",
"binding": "brand.config.visualPresentation.inquiry.submitLabel",
"label": "提交按钮文字",
"input": "text",
"placeholder": "例如:提交预订需求"
}
]
}
]
},
"renderers": {
"home": "acheng-home",
"offerings": "acheng-offerings",
+14
View File
@@ -22,6 +22,20 @@ function validateManifest(manifest) {
}
if (!Array.isArray(manifest.navigation) || !manifest.navigation.length)
throw new Error("template.json navigation must not be empty");
if (!Array.isArray(manifest.dataSlots) || !manifest.dataSlots.length)
throw new Error("template.json dataSlots must not be empty");
if (!Array.isArray(manifest.assetSlots))
throw new Error("template.json assetSlots must be an array");
if (!manifest.admin || !Array.isArray(manifest.admin.sections) || !manifest.admin.sections.length)
throw new Error("template.json admin.sections must not be empty");
for (const section of manifest.admin.sections) {
if (!section.key || !section.title || !section.description || !Array.isArray(section.fields))
throw new Error("template.json admin sections require key, title, description and fields");
for (const field of section.fields) {
if (!field.key || !field.binding || !field.label || !field.input)
throw new Error("template.json admin fields require key, binding, label and input");
}
}
if (
manifest.renderers !== undefined &&
(typeof manifest.renderers !== "object" || Array.isArray(manifest.renderers))
+2 -1
View File
@@ -7,6 +7,7 @@
".": "./src/index.ts"
},
"scripts": {
"typecheck": "tsc -p tsconfig.json --noEmit"
"typecheck": "tsc -p tsconfig.json --noEmit",
"test": "node --experimental-strip-types --test test/*.test.mjs"
}
}
+87
View File
@@ -7,6 +7,59 @@ export type TemplateRenderers = Partial<Record<"home" | "offerings" | "profile",
export type TemplateRuntimeOwnedPage = "detail" | "inquiry" | "success" | "records";
/**
* 模板向平台声明的内容来源。它只描述稳定的业务事实,不描述页面结构或 renderer。
*/
export type TemplateContentSource = "brand" | "offering" | "trust" | "inquiry" | "records";
/** 模板需要的小程序数据集合,用于 Runtime 投影和发布前校验。 */
export type TemplateDataSlot = {
key: string;
source: TemplateContentSource;
required: boolean;
description: string;
};
/** 图片、标志等媒体需求;label/help 是给品牌管理员看到的业务语言。 */
export type TemplateAssetSlot = {
key: string;
binding: string;
target: "brand" | "offering" | "trust";
label: string;
help: string;
required: boolean;
kind: "image" | "logo" | "portrait" | "texture";
aspectRatio?: string;
};
/**
* 一个可由普通品牌管理员编辑的字段。
* key 是稳定语义标识,binding 是平台内部的存储映射;两者均不直接展示给用户。
*/
export type TemplateAdminField = {
key: string;
binding: string;
label: string;
help?: string;
input: "text" | "textarea" | "phone" | "image" | "number";
required?: boolean;
maxLength?: number;
placeholder?: string;
};
/** 一个面向业务用户的编辑分组,而不是技术 schema 或 JSON 编辑器。 */
export type TemplateAdminSection = {
key: string;
title: string;
description: string;
target: "brand" | "offering" | "trust" | "inquiry";
fields: TemplateAdminField[];
};
export type TemplateAdminManifest = {
sections: TemplateAdminSection[];
};
export type TemplatePackageManifest = {
packageKey: string;
version: string;
@@ -25,6 +78,9 @@ export type TemplatePackageManifest = {
renderers?: TemplateRenderers;
runtimeOwnedPages?: TemplateRuntimeOwnedPage[];
ownedPaths?: string[];
dataSlots: TemplateDataSlot[];
assetSlots: TemplateAssetSlot[];
admin: TemplateAdminManifest;
};
export function validateTemplatePackageManifest(value: unknown): string[] {
@@ -43,6 +99,37 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
errors.push("supportedIndustryTemplates must not be empty");
if (!Array.isArray(manifest.navigation) || !manifest.navigation.length)
errors.push("navigation must not be empty");
if (!Array.isArray(manifest.dataSlots) || !manifest.dataSlots.length)
errors.push("dataSlots must not be empty");
else {
for (const slot of manifest.dataSlots) {
if (!slot?.key?.trim() || !slot.description?.trim())
errors.push("every data slot requires key and description");
if (!(["brand", "offering", "trust", "inquiry", "records"] as string[]).includes(slot.source))
errors.push("data slot source is invalid");
}
}
if (!Array.isArray(manifest.assetSlots)) errors.push("assetSlots must be an array");
else {
for (const slot of manifest.assetSlots) {
if (!slot?.key?.trim() || !slot.binding?.trim() || !slot.label?.trim() || !slot.help?.trim())
errors.push("every asset slot requires key, binding, label and help");
}
}
if (!manifest.admin || !Array.isArray(manifest.admin.sections) || !manifest.admin.sections.length)
errors.push("admin.sections must not be empty");
else {
for (const section of manifest.admin.sections) {
if (!section?.key?.trim() || !section.title?.trim() || !section.description?.trim())
errors.push("every admin section requires key, title and description");
if (!Array.isArray(section.fields) || !section.fields.length)
errors.push("every admin section must contain fields");
for (const field of section.fields ?? []) {
if (!field?.key?.trim() || !field.binding?.trim() || !field.label?.trim())
errors.push("every admin field requires key, binding and label");
}
}
}
if (manifest.ownedPaths !== undefined && !Array.isArray(manifest.ownedPaths))
errors.push("ownedPaths must be an array when provided");
if (
@@ -0,0 +1,27 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";
import { validateTemplatePackageManifest } from "../src/index.ts";
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
for (const key of ["acheng-campus-food", "linjing-editorial"]) {
test(`${key} declares valid admin content and asset requirements`, () => {
const manifestPath = path.join(packageRoot, `template-${key}`, "template.json");
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
assert.deepEqual(validateTemplatePackageManifest(manifest), []);
});
}
test("template contract rejects technical or incomplete admin declarations", () => {
const manifestPath = path.join(packageRoot, "template-acheng-campus-food/template.json");
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
manifest.admin.sections[0].fields[0].label = "";
manifest.assetSlots[0].help = "";
assert.deepEqual(validateTemplatePackageManifest(manifest), [
"every asset slot requires key, binding, label and help",
"every admin field requires key, binding and label",
]);
});
@@ -38,6 +38,237 @@
}
],
"requiredCapabilities": ["offerings", "inquiry"],
"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": "访客自己的咨询记录"
}
],
"assetSlots": [
{
"key": "brand.portrait",
"binding": "brand.avatarUrl",
"target": "brand",
"label": "主理人肖像",
"help": "用于主理人与我页面,建议使用正式、清晰的照片。",
"required": false,
"kind": "portrait",
"aspectRatio": "1:1"
},
{
"key": "brand.projectHero",
"binding": "brand.config.heroImage",
"target": "brand",
"label": "首页项目主图",
"help": "展示真实别墅、入户门或空间细节,体现品牌审美和项目能力。",
"required": true,
"kind": "image",
"aspectRatio": "16:9"
},
{
"key": "offering.cover",
"binding": "offering.coverUrl",
"target": "offering",
"label": "案例封面",
"help": "每个案例使用一张项目实拍或可信效果图。",
"required": true,
"kind": "image",
"aspectRatio": "4:3"
}
],
"admin": {
"sections": [
{
"key": "identity",
"title": "主理人与联系方式",
"description": "让业主清楚谁负责项目,以及如何联系你。",
"target": "brand",
"fields": [
{
"key": "founder",
"binding": "brand.config.founder",
"label": "主理人姓名",
"input": "text",
"required": true
},
{
"key": "portrait",
"binding": "brand.config.avatarUrl",
"label": "主理人肖像",
"help": "建议使用正式、清晰的个人照片。",
"input": "image"
},
{
"key": "title",
"binding": "brand.config.title",
"label": "身份或职位",
"input": "text",
"required": true,
"placeholder": "例如:别墅门系统主理人"
},
{
"key": "slogan",
"binding": "brand.config.slogan",
"label": "主理人主张",
"input": "textarea",
"maxLength": 100
},
{
"key": "studioAddress",
"binding": "brand.config.studioAddress",
"label": "服务区域或工作室地址",
"input": "text",
"required": true
},
{
"key": "phone",
"binding": "brand.config.phone",
"label": "公开联系电话",
"input": "phone"
},
{
"key": "wechat",
"binding": "brand.config.wechat",
"label": "公开微信号",
"input": "text"
}
]
},
{
"key": "home",
"title": "首页品牌表达",
"description": "用简洁的语言解释你的项目方法、代表作品和合作流程。",
"target": "brand",
"fields": [
{
"key": "founderBadge",
"binding": "brand.config.visualPresentation.home.founderBadge",
"label": "主理人标签",
"input": "text",
"placeholder": "例如:亲自主理 / 10 年经验"
},
{
"key": "heroImage",
"binding": "brand.config.heroImage",
"label": "首页项目主图",
"help": "展示真实别墅、入户门或空间细节,体现项目能力。",
"input": "image",
"required": true
},
{
"key": "proofTitle",
"binding": "brand.config.visualPresentation.home.proofTitle",
"label": "信任介绍标题",
"input": "text"
},
{
"key": "worksTitle",
"binding": "brand.config.visualPresentation.home.worksTitle",
"label": "代表案例标题",
"input": "text"
},
{
"key": "flowTitle",
"binding": "brand.config.visualPresentation.home.flowTitle",
"label": "项目流程标题",
"input": "text"
}
]
},
{
"key": "cases",
"title": "案例与体系",
"description": "说明案例页展示的内容,让业主能快速找到相近项目。",
"target": "offering",
"fields": [
{
"key": "worksEyebrow",
"binding": "brand.config.visualPresentation.offerings.worksEyebrow",
"label": "案例页辅助标题",
"input": "text"
},
{
"key": "worksTitle",
"binding": "brand.config.visualPresentation.offerings.worksTitle",
"label": "案例页主标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.offerings.subtitle",
"label": "案例页说明",
"input": "textarea",
"maxLength": 140
}
]
},
{
"key": "consultation",
"title": "咨询说明",
"description": "明确访客提交后会得到怎样的回应,减少无效咨询。",
"target": "inquiry",
"fields": [
{
"key": "title",
"binding": "brand.config.visualPresentation.inquiry.title",
"label": "咨询页面标题",
"input": "text"
},
{
"key": "subtitle",
"binding": "brand.config.visualPresentation.inquiry.subtitle",
"label": "咨询说明",
"input": "textarea",
"maxLength": 140
},
{
"key": "submitLabel",
"binding": "brand.config.visualPresentation.inquiry.submitLabel",
"label": "提交按钮文字",
"input": "text"
}
]
}
]
},
"renderers": {
"home": "linjing-home",
"offerings": "linjing-offerings",
+1
View File
@@ -94,6 +94,7 @@ export interface RuntimeOffering {
crafts: string[];
materialsList: Array<{ name: string; spec: string }>;
};
[key: string]: unknown;
};
sections: Array<{
key: string;