feat: 完善模板字段编辑与分类治理

This commit is contained in:
que01 committed 2026-10-11 23:07:53 +08:00
1 parent 91322fa9a0
commit 26bcb2b66e
23 files changed
+631 -250

No files matched your search

+2 -1
View File
@@ -7,6 +7,7 @@ import {
getDefaultVisualTemplateKey,
getTemplatePackageManifestForVisualKey,
} from "@personal-brand/config";
import type { TemplatePackageManifest } from "@personal-brand/config";
import { PrismaService } from "./prisma.service.js";
export interface BrandReleaseSnapshot {
@@ -16,7 +17,7 @@ export interface BrandReleaseSnapshot {
templateDefinition?: ReturnType<typeof getBrandTemplate> | null;
visualTemplateDefinition?: ReturnType<typeof getVisualTemplate> | null;
visualTemplateManifest?: ReturnType<typeof getVisualTemplateManifest> | null;
templatePackageManifest?: ReturnType<typeof getTemplatePackageManifestForVisualKey> | null;
templatePackageManifest?: TemplatePackageManifest | null;
brand: Record<string, unknown> | null;
installation: Record<string, unknown> | null;
fields: unknown[];
@@ -119,6 +119,14 @@ export class PublicWorkspaceService {
const templatePackageManifest =
releaseSnapshot.templatePackageManifest ??
getTemplatePackageManifestForVisualKey(visualTemplateKey);
const categoryOptions = new Map(
(templatePackageManifest?.admin.sections ?? [])
.filter((section) => section.target === "offering")
.flatMap((section) => section.fields)
.filter((field) => field.binding === "offering.config.categoryKey")
.flatMap((field) => field.options ?? [])
.map((option) => [option.value, option.label]),
);
// 标准 BrandProfile 字段优先,兼容旧模板仍使用的 config 字段。
// 这样后台编辑 description/contactPhone 等标准字段后,旧模板也会立即读取新值。
const runtimeBrand = projectBrandAliases(brandData, brandConfig);
@@ -177,7 +185,9 @@ export class PublicWorkspaceService {
...this.jsonObject(config.presentation),
categoryKey: typeof config.categoryKey === "string" ? config.categoryKey : "custom",
categoryLabel:
typeof config.categoryLabel === "string" ? config.categoryLabel : "业务提供项",
categoryOptions.get(
typeof config.categoryKey === "string" ? config.categoryKey : "custom",
) ?? "",
heroImage:
typeof config.detailHero === "string"
? config.detailHero