统一模板包 visual 契约并补齐完成证据;修复 release 版本一致性、管理员 token 撤销、CORS 与默认品牌配置;收敛依赖安全风险并完成全量回归验证。
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import type { VisualTemplateKey } from "./template-keys.js";
|
|
import type { VisualTemplateDefinition } from "./brand-contracts.js";
|
|
import { templatePackageRegistry } from "./template-packages.js";
|
|
|
|
export const visualTemplateKeys: VisualTemplateKey[] = templatePackageRegistry.map(
|
|
(manifest) => manifest.visualTemplateKey,
|
|
);
|
|
|
|
export function listVisualTemplateKeys(): VisualTemplateKey[] {
|
|
return visualTemplateKeys;
|
|
}
|
|
|
|
export function getVisualTemplate(key: string): VisualTemplateDefinition | undefined {
|
|
const manifest = templatePackageRegistry.find((item) => item.visualTemplateKey === key);
|
|
if (!manifest) return undefined;
|
|
const presentation = manifest.visualPresentation;
|
|
return {
|
|
key: manifest.visualTemplateKey,
|
|
version: manifest.version,
|
|
name: manifest.displayName,
|
|
description: presentation.description,
|
|
supportedIndustryTemplates: [...manifest.supportedIndustryTemplates],
|
|
variants: { ...presentation.variants },
|
|
theme: {
|
|
colors: { ...presentation.theme.colors },
|
|
radius: { ...presentation.theme.radius },
|
|
},
|
|
...(presentation.layout
|
|
? {
|
|
layout: {
|
|
home: [...presentation.layout.home],
|
|
offerings: [...presentation.layout.offerings],
|
|
detail: [...presentation.layout.detail],
|
|
profile: [...presentation.layout.profile],
|
|
},
|
|
}
|
|
: {}),
|
|
};
|
|
}
|