diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 621a05d..e49b374 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -39,7 +39,7 @@ import type { TransformFnParams } from "class-transformer"; import { IsBoolean, IsEnum, IsOptional, IsString } from "class-validator"; import { readIdentity, signIdentity } from "./auth.js"; import { ApiExceptionFilter, RequestIdMiddleware } from "./http.js"; -import { getBrandTemplate, resolveCapabilities } from "@personal-brand/config"; +import { getBrandTemplate, getVisualTemplate, resolveCapabilities } from "@personal-brand/config"; import { AdminWorkspaceController } from "./admin-workspace.controller.js"; import { TemplateWorkspaceService } from "./template-workspace.service.js"; import type { @@ -138,6 +138,16 @@ export class PublicWorkspaceController { ]); const templateKey = installation?.templateKey ?? brand?.templateKey ?? "personal"; const template = getBrandTemplate(templateKey); + const brandConfig = + brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config) + ? (brand.config as Record) + : {}; + const visualTemplateKey = + typeof brandConfig.visualTemplateKey === "string" + ? brandConfig.visualTemplateKey + : "linjing-editorial"; + const visualTemplate = + getVisualTemplate(visualTemplateKey) ?? getVisualTemplate("linjing-editorial"); const runtimeModules: RuntimeModule[] = modules.map((module) => ({ key: module.type, type: this.moduleType(module.type), @@ -222,7 +232,9 @@ export class PublicWorkspaceController { status: "enabled" as const, }), ), - theme: { colors: { background: "#F7F5F1", foreground: "#252525", accent: "#8A6846" } }, + theme: visualTemplate?.theme ?? { + colors: { background: "#F7F5F1", foreground: "#252525", accent: "#8A6846" }, + }, }; return { ...runtimeWorkspace, @@ -235,6 +247,14 @@ export class PublicWorkspaceController { name: template.name, } : null, + visualTemplate: visualTemplate + ? { + key: visualTemplate.key, + version: visualTemplate.version, + name: visualTemplate.name, + variants: visualTemplate.variants, + } + : null, capabilities: template?.capabilities ?? [], runtimeCapabilities: template ? resolveCapabilities(template.capabilities) : [], modules, diff --git a/docs/template-runtime-progress.md b/docs/template-runtime-progress.md index 8b6454a..45191bf 100644 --- a/docs/template-runtime-progress.md +++ b/docs/template-runtime-progress.md @@ -42,6 +42,7 @@ - [x] 建立固定页面状态、视口和视觉锚点清单,可供后续截图回归执行。 - [ ] Phase 3:模板中心、安装快照、升级和回滚。 - [x] 建立行业模板与视觉模板注册表,并注册林境建筑画册与极简留白视觉模板。 +- [x] Runtime Workspace 合并品牌配置中的视觉模板主题、版本和模块变体。 - [ ] Phase 4:Capability Plugin。 - [ ] Phase 5:林境门作与第二行业双模板验证。 - [ ] Phase 6:Stitch 到 Manifest 的转换流水线。 diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts index ecb67c7..f055d55 100644 --- a/packages/api-client/src/index.ts +++ b/packages/api-client/src/index.ts @@ -202,6 +202,12 @@ export interface PublicWorkspace { contractVersion: string; brand: BrandProfile | null; template: { key: BrandTemplateKey; version: string; name: string } | null; + visualTemplate?: { + key: string; + version: string; + name: string; + variants: Record; + } | null; capabilities: string[]; modules: BrandModule[]; runtimeModules: Array<{