From 041a6a7f02bce46b92bf24993fd4f74b8ce2c9c5 Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 23 Sep 2026 01:07:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=97=A8=E7=AA=97?= =?UTF-8?q?=E8=A1=8C=E4=B8=9A=E6=A8=A1=E6=9D=BF=E5=A3=B0=E6=98=8E=E4=B8=8E?= =?UTF-8?q?=E9=AA=8C=E6=94=B6=E5=A4=B9=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/admin.dto.ts | 6 +-- apps/api/src/template-workspace.service.ts | 2 +- .../miniapp/test/fixtures/doors-industry.json | 19 ++++++++ apps/miniapp/test/validate-fixture.cjs | 2 +- packages/api-client/src/index.ts | 4 +- packages/config/src/index.ts | 44 ++++++++++++++++++- packages/types/src/index.ts | 2 +- 7 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 apps/miniapp/test/fixtures/doors-industry.json diff --git a/apps/api/src/admin.dto.ts b/apps/api/src/admin.dto.ts index 9736902..2f74171 100644 --- a/apps/api/src/admin.dto.ts +++ b/apps/api/src/admin.dto.ts @@ -13,7 +13,7 @@ import { export class UpdateBrandDto { @IsOptional() @IsString() name?: string; - @IsOptional() @IsIn(["food", "personal"]) templateKey?: "food" | "personal"; + @IsOptional() @IsIn(["food", "personal", "doors"]) templateKey?: "food" | "personal" | "doors"; @IsOptional() @IsString() tagline?: string; @IsOptional() @IsString() description?: string; @IsOptional() @IsString() avatarUrl?: string; @@ -75,8 +75,8 @@ export class UpdateBookingTagsDto { } export class InstallTemplateDto { - @IsIn(["personal", "food"]) - templateKey!: "personal" | "food"; + @IsIn(["personal", "food", "doors"]) + templateKey!: "personal" | "food" | "doors"; } export class UpdateCapabilityInstallationDto { diff --git a/apps/api/src/template-workspace.service.ts b/apps/api/src/template-workspace.service.ts index 2e193e9..72978de 100644 --- a/apps/api/src/template-workspace.service.ts +++ b/apps/api/src/template-workspace.service.ts @@ -6,7 +6,7 @@ import { PrismaService } from "./prisma.service.js"; @Injectable() export class TemplateWorkspaceService { constructor(private readonly prisma: PrismaService) {} - async install(brandId: string, templateKey: "personal" | "food") { + async install(brandId: string, templateKey: "personal" | "food" | "doors") { const template = getBrandTemplate(templateKey); if (!template) throw new BadRequestException("行业模板不存在"); const existing = await this.prisma.brandTemplateInstallation.findFirst({ where: { brandId } }); diff --git a/apps/miniapp/test/fixtures/doors-industry.json b/apps/miniapp/test/fixtures/doors-industry.json new file mode 100644 index 0000000..bcae965 --- /dev/null +++ b/apps/miniapp/test/fixtures/doors-industry.json @@ -0,0 +1,19 @@ +{ + "templateKey": "doors", + "version": "1.0.0", + "pages": ["home", "offerings", "detail", "inquiry", "success", "records", "profile"], + "layout": { "home": ["brand-hero", "founder-card", "trust-proof", "offering-list"] }, + "requiredModules": [ + "brand-hero", + "founder-card", + "trust-proof", + "offering-list", + "offering-detail", + "inquiry-form", + "records", + "profile", + "success-summary" + ], + "requiredCapabilities": ["offerings", "inquiry"], + "visualAnchors": { "home": ["brand-hero", "founder-card", "trust-proof", "offering-list"] } +} diff --git a/apps/miniapp/test/validate-fixture.cjs b/apps/miniapp/test/validate-fixture.cjs index 870041b..1cbd55f 100644 --- a/apps/miniapp/test/validate-fixture.cjs +++ b/apps/miniapp/test/validate-fixture.cjs @@ -1,7 +1,7 @@ const fs = require("node:fs"); const path = require("node:path"); const root = path.resolve(__dirname, ".."); -const fixtureFiles = ["linjing-door.json", "minimal-neutral.json"]; +const fixtureFiles = ["linjing-door.json", "minimal-neutral.json", "doors-industry.json"]; const fixtures = fixtureFiles.map((file) => JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", file), "utf8"))); for (const fixture of fixtures) { const modules = fixture.requiredModules.map((key) => path.join(root, "components/modules", key)); diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts index 42df767..4e808cd 100644 --- a/packages/api-client/src/index.ts +++ b/packages/api-client/src/index.ts @@ -104,7 +104,7 @@ export interface ApiErrorBody { requestId: string | null; } export interface BrandTemplateDefinition { - key: "personal" | "food"; + key: "personal" | "food" | "doors"; version: string; name: string; description: string; @@ -471,7 +471,7 @@ export class ApiClient { }> { return this.request("/admin/workspace"); } - installAdminTemplate(templateKey: "personal" | "food"): Promise { + installAdminTemplate(templateKey: "personal" | "food" | "doors"): Promise { return this.request("/admin/workspace/install", { method: "POST", body: { templateKey } }); } listAdminCapabilities(): Promise { diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index b2b0184..ec8c22d 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -1,6 +1,6 @@ export const configPackageName = "personal-brand-config"; -export type BrandTemplateKey = "personal" | "food"; +export type BrandTemplateKey = "personal" | "food" | "doors"; export type VisualTemplateKey = "linjing-editorial" | "minimal-neutral"; export type CapabilityKey = "offerings" | "inquiry" | "booking"; @@ -224,6 +224,48 @@ export const brandTemplates = { ], capabilities: ["offerings", "inquiry", "booking"], }, + doors: { + key: "doors", + version: "1.0.0", + name: "高端门窗模板", + description: "适用于别墅门、院门、室内门与定制门窗服务的行业模板。", + serviceCategories: ["entrance-door", "garden-door", "interior-door", "custom"], + trustContentTypes: [ + "profile", + "experience", + "credential", + "portfolio", + "process", + "testimonial", + ], + modules: [ + { key: "identity", type: "identity", title: "品牌身份", required: true }, + { key: "trust", type: "trust", title: "工艺与信任", required: true }, + { key: "offerings", type: "offering", title: "门窗系列", required: true }, + { key: "inquiry", type: "inquiry", title: "设计咨询", required: true }, + { key: "contact", type: "contact", title: "品牌表达", required: true }, + ], + fields: [ + { scope: "profile", key: "name", label: "品牌名称", type: "text", required: true }, + { scope: "profile", key: "tagline", label: "一句话定位", type: "text", required: true }, + { scope: "profile", key: "audience", label: "服务对象", type: "textarea", required: true }, + { + scope: "profile", + key: "valueProposition", + label: "提供的价值", + type: "textarea", + required: true, + }, + { + scope: "profile", + key: "trustProof", + label: "信任证明入口", + type: "textarea", + required: true, + }, + ], + capabilities: ["offerings", "inquiry"], + }, } satisfies Record; export function isBrandTemplateKey(value: string): value is BrandTemplateKey { diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index a297e54..82d1204 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -3,7 +3,7 @@ export type BookingRequestType = "package" | "private_chef" | "inquiry"; export type ContactPreference = "wechat" | "phone" | "none"; export type FulfillmentType = "pickup" | "delivery"; export type OrderStatus = BookingStatus; -export type BrandTemplateKey = "food" | "personal"; +export type BrandTemplateKey = "food" | "personal" | "doors"; export const BRAND_TEMPLATE = { FOOD: "food", PERSONAL: "personal" } as const satisfies Record< Uppercase, BrandTemplateKey