refactor: 统一模板契约并修复预览版本

This commit is contained in:
que01 committed 2026-10-18 17:09:09 +08:00
1 parent cd2992c00a
commit 50b87e48de
56 files changed
+7849 -5756

No files matched your search

+3 -9
View File
@@ -193,15 +193,6 @@ export class ApiClient
this.resources.brand.createAdminMember(...arguments_);
updateAdminMember = (...arguments_: Parameters<BrandMethods["updateAdminMember"]>) =>
this.resources.brand.updateAdminMember(...arguments_);
getAdminVisualTemplatePreview = (
...arguments_: Parameters<BrandMethods["getAdminVisualTemplatePreview"]>
) => this.resources.brand.getAdminVisualTemplatePreview(...arguments_);
getAdminVisualTemplateHistory = (
...arguments_: Parameters<BrandMethods["getAdminVisualTemplateHistory"]>
) => this.resources.brand.getAdminVisualTemplateHistory(...arguments_);
rollbackAdminVisualTemplate = (
...arguments_: Parameters<BrandMethods["rollbackAdminVisualTemplate"]>
) => this.resources.brand.rollbackAdminVisualTemplate(...arguments_);
updateAdminBrand = (...arguments_: Parameters<BrandMethods["updateAdminBrand"]>) =>
this.resources.brand.updateAdminBrand(...arguments_);
updateAdminBrandPresentation = (
@@ -270,6 +261,9 @@ export class ApiClient
) => this.resources.template.getAdminPreviewWorkspace(...arguments_);
installAdminTemplate = (...arguments_: Parameters<TemplateMethods["installAdminTemplate"]>) =>
this.resources.template.installAdminTemplate(...arguments_);
selectAdminTemplateVersion = (
...arguments_: Parameters<TemplateMethods["selectAdminTemplateVersion"]>
) => this.resources.template.selectAdminTemplateVersion(...arguments_);
listAdminCapabilities = (...arguments_: Parameters<TemplateMethods["listAdminCapabilities"]>) =>
this.resources.template.listAdminCapabilities(...arguments_);
updateAdminCapability = (...arguments_: Parameters<TemplateMethods["updateAdminCapability"]>) =>
@@ -27,20 +27,6 @@ export interface BrandMethods {
id: string,
body: Partial<Pick<AdminBrandMember, "role" | "isEnabled">>,
): Promise<AdminBrandMember>;
getAdminVisualTemplatePreview(): Promise<{
current: {
key: string;
version: string;
name: string;
theme: { colors: Record<string, string> };
variants: Record<string, string>;
} | null;
available: string[];
}>;
getAdminVisualTemplateHistory(): Promise<{
history: Array<{ visualTemplateKey: string; savedAt: string }>;
}>;
rollbackAdminVisualTemplate(): Promise<{ visualTemplateKey: string; rolledBack: boolean }>;
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile>;
updateAdminBrandPresentation(body: BrandPresentationUpdate): Promise<{
visualPresentation: Record<string, Record<string, string>>;
@@ -97,10 +83,6 @@ export function brandMethods({ request }: { request: RequestFn }): BrandMethods
method: "PATCH",
body,
}),
getAdminVisualTemplatePreview: () => request("/admin/config/visual-template/preview"),
getAdminVisualTemplateHistory: () => request("/admin/config/visual-template/history"),
rollbackAdminVisualTemplate: () =>
request("/admin/config/visual-template/rollback", { method: "POST" }),
updateAdminBrand: (body) => request("/admin/config/brand", { method: "PATCH", body }),
updateAdminBrandPresentation: (body) =>
request("/admin/config/presentation", { method: "PATCH", body }),
+19 -15
View File
@@ -67,9 +67,9 @@ export interface TemplateMethods {
id: string;
templateKey: BrandTemplateKey;
templateVersion: string;
visualTemplateKey: string | null;
templatePackageVersionId: string | null;
contentChecksum: string | null;
visualTemplateKey: string;
templatePackageVersionId: string;
contentChecksum: string;
}>;
fields: BrandFieldDefinition[];
offerings: Offering[];
@@ -80,8 +80,13 @@ export interface TemplateMethods {
getAdminPreviewWorkspace(): Promise<RuntimeWorkspace>;
installAdminTemplate(
templateKey: BrandTemplateKey,
templatePackageVersionId?: string,
templatePackageVersionId: string,
): Promise<unknown>;
selectAdminTemplateVersion(input: {
templatePackageVersionId: string;
expectedCurrentPackageVersionId?: string | null;
confirm: true;
}): Promise<unknown>;
listAdminCapabilities(): Promise<CapabilityWithMetadata[]>;
updateAdminCapability(
key: string,
@@ -97,11 +102,11 @@ export interface TemplateMethods {
templateKey: string;
visualTemplateKey: string;
source: {
kind: "package_version" | "registry";
kind: "package_version";
packageKey: string;
version: string;
contentChecksum: string | null;
templatePackageVersionId?: string;
contentChecksum: string;
templatePackageVersionId: string;
};
alreadyImported: boolean;
counts: Record<
@@ -124,11 +129,11 @@ export interface TemplateMethods {
imported: boolean;
alreadyImported: boolean;
source: {
kind: "package_version" | "registry";
kind: "package_version";
packageKey: string;
version: string;
contentChecksum: string | null;
templatePackageVersionId?: string;
contentChecksum: string;
templatePackageVersionId: string;
};
counts: Record<string, number>;
}>;
@@ -201,7 +206,6 @@ export interface TemplatePackageVersion {
packageKey: string;
version: string;
displayName: string;
visualTemplateKey: string | null;
status: "imported" | "published" | "retired" | "disabled";
contentChecksum: string;
archiveChecksum: string;
@@ -235,7 +239,7 @@ export interface TemplatePackagePreview {
workspace: RuntimeWorkspace;
preview: {
assetFiles: Record<string, { sha256: string; dataUrl: string }>;
fixtureSource: "previewFixture" | "legacy-sampleContent";
fixtureSource: "previewFixture";
safety: { submissions: "disabled"; customerRecords: "disabled"; contactActions: "disabled" };
session: { token: string; expiresAt: string };
diagnostics: Array<{ code: string; severity: "warning"; message: string }>;
@@ -270,7 +274,6 @@ export interface TemplatePackageActionResult {
| "packageKey"
| "version"
| "displayName"
| "visualTemplateKey"
| "status"
| "contentChecksum"
| "archiveChecksum"
@@ -298,7 +301,6 @@ export interface TemplatePackageImportResult {
| "packageKey"
| "version"
| "displayName"
| "visualTemplateKey"
| "status"
| "contentChecksum"
| "archiveChecksum"
@@ -375,8 +377,10 @@ export function templateMethods({ request }: { request: RequestFn }): TemplateMe
installAdminTemplate: (templateKey, templatePackageVersionId) =>
request("/admin/workspace/install", {
method: "POST",
body: { templateKey, ...(templatePackageVersionId ? { templatePackageVersionId } : {}) },
body: { templateKey, templatePackageVersionId },
}),
selectAdminTemplateVersion: (input) =>
request("/admin/workspace/template/select-version", { method: "POST", body: input }),
listAdminCapabilities: () => request("/admin/workspace/capabilities"),
updateAdminCapability: (key, body) =>
request(`/admin/workspace/capabilities/${encodeURIComponent(key)}`, {
+3
View File
@@ -8,6 +8,9 @@
"import": "./dist/index.js"
}
},
"dependencies": {
"@personal-brand/template-contract": "workspace:^"
},
"scripts": {
"build": "tsc -p tsconfig.json",
"lint": "eslint .",
File diff suppressed because it is too large. Load diff
@@ -147,5 +147,5 @@ export interface TemplatePackageManifest {
}[];
overrides?: readonly string[];
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
previewFixture?: Partial<Record<BrandTemplateKey, TemplatePreviewFixture>>;
previewFixture: Readonly<Partial<Record<BrandTemplateKey, TemplatePreviewFixture>>>;
}
+1 -21
View File
@@ -1,5 +1,6 @@
import { generatedTemplatePackageRegistry } from "./generated-template-packages.js";
import type { TemplatePackageManifest } from "./template-package-manifest.js";
export { validateTemplatePackageManifest } from "@personal-brand/template-contract";
export const templatePackageRegistry: readonly TemplatePackageManifest[] =
generatedTemplatePackageRegistry;
@@ -13,24 +14,3 @@ export function getTemplatePackageManifestForVisualKey(
): 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;
}
@@ -1,6 +1,4 @@
import type { BrandTemplateKey } from "./template-keys.js";
import { getDefaultVisualTemplateKey } from "./visual-templates.js";
import { templatePackageRegistry } from "./template-packages.js";
export interface TemplateSampleContent {
templateKey: BrandTemplateKey;
@@ -33,132 +31,3 @@ export interface TemplateSampleContent {
}>;
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",
priceAmount: 2800,
},
{
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 = {
personal: personalSampleContent,
food: foodSampleContent,
doors: doorsSampleContent,
} as const;
export function getTemplateSampleContent(
templateKey: string,
visualTemplateKey?: string,
): TemplateSampleContent | undefined {
const selected = visualTemplateKey
? templatePackageRegistry.find(
(item) =>
item.packageKey === visualTemplateKey &&
item.supportedIndustryTemplates.includes(templateKey),
)
: undefined;
if (selected) return selected.sampleContent?.[templateKey];
const packageSample = templatePackageRegistry.find(
(item) =>
item.packageKey === getDefaultVisualTemplateKey(templateKey) &&
item.supportedIndustryTemplates.includes(templateKey),
)?.sampleContent?.[templateKey];
return packageSample ?? templateSampleContent[templateKey as keyof typeof templateSampleContent];
}
-10
View File
@@ -67,13 +67,3 @@ export const visualTemplateKeys = listVisualTemplateKeys();
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
return visualTemplates[key];
}
export function getDefaultVisualTemplateKey(industryTemplateKey: string): VisualTemplateKey {
return (
listVisualTemplateKeys().find((key) =>
getVisualTemplate(key)?.supportedIndustryTemplates.includes(industryTemplateKey),
) ?? defaultVisualTemplateKey
);
}
export const defaultVisualTemplateKey = "linjing-editorial" satisfies VisualTemplateKey;
@@ -1539,7 +1539,6 @@
],
"capabilityKey": "booking",
"brandConfig": {
"visualTemplateKey": "acheng-campus-food",
"founder": "阿成",
"title": "私房菜主理人",
"slogan": "认真做好每一顿家常饭。",
@@ -1615,5 +1614,394 @@
"pages/stall-service/index",
"pages/bookings/index"
],
"overrides": ["pages/inquiry", "pages/inquiry-success", "pages/offering", "pages/records"]
"overrides": ["pages/inquiry", "pages/inquiry-success", "pages/offering", "pages/records"],
"visualTemplateKey": "acheng-campus-food",
"previewFixture": {
"food": {
"schemaVersion": "1",
"brand": {
"name": "阿成校园餐 · 预览",
"tagline": "用于独立预览的模板演示内容",
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
},
"content": {
"templateKey": "food",
"inquiryFormName": "餐品预订与定制表单",
"offerings": [
{
"kind": "package",
"name": "示例·今日套餐",
"summary": "现做家常套餐示例内容。",
"categoryKey": "set-meal",
"coverUrl": "/assets/content/package-01.jpg",
"priceText": "¥28 起 / 份",
"config": {
"media": [
{
"url": "/assets/content/package-01.jpg",
"alt": "",
"type": "image"
}
]
}
},
{
"kind": "service",
"name": "示例·聚餐定制",
"summary": "按人数和口味沟通定制餐品。",
"categoryKey": "private-chef",
"coverUrl": "/assets/content/private-chef.jpg",
"priceText": "按人数和菜单确认",
"config": {
"media": [
{
"url": "/assets/content/private-chef.jpg",
"alt": "",
"type": "image"
}
]
}
},
{
"kind": "service",
"name": "示例·团体餐定制",
"summary": "为社团、活动和小型聚会提供批量餐品定制。",
"categoryKey": "group-meal",
"coverUrl": "/assets/content/private-chef.jpg",
"priceText": "按人数和菜单确认",
"config": {
"media": [
{
"url": "/assets/content/private-chef.jpg",
"alt": "",
"type": "image"
}
]
}
}
],
"trustContent": [
{
"type": "schedule",
"title": "每周出摊固定日程",
"content": "",
"config": {
"status": "准时出摊",
"weekdayLabel": "周一至周五(晚餐 + 夜宵档)",
"weekdayTag": "常规固定点",
"weekdayDetail": "地点:二号校门外小吃商业街 #07 号铺位",
"weekdayHours": "营业:17:00 - 22:30(下雨搭防雨防风棚正常营业)",
"weekendLabel": "周六、周日(全天接团体单 + 夜市流动)",
"weekendTag": "活动专车",
"weekendDetail": "白天专供:球赛、班级春游、社团集训、答辩餐",
"weekendHours": "晚间:18:00 - 23:00 体育馆南侧流动出摊"
}
},
{
"type": "coverage",
"title": "取餐与配送范围",
"content": "",
"config": {
"pickupTitle": "摊位现场自取",
"pickupDetail": "小程序提前留餐,报手机尾号即拿,附赠特制加厚保温袋,不用排长龙。",
"deliveryTitle": "校内楼下配送",
"deliveryDetail": "满 3 份即可送至宿舍楼栋或实验楼门前,阿成骑专用恒温保温箱电动车直送。"
}
},
{
"type": "process",
"title": "定制餐品 4 步流程",
"content": "",
"config": {
"intro": "专为班长、社长、活动干事设计的极简排菜流程",
"steps": [
{
"title": "提交基本需求",
"detail": "选择活动类型(如生日会、社团换届、答辩加餐)、预估人数与预算。"
},
{
"title": "15 分钟内核算菜单",
"detail": "阿成微信直接联系,提供荤素搭配明细与个性化需求(免辣、清真配料等)。"
},
{
"title": "当日新鲜烹饪打包",
"detail": "提前 2 小时生鲜采买,铁锅现炒,独立封盒并标注姓名 / 楼栋。"
},
{
"title": "保温直达交付",
"detail": "约定时间准时送抵指定场地,确认菜品温度与数量无误后结算。"
}
],
"minimumNote": "起订门槛:6 份起",
"refundNote": "退改:出餐前 2 小时全退"
}
},
{
"type": "credential",
"title": "食品安全与制作标准",
"content": "示例内容,请根据实际资质和制作标准完善。",
"config": {
"standards": [
{
"title": "当天采购",
"detail": "按当天需求采买"
},
{
"title": "现做现出餐",
"detail": "按约定时间制作"
},
{
"title": "食具清洁消毒",
"detail": "每日清洁与消毒"
}
]
}
},
{
"type": "case",
"title": "他们都在阿成这订过餐",
"summary": "感谢大学城各学院与社团伙伴的信任",
"content": "校街舞社年度专场 · 52 人份\n信息学院科创竞赛 · 连签 5 天\n7 号楼庆功宴 · 8 人定制",
"config": {
"entries": [
{
"badge": "舞",
"title": "校街舞社年度专场(52 人份)",
"detail": "保温箱直达大礼堂后台,贴名分装",
"result": "零延误签收"
},
{
"badge": "科",
"title": "信息学院科创竞赛封闭备赛",
"detail": "每日荤素轮换,附赠每日滋补老汤",
"result": "连签 5 天"
},
{
"badge": "寝",
"title": "7 号楼庆功宴(8 人定制)",
"detail": "定制双拼厚肉饭",
"result": "定制餐品"
}
]
}
},
{
"type": "promise",
"title": "阿成的真实回复承诺",
"content": "备料期 15 分钟内联系,出摊高峰 1 小时内回复。",
"config": {
"commitments": [
{
"label": "非出摊备料期",
"detail": "提交咨询后通过微信或电话沟通。",
"highlight": "15 分钟内"
},
{
"label": "出摊晚高峰",
"detail": "正在出餐,稍有延迟,会抽空回复。",
"highlight": "1 小时内"
}
]
}
}
],
"fields": [
{
"key": "type",
"label": "咨询类型",
"type": "select",
"required": true,
"options": [
{
"label": "日常留餐",
"value": "日常留餐"
},
{
"label": "宿舍开黑餐",
"value": "宿舍开黑餐"
},
{
"label": "社团 / 班级活动",
"value": "社团 / 班级活动"
},
{
"label": "生日聚会",
"value": "生日聚会"
},
{
"label": "考试周加餐",
"value": "考试周加餐"
},
{
"label": "其他需求",
"value": "其他需求"
}
]
},
{
"key": "people",
"label": "用餐人数",
"type": "select",
"required": true,
"options": [
{
"label": "1 人(单点)",
"value": "1 人(单点)"
},
{
"label": "2-4 人(寝室小聚)",
"value": "2-4 人(寝室小聚)"
},
{
"label": "5-10 人(部门小聚)",
"value": "5-10 人(部门小聚)"
},
{
"label": "10-30 人(社团活动)",
"value": "10-30 人(社团活动)"
},
{
"label": "30 人以上(大型活动)",
"value": "30 人以上(大型活动)"
}
]
},
{
"key": "date",
"label": "用餐日期",
"type": "date",
"required": true
},
{
"key": "budget",
"label": "人均预算",
"type": "select",
"required": false,
"options": [
{
"label": "15 元左右 / 人(实惠)",
"value": "15 元左右 / 人(实惠)"
},
{
"label": "18-22 元 / 人(荤素双拼)",
"value": "18-22 元 / 人(荤素双拼)"
},
{
"label": "25 元以上 / 人(高规格定制)",
"value": "25 元以上 / 人(高规格定制)"
}
]
},
{
"key": "delivery",
"label": "取餐 / 配送方式",
"type": "select",
"required": false,
"options": [
{
"label": "摊位自取(报手机尾号即拿)",
"value": "摊位自取(报手机尾号即拿)"
},
{
"label": "送至宿舍楼下(满 3 份)",
"value": "送至宿舍楼下(满 3 份)"
},
{
"label": "送至指定教室 / 场地",
"value": "送至指定教室 / 场地"
}
]
},
{
"key": "remark",
"label": "餐品 / 口味 / 忌口备注",
"type": "textarea",
"required": false,
"placeholder": "例:现炒牛肉饭 1 份,微辣多浇卤汁,不要香菜"
},
{
"key": "phone",
"label": "联系手机",
"type": "phone",
"required": true
}
],
"capabilityKey": "booking",
"brandConfig": {
"founder": "阿成",
"title": "私房菜主理人",
"slogan": "认真做好每一顿家常饭。",
"phone": "",
"wechat": "",
"studioAddress": "大学城生活区东门附近",
"avatarUrl": "/assets/owner/portrait.jpg",
"heroImage": "/assets/content/package-01.jpg",
"visualPresentation": {
"home": {
"stallTitle": "服务地点",
"primaryAction": "咨询 / 预订",
"secondaryAction": "查看菜单",
"worksEyebrow": "今日推荐",
"worksTitle": "热门套餐",
"worksAction": "查看全部 →",
"manifestoTitle": "我们的服务承诺"
},
"offerings": {
"title": "餐品与定制",
"subtitle": "现做家常餐、团体餐和活动定制",
"materialLabel": "包含:",
"hardwareLabel": "定制说明:",
"detailAction": "查看详情 →",
"inquiryAction": "预订 / 咨询"
},
"detail": {
"priceLabel": "价格参考",
"spaceLabel": "适合场景",
"backgroundTitle": "餐品说明",
"conceptTitle": "备餐方式",
"craftsTitle": "服务内容",
"materialsTitle": "交付说明",
"inquiryAction": "预订 / 咨询",
"inquiryHint": "提交后会由主理人与你确认时间、数量和地点。"
},
"profile": {
"phoneLabel": "联系电话",
"wechatLabel": "微信",
"addressLabel": "服务地点",
"callAction": "呼叫",
"copyAction": "复制",
"recordsTitle": "我的订单与咨询",
"recordsCountUnit": "条记录"
},
"inquiry": {
"eyebrow": "ORDER",
"title": "餐品预订",
"subtitle": "留下用餐时间和人数,我会尽快确认。",
"submitLabel": "提交预订需求"
},
"success": {
"eyebrow": "ORDER",
"title": "已收到你的需求",
"intro": "确认备餐时间和数量后,我会尽快回复。",
"recordsAction": "查看咨询记录",
"homeAction": "返回首页"
},
"records": {
"title": "我的咨询记录",
"createAction": "新增咨询",
"emptyTitle": "还没有咨询记录",
"emptyDescription": "提交一次需求,开始与主理人沟通。",
"emptyAction": "开始咨询"
}
}
}
},
"safety": {
"submissions": "disabled",
"customerRecords": "disabled",
"contactActions": "disabled"
}
}
}
}
@@ -2,6 +2,7 @@
"packageKey": "drill-consultant",
"version": "0.1.0",
"displayName": "咨询师演练模板",
"visualTemplateKey": "drill-consultant",
"defaultBrandSlug": "drill-consultant",
"runtimeContract": "1.0",
"supportedIndustryTemplates": ["consulting"],
@@ -54,5 +55,28 @@
]
}
]
},
"previewFixture": {
"consulting": {
"schemaVersion": "1",
"brand": {
"name": "咨询师演练",
"tagline": "用于编译器测试的虚构品牌",
"description": "此内容仅用于模板编译器测试。"
},
"content": {
"templateKey": "consulting",
"inquiryFormName": "演练咨询表单",
"capabilityKey": "inquiry",
"offerings": [],
"trustContent": [],
"fields": []
},
"safety": {
"submissions": "disabled",
"customerRecords": "disabled",
"contactActions": "disabled"
}
}
}
}
+8 -8
View File
@@ -137,6 +137,7 @@ export type TemplatePackageManifest = {
packageKey: string;
version: string;
displayName: string;
visualTemplateKey: string;
runtimeContract: typeof TEMPLATE_RUNTIME_CONTRACT;
supportedIndustryTemplates: string[];
entrypoints: Record<string, string>;
@@ -160,22 +161,21 @@ export type TemplatePackageManifest = {
admin: TemplateAdminManifest;
trustContentTypes?: TemplateTrustContentType[];
sampleContent?: Record<string, TemplateSampleContent>;
previewFixture?: Record<string, unknown>;
previewFixture: Record<string, unknown>;
};
export function validateTemplatePackageManifest(value: unknown): string[] {
const errors: string[] = [];
if (!value || typeof value !== "object") return ["manifest must be an object"];
const manifest = value as Partial<TemplatePackageManifest>;
if (manifest.previewFixture !== undefined) {
for (const issue of validateTemplatePreviewFixtures(
manifest.previewFixture,
manifest.supportedIndustryTemplates ?? [],
))
errors.push(`previewFixture.${issue.path}: ${issue.message}`);
}
for (const issue of validateTemplatePreviewFixtures(
manifest.previewFixture,
manifest.supportedIndustryTemplates ?? [],
))
errors.push(`previewFixture.${issue.path}: ${issue.message}`);
if (!manifest.packageKey?.trim()) errors.push("packageKey is required");
if (!manifest.version?.trim()) errors.push("version is required");
if (!manifest.visualTemplateKey?.trim()) errors.push("visualTemplateKey is required");
if (manifest.runtimeContract !== TEMPLATE_RUNTIME_CONTRACT)
errors.push(`runtimeContract must be ${TEMPLATE_RUNTIME_CONTRACT}`);
if (!manifest.displayName?.trim()) errors.push("displayName is required");
@@ -58,6 +58,14 @@ for (const key of ["acheng-campus-food", "linjing-editorial"]) {
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"));
const previewFixture = structuredClone(manifest.previewFixture);
delete manifest.previewFixture;
assert.ok(
validateTemplatePackageManifest(manifest).some((message) =>
message.startsWith("previewFixture"),
),
);
manifest.previewFixture = previewFixture;
manifest.admin.sections[0].fields[0].label = "";
manifest.assetSlots[0].help = "";
assert.deepEqual(validateTemplatePackageManifest(manifest), [
@@ -1,6 +1,6 @@
{
"name": "@personal-brand/template-linjing-editorial",
"version": "1.0.4",
"version": "1.0.5",
"private": true,
"type": "module",
"files": [
+686 -22
View File
@@ -1,6 +1,6 @@
{
"packageKey": "linjing-editorial",
"version": "1.0.4",
"version": "1.0.5",
"displayName": "林境建筑画册",
"defaultBrandSlug": "linjing-doors",
"runtimeContract": "1.0",
@@ -1336,8 +1336,14 @@
"hardware": "德国 dormakaba 重型地弹簧 + 定制实心锻铜一体式长执手",
"details": {
"materialsList": [
{ "name": "门扇主体", "spec": "航空铝蜂窝 + 防暴钢板 + 黑胡桃" },
{ "name": "承重结构", "spec": "不锈钢重型天地偏心轴" }
{
"name": "门扇主体",
"spec": "航空铝蜂窝 + 防暴钢板 + 黑胡桃"
},
{
"name": "承重结构",
"spec": "不锈钢重型天地偏心轴"
}
]
},
"media": [
@@ -1361,8 +1367,14 @@
"hardware": "意大利全隐形地埋式液压自闭器 + 静音电控锁",
"details": {
"materialsList": [
{ "name": "户外木种", "spec": "高油脂老料缅甸柚木" },
{ "name": "骨架型材", "spec": "高强度航空铝镁合金" }
{
"name": "户外木种",
"spec": "高油脂老料缅甸柚木"
},
{
"name": "骨架型材",
"spec": "高强度航空铝镁合金"
}
]
},
"media": [
@@ -1386,8 +1398,14 @@
"hardware": "意大利 AGB 磁吸静音门锁 + 隐藏式暗铰链",
"details": {
"materialsList": [
{ "name": "抗弯核心", "spec": "双组份碳纤维预应力防变形拉力杆" },
{ "name": "吸音内衬", "spec": "德国均质空心桥洞力学板" }
{
"name": "抗弯核心",
"spec": "双组份碳纤维预应力防变形拉力杆"
},
{
"name": "吸音内衬",
"spec": "德国均质空心桥洞力学板"
}
]
},
"media": [
@@ -1411,8 +1429,14 @@
"hardware": "感应式电动自开闭装置或碰珠反弹器",
"details": {
"materialsList": [
{ "name": "表面饰材", "spec": "意大利雪山银狐超薄天然大理石" },
{ "name": "驱动系统", "spec": "低噪步进电机伺服闭门器" }
{
"name": "表面饰材",
"spec": "意大利雪山银狐超薄天然大理石"
},
{
"name": "驱动系统",
"spec": "低噪步进电机伺服闭门器"
}
]
},
"media": [
@@ -1432,10 +1456,26 @@
"content": "国家注册高级室内建筑师,专注高定大门及私宅空间门类系统研发 14 年。",
"config": {
"stats": [
{ "value": "14年", "label": "高端门系深化经验", "sub": "历经百项严苛私宅考验" },
{ "value": "260+", "label": "落地庄园实景案例", "sub": "全实景图库,可预约探访" },
{ "value": "100%", "label": "主理人全案跟进", "sub": "量房 / 出图 / 选料 / 试装" },
{ "value": "10年", "label": "结构主轴质保承诺", "sub": "终生五金润滑维保机制" }
{
"value": "14年",
"label": "高端门系深化经验",
"sub": "历经百项严苛私宅考验"
},
{
"value": "260+",
"label": "落地庄园实景案例",
"sub": "全实景图库,可预约探访"
},
{
"value": "100%",
"label": "主理人全案跟进",
"sub": "量房 / 出图 / 选料 / 试装"
},
{
"value": "10年",
"label": "结构主轴质保承诺",
"sub": "终生五金润滑维保机制"
}
],
"pillars": [
{
@@ -1452,12 +1492,36 @@
}
],
"serviceFlow": [
{ "step": "01", "name": "私享沟通", "desc": "厘清生活动线与风候环境" },
{ "step": "02", "name": "上门实测", "desc": "复核门洞公差与地平基准" },
{ "step": "03", "name": "构造出图", "desc": "输出结构图与材质节点方案" },
{ "step": "04", "name": "实样工坊确认", "desc": "确认木样、锻铜样与密封节点" },
{ "step": "05", "name": "工坊试装交付", "desc": "试装调试后专车直运现场" },
{ "step": "06", "name": "终生私属维护", "desc": "建立一门一档数字化档案" }
{
"step": "01",
"name": "私享沟通",
"desc": "厘清生活动线与风候环境"
},
{
"step": "02",
"name": "上门实测",
"desc": "复核门洞公差与地平基准"
},
{
"step": "03",
"name": "构造出图",
"desc": "输出结构图与材质节点方案"
},
{
"step": "04",
"name": "实样工坊确认",
"desc": "确认木样、锻铜样与密封节点"
},
{
"step": "05",
"name": "工坊试装交付",
"desc": "试装调试后专车直运现场"
},
{
"step": "06",
"name": "终生私属维护",
"desc": "建立一门一档数字化档案"
}
]
}
},
@@ -1592,7 +1656,6 @@
],
"capabilityKey": "inquiry",
"brandConfig": {
"visualTemplateKey": "linjing-editorial",
"templateData": {
"designPhilosophy": "先厘清问题,再设计表达"
},
@@ -1756,7 +1819,6 @@
],
"capabilityKey": "inquiry",
"brandConfig": {
"visualTemplateKey": "linjing-editorial",
"templateData": {
"designPhilosophy": "先厘清问题,再设计表达"
},
@@ -1830,5 +1892,607 @@
}
}
},
"pages": ["pages/index/index", "pages/services/index", "pages/bookings/index"]
"pages": ["pages/index/index", "pages/services/index", "pages/bookings/index"],
"visualTemplateKey": "linjing-editorial",
"previewFixture": {
"doors": {
"schemaVersion": "1",
"brand": {
"name": "林境建筑画册 · 预览",
"tagline": "用于独立预览的模板演示内容",
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
},
"content": {
"templateKey": "doors",
"inquiryFormName": "门系统咨询表单",
"offerings": [
{
"kind": "product",
"name": "序章·入户门",
"summary": "为别墅入口定制的整樘门系统",
"categoryKey": "entrance-door",
"coverUrl": "/assets/content/doors-hero.jpg",
"priceText": "按项目确认",
"config": {
"series": "「万籁」重型天地轴入户系统",
"hardware": "德国 dormakaba 重型地弹簧 + 定制实心锻铜一体式长执手",
"details": {
"materialsList": [
{
"name": "门扇主体",
"spec": "航空铝蜂窝 + 防暴钢板 + 黑胡桃"
},
{
"name": "承重结构",
"spec": "不锈钢重型天地偏心轴"
}
]
},
"media": [
{
"url": "/assets/content/doors-hero.jpg",
"alt": "",
"type": "image"
}
]
}
},
{
"kind": "product",
"name": "庭院·边界门",
"summary": "连接建筑与庭院的定制门",
"categoryKey": "garden-door",
"coverUrl": "/assets/content/doors-yard-gate.jpg",
"priceText": "按项目确认",
"config": {
"series": "「虚实」透光私家庭院门",
"hardware": "意大利全隐形地埋式液压自闭器 + 静音电控锁",
"details": {
"materialsList": [
{
"name": "户外木种",
"spec": "高油脂老料缅甸柚木"
},
{
"name": "骨架型材",
"spec": "高强度航空铝镁合金"
}
]
},
"media": [
{
"url": "/assets/content/doors-yard-gate.jpg",
"alt": "",
"type": "image"
}
]
}
},
{
"kind": "product",
"name": "室内·静谧门",
"summary": "统一室内空间秩序的户内门",
"categoryKey": "interior-door",
"coverUrl": "/assets/content/doors-room-door.jpg",
"priceText": "按项目确认",
"config": {
"series": "「空灵」2.8m - 3.2m 满高通顶系统",
"hardware": "意大利 AGB 磁吸静音门锁 + 隐藏式暗铰链",
"details": {
"materialsList": [
{
"name": "抗弯核心",
"spec": "双组份碳纤维预应力防变形拉力杆"
},
{
"name": "吸音内衬",
"spec": "德国均质空心桥洞力学板"
}
]
},
"media": [
{
"url": "/assets/content/doors-room-door.jpg",
"alt": "",
"type": "image"
}
]
}
},
{
"kind": "service",
"name": "一对一门系统设计咨询",
"summary": "从现场到方案的完整设计沟通",
"categoryKey": "custom",
"coverUrl": "/assets/content/personal-consulting.jpg",
"priceText": "按项目确认",
"config": {
"series": "「无垠」密室及背景墙融合门",
"hardware": "感应式电动自开闭装置或碰珠反弹器",
"details": {
"materialsList": [
{
"name": "表面饰材",
"spec": "意大利雪山银狐超薄天然大理石"
},
{
"name": "驱动系统",
"spec": "低噪步进电机伺服闭门器"
}
]
},
"media": [
{
"url": "/assets/content/personal-consulting.jpg",
"alt": "",
"type": "image"
}
]
}
}
],
"trustContent": [
{
"type": "credential",
"title": "主理人的门作观",
"content": "国家注册高级室内建筑师,专注高定大门及私宅空间门类系统研发 14 年。",
"config": {
"stats": [
{
"value": "14年",
"label": "高端门系深化经验",
"sub": "历经百项严苛私宅考验"
},
{
"value": "260+",
"label": "落地庄园实景案例",
"sub": "全实景图库,可预约探访"
},
{
"value": "100%",
"label": "主理人全案跟进",
"sub": "量房 / 出图 / 选料 / 试装"
},
{
"value": "10年",
"label": "结构主轴质保承诺",
"sub": "终生五金润滑维保机制"
}
],
"pillars": [
{
"title": "天然厚板与古铜锻打",
"desc": "精选天然木材与手工冷锻紫铜,构建长期耐用的门体结构。"
},
{
"title": "微米级红外高精量房",
"desc": "通过 3D 空间激光扫描复核门洞公差与建筑墙体垂直度。"
},
{
"title": "隐匿式重型五金系统",
"desc": "使用可调静音承重铰链,让重型门体开合轻盈安静。"
}
],
"serviceFlow": [
{
"step": "01",
"name": "私享沟通",
"desc": "厘清生活动线与风候环境"
},
{
"step": "02",
"name": "上门实测",
"desc": "复核门洞公差与地平基准"
},
{
"step": "03",
"name": "构造出图",
"desc": "输出结构图与材质节点方案"
},
{
"step": "04",
"name": "实样工坊确认",
"desc": "确认木样、锻铜样与密封节点"
},
{
"step": "05",
"name": "工坊试装交付",
"desc": "试装调试后专车直运现场"
},
{
"step": "06",
"name": "终生私属维护",
"desc": "建立一门一档数字化档案"
}
]
}
},
{
"type": "case",
"title": "别墅门系统案例",
"content": "示例内容,待品牌主理人完善。"
},
{
"type": "process",
"title": "从测量到交付",
"content": "示例内容,待品牌主理人完善。"
}
],
"fields": [
{
"key": "doorType",
"label": "期望定制的门类型",
"type": "select",
"required": true,
"options": [
{
"label": "入户大门(防暴铸铜 / 实木)",
"value": "entry"
},
{
"label": "庭院围墙门(耐候格栅 / 对开)",
"value": "yard"
},
{
"label": "全屋室内门系统(通顶隐形)",
"value": "interior"
},
{
"label": "背景墙一体门 / 密室门",
"value": "wall"
},
{
"label": "整栋别墅门系统全案一体化",
"value": "whole-home"
}
]
},
{
"key": "cityArea",
"label": "房屋 / 别墅所在城市与楼盘",
"type": "text",
"required": true
},
{
"key": "projectStage",
"label": "项目阶段",
"type": "select",
"required": true,
"options": [
{
"label": "土建结构阶段(适合预埋加固)",
"value": "structure"
},
{
"label": "水电木工阶段(适合精确测距)",
"value": "rough-in"
},
{
"label": "硬装收尾阶段",
"value": "finishing"
},
{
"label": "旧宅门体翻新改造",
"value": "renovation"
}
]
},
{
"key": "budgetRange",
"label": "预估门系统投资预算",
"type": "select",
"required": false,
"options": [
{
"label": "5 万 - 10 万",
"value": "50k-100k"
},
{
"label": "10 万 - 20 万",
"value": "100k-200k"
},
{
"label": "20 万 - 50 万(全宅全案)",
"value": "200k-500k"
},
{
"label": "50 万以上(顶级孤品定制)",
"value": "500k-plus"
}
]
},
{
"key": "needMeasure",
"label": "是否需要主理人上门现场量房",
"type": "radio",
"required": true,
"options": [
{
"label": "需要(预约排期现场勘测)",
"value": "需要(预约排期现场勘测)"
},
{
"label": "暂不需要(先发图纸在线深化评估)",
"value": "暂不需要(先发图纸在线深化评估)"
}
]
},
{
"key": "contactName",
"label": "贵姓称谓",
"type": "text",
"required": true
},
{
"key": "contactPhone",
"label": "联系手机号(微信同号)",
"type": "tel",
"required": true
},
{
"key": "specialNote",
"label": "空间想法或特殊需求描述",
"type": "textarea",
"required": false
}
],
"capabilityKey": "inquiry",
"brandConfig": {
"templateData": {
"designPhilosophy": "先厘清问题,再设计表达"
},
"title": "高端门系统建筑研造主理人",
"slogan": "为当代别墅空间,定制有秩序感与呼吸感的门",
"phone": "186-0218-9908",
"wechat": "LIN-ATELIER-2024",
"studioAddress": "上海市静安区威海路设计中心 A 座 / 杭州良渚研造工坊",
"avatarUrl": "/assets/content/personal-avatar.jpg",
"heroImage": "/assets/content/doors-hero.jpg",
"visualPresentation": {
"home": {
"founderBadge": "接受项目沟通",
"proofEyebrow": "专业经验与合作成果",
"proofTitle": "14 年,只做门与空间的关系",
"manifestoEyebrow": "工作原则",
"manifestoTitle": "先厘清问题,再设计表达",
"worksEyebrow": "项目案例",
"worksTitle": "门系统项目",
"worksAction": "查看全部 →"
},
"offerings": {
"title": "门系统项目",
"subtitle": "从入户门到室内门的一体化设计",
"materialLabel": "包含:",
"hardwareLabel": "定制说明:",
"detailAction": "查看详情 →",
"inquiryAction": "发起咨询"
},
"detail": {
"priceLabel": "价格参考",
"spaceLabel": "适合场景",
"backgroundTitle": "项目背景",
"conceptTitle": "设计思路",
"craftsTitle": "交付要点",
"materialsTitle": "材料与说明",
"inquiryAction": "发起咨询",
"inquiryHint": "提交信息后由主理人与您沟通。"
},
"profile": {
"phoneLabel": "联系电话",
"wechatLabel": "微信",
"addressLabel": "工作地点",
"callAction": "呼叫",
"copyAction": "复制",
"recordsTitle": "我的咨询记录",
"recordsCountUnit": "条记录"
},
"inquiry": {
"eyebrow": "COLLABORATION",
"title": "合作咨询",
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
"submitLabel": "提交量房与定制评估需求"
},
"success": {
"eyebrow": "COLLABORATION",
"title": "已收到你的咨询",
"intro": "主理人会尽快与你联系。",
"recordsAction": "查看咨询记录",
"homeAction": "返回首页"
},
"records": {
"title": "我的咨询记录",
"createAction": "新增咨询",
"emptyTitle": "还没有咨询记录",
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
"emptyAction": "开始咨询"
}
},
"founder": "林叙安 (Lin XUAN)",
"profilePresentation": {
"coverage": [
{
"title": "直派核心圈",
"content": "上海、杭州、宁波、苏州、无锡、南京及深圳、广州。主理人及资深装配总工亲赴现场。"
},
{
"title": "全国其他城市私邸",
"content": "接受建筑设计师联合委托,安排远程 3D 激光测绘支持与专用物流直运安装。"
}
],
"warranty": [
"门体内部防变形航空合金骨架承诺 10 年结构质保;",
"重型天地轴、进口地弹簧及磁吸五金 5 年免费维护;",
"每樘门出厂前进行 5000 次启闭校正;",
"原木天然肌理享有首年 2 次木蜡油保养服务。"
]
}
}
},
"safety": {
"submissions": "disabled",
"customerRecords": "disabled",
"contactActions": "disabled"
}
},
"personal": {
"schemaVersion": "1",
"brand": {
"name": "林境建筑画册 · 预览",
"tagline": "用于独立预览的模板演示内容",
"description": "此内容仅用于平台模板预览,不代表真实品牌或客户案例。",
"deliveryNote": "演示预览已禁用真实咨询和联系操作。"
},
"content": {
"templateKey": "personal",
"inquiryFormName": "合作咨询表单",
"offerings": [
{
"kind": "service",
"name": "示例·品牌定位咨询",
"summary": "梳理品牌定位与下一步行动。",
"categoryKey": "consulting",
"coverUrl": "/assets/content/personal-consulting.jpg",
"priceText": "按需求确认",
"config": {
"media": [
{
"url": "/assets/content/personal-consulting.jpg",
"alt": "",
"type": "image"
}
]
}
},
{
"kind": "service",
"name": "示例·长期顾问支持",
"summary": "围绕表达和转化提供持续支持。",
"categoryKey": "advisory",
"coverUrl": "/assets/content/personal-advisory.jpg",
"priceText": "按服务周期确认",
"config": {
"media": [
{
"url": "/assets/content/personal-advisory.jpg",
"alt": "",
"type": "image"
}
]
}
}
],
"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",
"brandConfig": {
"templateData": {
"designPhilosophy": "先厘清问题,再设计表达"
},
"title": "品牌策略顾问",
"slogan": "用清晰的定位与可执行的表达,让专业被看见。",
"phone": "",
"wechat": "",
"studioAddress": "上海市徐汇区创意园区",
"avatarUrl": "/assets/content/personal-avatar.jpg",
"heroImage": "/assets/content/personal-consulting.jpg",
"visualPresentation": {
"home": {
"founderBadge": "接受项目沟通",
"proofEyebrow": "专业经验与合作成果",
"proofTitle": "经验与方法",
"manifestoEyebrow": "工作原则",
"manifestoTitle": "先厘清问题,再设计表达",
"worksEyebrow": "合作方式",
"worksTitle": "品牌策略与顾问服务",
"worksAction": "查看全部 →"
},
"offerings": {
"title": "合作方式",
"subtitle": "围绕定位、表达与业务转化,选择适合当前阶段的支持。",
"materialLabel": "包含:",
"hardwareLabel": "定制说明:",
"detailAction": "查看详情 →",
"inquiryAction": "发起咨询"
},
"detail": {
"priceLabel": "价格参考",
"spaceLabel": "适合场景",
"backgroundTitle": "项目背景",
"conceptTitle": "设计思路",
"craftsTitle": "交付要点",
"materialsTitle": "材料与说明",
"inquiryAction": "发起咨询",
"inquiryHint": "提交信息后由主理人与您沟通。"
},
"profile": {
"phoneLabel": "联系电话",
"wechatLabel": "微信",
"addressLabel": "工作地点",
"callAction": "呼叫",
"copyAction": "复制",
"recordsTitle": "我的咨询记录",
"recordsCountUnit": "条记录"
},
"inquiry": {
"eyebrow": "COLLABORATION",
"title": "合作咨询",
"subtitle": "留下你的需求与目标,主理人会尽快联系。",
"submitLabel": "提交咨询"
},
"success": {
"eyebrow": "COLLABORATION",
"title": "已收到你的咨询",
"intro": "主理人会尽快与你联系。",
"recordsAction": "查看咨询记录",
"homeAction": "返回首页"
},
"records": {
"title": "我的咨询记录",
"createAction": "新增咨询",
"emptyTitle": "还没有咨询记录",
"emptyDescription": "提交一次咨询,开始与你的主理人沟通。",
"emptyAction": "开始咨询"
}
},
"founder": "示例主理人"
}
},
"safety": {
"submissions": "disabled",
"customerRecords": "disabled",
"contactActions": "disabled"
}
}
}
}