feat: 增加视觉模板预览与配置合并
This commit is contained in:
1 parent
facf261bd6
commit
4810ed7bde
3 files changed
+56
-2
No files matched your search
+43
-2
@@ -640,17 +640,58 @@ export class AdminConfigController {
|
|||||||
return this.prisma.brandProfile.findUnique({ where: { id: this.brandId() } });
|
return this.prisma.brandProfile.findUnique({ where: { id: this.brandId() } });
|
||||||
}
|
}
|
||||||
@Patch("brand")
|
@Patch("brand")
|
||||||
updateBrand(@Req() request: FastifyRequest, @Body() body: UpdateBrandDto): Promise<unknown> {
|
async updateBrand(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Body() body: UpdateBrandDto,
|
||||||
|
): Promise<unknown> {
|
||||||
this.requireAdmin(request);
|
this.requireAdmin(request);
|
||||||
const { config, ...fields } = body;
|
const { config, ...fields } = body;
|
||||||
|
const current = await this.prisma.brandProfile.findUnique({
|
||||||
|
where: { id: this.brandId() },
|
||||||
|
select: { config: true },
|
||||||
|
});
|
||||||
|
const currentConfig =
|
||||||
|
current?.config && typeof current.config === "object" && !Array.isArray(current.config)
|
||||||
|
? (current.config as Record<string, unknown>)
|
||||||
|
: {};
|
||||||
|
const nextConfig = config ? { ...currentConfig, ...config } : undefined;
|
||||||
return this.prisma.brandProfile.update({
|
return this.prisma.brandProfile.update({
|
||||||
where: { id: this.brandId() },
|
where: { id: this.brandId() },
|
||||||
data: {
|
data: {
|
||||||
...fields,
|
...fields,
|
||||||
...(config ? { config: config as Prisma.InputJsonValue } : {}),
|
...(nextConfig ? { config: nextConfig as Prisma.InputJsonValue } : {}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@Get("visual-template/preview")
|
||||||
|
getVisualTemplatePreview(@Req() request: FastifyRequest): unknown {
|
||||||
|
this.requireAdmin(request);
|
||||||
|
return this.prisma.brandProfile
|
||||||
|
.findUnique({ where: { id: this.brandId() }, select: { config: true } })
|
||||||
|
.then((brand) => {
|
||||||
|
const config =
|
||||||
|
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
|
||||||
|
? (brand.config as Record<string, unknown>)
|
||||||
|
: {};
|
||||||
|
const currentKey =
|
||||||
|
typeof config.visualTemplateKey === "string"
|
||||||
|
? config.visualTemplateKey
|
||||||
|
: "linjing-editorial";
|
||||||
|
const current = getVisualTemplate(currentKey) ?? getVisualTemplate("linjing-editorial");
|
||||||
|
return {
|
||||||
|
current: current
|
||||||
|
? {
|
||||||
|
key: current.key,
|
||||||
|
version: current.version,
|
||||||
|
name: current.name,
|
||||||
|
theme: current.theme,
|
||||||
|
variants: current.variants,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
available: ["linjing-editorial", "minimal-neutral"],
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
@Get("trust-content")
|
@Get("trust-content")
|
||||||
listTrustContent(@Req() request: FastifyRequest): Promise<unknown> {
|
listTrustContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
this.requireAdmin(request);
|
this.requireAdmin(request);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
- [x] Runtime Workspace 合并品牌配置中的视觉模板主题、版本和模块变体。
|
- [x] Runtime Workspace 合并品牌配置中的视觉模板主题、版本和模块变体。
|
||||||
- [x] Admin 工作空间支持切换视觉模板并保存 `visualTemplateKey`。
|
- [x] Admin 工作空间支持切换视觉模板并保存 `visualTemplateKey`。
|
||||||
- [x] 集成测试验证视觉模板切换会影响公开 Runtime Workspace 的主题和变体。
|
- [x] 集成测试验证视觉模板切换会影响公开 Runtime Workspace 的主题和变体。
|
||||||
|
- [x] 增加视觉模板预览接口,并在品牌配置更新时合并 config,避免覆盖其他配置。
|
||||||
- [ ] Phase 4:Capability Plugin。
|
- [ ] Phase 4:Capability Plugin。
|
||||||
- [ ] Phase 5:林境门作与第二行业双模板验证。
|
- [ ] Phase 5:林境门作与第二行业双模板验证。
|
||||||
- [ ] Phase 6:Stitch 到 Manifest 的转换流水线。
|
- [ ] Phase 6:Stitch 到 Manifest 的转换流水线。
|
||||||
|
|||||||
@@ -366,6 +366,18 @@ export class ApiClient {
|
|||||||
getAdminBrand(): Promise<BrandProfile> {
|
getAdminBrand(): Promise<BrandProfile> {
|
||||||
return this.request("/admin/config/brand");
|
return this.request("/admin/config/brand");
|
||||||
}
|
}
|
||||||
|
getAdminVisualTemplatePreview(): Promise<{
|
||||||
|
current: {
|
||||||
|
key: string;
|
||||||
|
version: string;
|
||||||
|
name: string;
|
||||||
|
theme: unknown;
|
||||||
|
variants: Record<string, string>;
|
||||||
|
} | null;
|
||||||
|
available: string[];
|
||||||
|
}> {
|
||||||
|
return this.request("/admin/config/visual-template/preview");
|
||||||
|
}
|
||||||
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile> {
|
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile> {
|
||||||
return this.request("/admin/config/brand", { method: "PATCH", body });
|
return this.request("/admin/config/brand", { method: "PATCH", body });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user