refactor: 模板注册与默认模板收敛到目录驱动
This commit is contained in:
1 parent
f87b26b201
commit
89fdfd7d83
25 files changed
+122
-96
No files matched your search
@@ -22,6 +22,7 @@ import {
|
||||
UpdateTrustContentDto,
|
||||
} from "../../admin.dto.js";
|
||||
import {
|
||||
defaultVisualTemplateKey,
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
isVisualTemplateCompatible,
|
||||
@@ -278,7 +279,7 @@ export class AdminConfigController {
|
||||
const currentKey =
|
||||
typeof config.visualTemplateKey === "string"
|
||||
? config.visualTemplateKey
|
||||
: "linjing-editorial";
|
||||
: defaultVisualTemplateKey;
|
||||
const current = getVisualTemplate(currentKey);
|
||||
return {
|
||||
current: current
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { BrandReleaseSnapshot } from "../../brand-release.service.js";
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import {
|
||||
capabilityPlugins,
|
||||
defaultBrandTemplateKey,
|
||||
type BrandTemplateKey,
|
||||
getBrandTemplate,
|
||||
getDefaultVisualTemplateKey,
|
||||
@@ -96,7 +97,7 @@ export function assemblePublicWorkspace(input: {
|
||||
asString(releaseSnapshot.templateKey) ||
|
||||
asString(installationData.templateKey) ||
|
||||
asString(brandData.templateKey) ||
|
||||
"personal";
|
||||
defaultBrandTemplateKey;
|
||||
const template = releaseSnapshot.templateDefinition ?? getBrandTemplate(templateKey);
|
||||
const capabilityData = asArray(releaseSnapshot.capabilities) as Array<Record<string, unknown>>;
|
||||
const capabilities = capabilityData.length
|
||||
|
||||
@@ -2,12 +2,16 @@ import { BadRequestException, Controller, Get, Param, Query } from "@nestjs/comm
|
||||
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||
import { BrandReleaseService } from "../../brand-release.service.js";
|
||||
import {
|
||||
defaultBrandTemplateKey,
|
||||
defaultVisualTemplateKey,
|
||||
brandTemplates,
|
||||
brandTemplateKeys,
|
||||
getBrandTemplate,
|
||||
getVisualTemplate,
|
||||
isVisualTemplateCompatible,
|
||||
resolveCapabilities,
|
||||
visualTemplates,
|
||||
visualTemplateKeys,
|
||||
} from "@personal-brand/config";
|
||||
|
||||
@Controller("public")
|
||||
@@ -74,15 +78,15 @@ export class PublicTemplateController {
|
||||
@Get()
|
||||
list(): unknown {
|
||||
return {
|
||||
industries: Object.values(brandTemplates),
|
||||
visuals: Object.values(visualTemplates),
|
||||
industries: brandTemplateKeys.map((key) => brandTemplates[key]),
|
||||
visuals: visualTemplateKeys.map((key) => visualTemplates[key]),
|
||||
};
|
||||
}
|
||||
|
||||
@Get("preview")
|
||||
preview(
|
||||
@Query("industry") industry = "personal",
|
||||
@Query("visual") visual = "linjing-editorial",
|
||||
@Query("industry") industry = defaultBrandTemplateKey,
|
||||
@Query("visual") visual = defaultVisualTemplateKey,
|
||||
): unknown {
|
||||
const industryTemplate = getBrandTemplate(industry);
|
||||
const visualTemplate = getVisualTemplate(visual);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { PrismaService } from "../../prisma.service.js";
|
||||
import {
|
||||
defaultBrandTemplateKey,
|
||||
getDefaultVisualTemplateKey,
|
||||
getTemplatePackageManifestForVisualKey,
|
||||
} from "@personal-brand/config";
|
||||
@@ -28,7 +29,7 @@ export class AdminWorkspaceService {
|
||||
const templateKey =
|
||||
typeof config.visualTemplateKey === "string"
|
||||
? config.visualTemplateKey
|
||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? "personal");
|
||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? defaultBrandTemplateKey);
|
||||
const manifest = getTemplatePackageManifestForVisualKey(templateKey);
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user