refactor: 退役运行时视觉模块并泛化模板门禁
This commit is contained in:
1 parent
25d1fe983c
commit
e2e2340bfe
56 files changed
+290
-1037
No files matched your search
@@ -12,12 +12,7 @@ import {
|
||||
getDefaultVisualTemplateKey,
|
||||
getTemplatePackageManifestForVisualKey,
|
||||
} from "@personal-brand/config";
|
||||
import type {
|
||||
RuntimeInquiryField,
|
||||
RuntimeOffering,
|
||||
RuntimeWorkspace,
|
||||
RuntimeModule,
|
||||
} from "@personal-brand/types";
|
||||
import type { RuntimeInquiryField, RuntimeOffering, RuntimeWorkspace } from "@personal-brand/types";
|
||||
|
||||
@Controller("public/workspace")
|
||||
export class PublicWorkspaceController {
|
||||
@@ -42,7 +37,6 @@ export class PublicWorkspaceController {
|
||||
brand: null,
|
||||
template: null,
|
||||
visualTemplate: null,
|
||||
modules: [],
|
||||
offerings: [],
|
||||
inquiryForms: [],
|
||||
capabilities: [],
|
||||
@@ -53,9 +47,6 @@ export class PublicWorkspaceController {
|
||||
};
|
||||
}
|
||||
const brandData = this.jsonObject(releaseSnapshot.brand);
|
||||
const modulesData = this.jsonArray(releaseSnapshot.modules).filter(
|
||||
(item) => this.jsonObject(item).isEnabled === true,
|
||||
) as Array<Record<string, unknown>>;
|
||||
const offeringsData = this.jsonArray(releaseSnapshot.offerings).filter(
|
||||
(item) => this.jsonObject(item).isEnabled === true,
|
||||
) as Array<Record<string, unknown>>;
|
||||
@@ -120,17 +111,6 @@ export class PublicWorkspaceController {
|
||||
...brandData,
|
||||
...brandConfig,
|
||||
};
|
||||
const runtimeModules: RuntimeModule[] = modulesData.map((item) => ({
|
||||
key: this.string(item.type, "custom"),
|
||||
type: this.moduleType(this.string(item.type, "custom")),
|
||||
version: "1.0.0",
|
||||
propsSchema: `module.${this.string(item.type, "custom")}.v1`,
|
||||
dataSource: this.string(item.type, "custom"),
|
||||
config: this.jsonObject(item.config),
|
||||
source:
|
||||
item.source === "custom" ? "custom" : item.source === "template" ? "template" : "core",
|
||||
schemaVersion: "1.0",
|
||||
}));
|
||||
const runtimeOfferings: RuntimeOffering[] = offeringsData.map((raw) => {
|
||||
const item = raw;
|
||||
const config = this.jsonObject(item.config);
|
||||
@@ -282,7 +262,6 @@ export class PublicWorkspaceController {
|
||||
page: templatePackageManifest.entrypoints[tab.page] ?? tab.page,
|
||||
})) ?? [],
|
||||
},
|
||||
modules: runtimeModules,
|
||||
offerings: runtimeOfferings,
|
||||
inquiryForms: formsData.map((raw) => {
|
||||
const form = this.jsonObject(raw);
|
||||
@@ -355,32 +334,6 @@ export class PublicWorkspaceController {
|
||||
private jsonArray(value: unknown): Prisma.JsonValue[] {
|
||||
return Array.isArray(value) ? (value as Prisma.JsonValue[]) : [];
|
||||
}
|
||||
private moduleType(value: string): RuntimeModule["type"] {
|
||||
const aliases: Record<string, RuntimeModule["type"]> = {
|
||||
identity: "brand-hero",
|
||||
trust: "trust-proof",
|
||||
offering: "offering-list",
|
||||
contact: "founder-card",
|
||||
};
|
||||
const known: RuntimeModule["type"][] = [
|
||||
"brand-hero",
|
||||
"founder-card",
|
||||
"trust-proof",
|
||||
"offering-list",
|
||||
"offering-detail",
|
||||
"gallery",
|
||||
"timeline",
|
||||
"faq",
|
||||
"contact",
|
||||
"inquiry",
|
||||
"records",
|
||||
"custom",
|
||||
];
|
||||
const type = aliases[value] ?? value;
|
||||
return (
|
||||
known.includes(type as RuntimeModule["type"]) ? type : "custom"
|
||||
) as RuntimeModule["type"];
|
||||
}
|
||||
private sectionType(value: unknown): RuntimeOffering["sections"][number]["type"] {
|
||||
const known = ["text", "image-list", "timeline", "faq", "specification"] as const;
|
||||
return known.includes(value as (typeof known)[number])
|
||||
|
||||
@@ -94,12 +94,6 @@ export class PublicTemplateController {
|
||||
visual: visualTemplate,
|
||||
runtime: {
|
||||
schemaVersion: "1.0.0",
|
||||
modules: industryTemplate.modules.map((module) => ({
|
||||
key: module.key,
|
||||
type: module.type,
|
||||
title: module.title,
|
||||
variant: visualTemplate.variants[module.type] ?? "default",
|
||||
})),
|
||||
capabilities: resolveCapabilities(industryTemplate.capabilities),
|
||||
theme: visualTemplate.theme,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user