feat: 让模板声明信任内容编辑语义

This commit is contained in:
que01 committed 2026-09-27 12:51:21 +08:00
1 parent 6d7fae95b3
commit e3a4074d8e
12 files changed
+159 -13

No files matched your search

+1
View File
@@ -87,6 +87,7 @@ export interface TemplateAdminSection {
export interface AdminTemplateContent {
displayName: string;
admin: { sections: TemplateAdminSection[] };
trustContentTypes?: Array<{ type: string; label: string; help?: string; placeholder?: string }>;
assetSlots: Array<{
key: string;
binding: string;
@@ -288,6 +288,41 @@ export const generatedTemplatePackageRegistry = [
}
]
},
"trustContentTypes": [
{
"type": "schedule",
"label": "出摊与营业安排",
"help": "说明固定出摊时间、临时营业安排或接受预订的时段。",
"placeholder": "例如:周一至周五 17:00 - 22:30"
},
{
"type": "coverage",
"label": "取餐与配送范围",
"help": "说明服务地点、取餐方式和可配送范围。",
"placeholder": "例如:支持校内宿舍楼下配送"
},
{
"type": "process",
"label": "定制餐品流程",
"help": "每行写一步,从提出需求到完成交付。",
"placeholder": "例如:提交需求\n确认菜单\n制作交付"
},
{
"type": "credential",
"label": "食品安全与制作标准",
"help": "填写让顾客放心的资质、卫生或制作标准。"
},
{
"type": "case",
"label": "客户案例与反馈",
"help": "填写代表性订单、活动案例或客户评价。"
},
{
"type": "promise",
"label": "回复与服务承诺",
"help": "说明回复时间、退改规则或服务承诺。"
}
],
"sampleContent": {
"food": {
"templateKey": "food",
@@ -681,6 +716,39 @@ export const generatedTemplatePackageRegistry = [
}
]
},
"trustContentTypes": [
{
"type": "schedule",
"label": "服务与合作安排",
"help": "说明可预约时间、服务周期或项目排期。"
},
{
"type": "coverage",
"label": "服务范围与适用对象",
"help": "说明服务地区、项目类型或合作边界。"
},
{
"type": "process",
"label": "合作流程",
"help": "每行写一步,从初次沟通到交付完成。",
"placeholder": "例如:需求沟通\n方案确认\n落地交付"
},
{
"type": "credential",
"label": "专业资历与方法",
"help": "填写经验、资质、专业标准或工作方法。"
},
{
"type": "case",
"label": "项目案例与客户反馈",
"help": "填写代表性项目、成果或客户评价。"
},
{
"type": "promise",
"label": "合作预期与响应承诺",
"help": "说明回复时间、合作边界和后续跟进方式。"
}
],
"sampleContent": {
"doors": {
"templateKey": "doors",
@@ -912,4 +980,4 @@ export const generatedTemplatePackageRegistry = [
}
];
export const generatedTemplatePackageRegistryHash =
"ebcac61077ff8d4097065555e86c651b93f99f91196b55b9503a13c6dcb9631a";
"afbd1045ccdc7eda85bd9707ce27083ba699899f115a26a3c60459a88a5e5148";
+6
View File
@@ -225,6 +225,12 @@ export interface TemplatePackageManifest {
fields: readonly { key: string; binding: string; label: string; required?: boolean }[];
}[];
};
trustContentTypes?: readonly {
type: string;
label: string;
help?: string;
placeholder?: string;
}[];
sampleContent?: Partial<Record<BrandTemplateKey, TemplateSampleContent>>;
}
@@ -281,6 +281,14 @@
}
]
},
"trustContentTypes": [
{ "type": "schedule", "label": "出摊与营业安排", "help": "说明固定出摊时间、临时营业安排或接受预订的时段。", "placeholder": "例如:周一至周五 17:00 - 22:30" },
{ "type": "coverage", "label": "取餐与配送范围", "help": "说明服务地点、取餐方式和可配送范围。", "placeholder": "例如:支持校内宿舍楼下配送" },
{ "type": "process", "label": "定制餐品流程", "help": "每行写一步,从提出需求到完成交付。", "placeholder": "例如:提交需求\n确认菜单\n制作交付" },
{ "type": "credential", "label": "食品安全与制作标准", "help": "填写让顾客放心的资质、卫生或制作标准。" },
{ "type": "case", "label": "客户案例与反馈", "help": "填写代表性订单、活动案例或客户评价。" },
{ "type": "promise", "label": "回复与服务承诺", "help": "说明回复时间、退改规则或服务承诺。" }
],
"sampleContent": {
"food": {
"templateKey": "food",
+24
View File
@@ -64,6 +64,13 @@ export type TemplateAdminManifest = {
sections: TemplateAdminSection[];
};
export type TemplateTrustContentType = {
type: "schedule" | "coverage" | "process" | "credential" | "case" | "promise" | (string & {});
label: string;
help?: string;
placeholder?: string;
};
export type TemplateSampleContent = {
templateKey: string;
offerings: Array<Record<string, unknown>>;
@@ -96,6 +103,7 @@ export type TemplatePackageManifest = {
dataSlots: TemplateDataSlot[];
assetSlots: TemplateAssetSlot[];
admin: TemplateAdminManifest;
trustContentTypes?: TemplateTrustContentType[];
sampleContent?: Record<string, TemplateSampleContent>;
};
@@ -125,6 +133,22 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
errors.push("data slot source is invalid");
}
}
if (manifest.trustContentTypes !== undefined) {
if (!Array.isArray(manifest.trustContentTypes))
errors.push("trustContentTypes must be an array");
else {
for (const [index, item] of manifest.trustContentTypes.entries()) {
if (!item || typeof item !== "object") {
errors.push(`trustContentTypes.${index} must be an object`);
continue;
}
if (typeof item.type !== "string" || !item.type.trim())
errors.push(`trustContentTypes.${index}.type is required`);
if (typeof item.label !== "string" || !item.label.trim())
errors.push(`trustContentTypes.${index}.label is required`);
}
}
}
if (!Array.isArray(manifest.assetSlots)) errors.push("assetSlots must be an array");
else {
for (const slot of manifest.assetSlots) {
@@ -269,6 +269,14 @@
}
]
},
"trustContentTypes": [
{ "type": "schedule", "label": "服务与合作安排", "help": "说明可预约时间、服务周期或项目排期。" },
{ "type": "coverage", "label": "服务范围与适用对象", "help": "说明服务地区、项目类型或合作边界。" },
{ "type": "process", "label": "合作流程", "help": "每行写一步,从初次沟通到交付完成。", "placeholder": "例如:需求沟通\n方案确认\n落地交付" },
{ "type": "credential", "label": "专业资历与方法", "help": "填写经验、资质、专业标准或工作方法。" },
{ "type": "case", "label": "项目案例与客户反馈", "help": "填写代表性项目、成果或客户评价。" },
{ "type": "promise", "label": "合作预期与响应承诺", "help": "说明回复时间、合作边界和后续跟进方式。" }
],
"sampleContent": {
"doors": {
"templateKey": "doors",