feat: 完善模板内容后台配置能力
This commit is contained in:
1 parent
2bc2193b44
commit
9266ec824a
37 files changed
+2273
-63
No files matched your search
@@ -45,7 +45,14 @@ export type TemplateAdminField = {
|
||||
binding: string;
|
||||
label: string;
|
||||
help?: string;
|
||||
input: "text" | "textarea" | "phone" | "image" | "number";
|
||||
input: "text" | "textarea" | "phone" | "image" | "number" | "list";
|
||||
itemFields?: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
input?: "text" | "textarea";
|
||||
required?: boolean;
|
||||
}>;
|
||||
itemValueKey?: string;
|
||||
required?: boolean;
|
||||
maxLength?: number;
|
||||
placeholder?: string;
|
||||
@@ -70,6 +77,7 @@ export type TemplateTrustContentType = {
|
||||
help?: string;
|
||||
placeholder?: string;
|
||||
required?: boolean;
|
||||
configFields?: TemplateAdminField[];
|
||||
};
|
||||
|
||||
export type TemplateSampleContent = {
|
||||
@@ -147,6 +155,12 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
errors.push(`trustContentTypes.${index}.type is required`);
|
||||
if (typeof item.label !== "string" || !item.label.trim())
|
||||
errors.push(`trustContentTypes.${index}.label is required`);
|
||||
for (const field of item.configFields ?? []) {
|
||||
if (!field.key?.trim() || !field.binding?.startsWith("trust.config."))
|
||||
errors.push(`trustContentTypes.${index}.configFields binding is invalid`);
|
||||
if (field.input === "list" && !field.itemFields?.length)
|
||||
errors.push(`trustContentTypes.${index}.configFields list requires itemFields`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,6 +182,13 @@ export function validateTemplatePackageManifest(value: unknown): string[] {
|
||||
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 (field.input === "list" && !field.itemFields?.length)
|
||||
errors.push("list admin fields require itemFields");
|
||||
if (
|
||||
field.itemValueKey &&
|
||||
!field.itemFields?.some((item) => item.key === field.itemValueKey)
|
||||
)
|
||||
errors.push("list itemValueKey must match an itemField");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user