feat: 让模板中心由注册表驱动

This commit is contained in:
que01 committed 2026-09-22 23:41:03 +08:00
1 parent a30c939f90
commit 0d98d23892
4 files changed
+38 -7

No files matched your search

@@ -39,6 +39,10 @@ export function WorkspacePage() {
queryKey: ["public-runtime-workspace"],
queryFn: () => client.getPublicWorkspace(),
});
const templateCatalog = useQuery({
queryKey: ["template-catalog"],
queryFn: () => client.listPublicTemplates(),
});
const visualTemplate = useMutation({
mutationFn: (key: string) =>
client.updateAdminBrand({
@@ -250,12 +254,15 @@ export function WorkspacePage() {
title="行业模板"
extra={
<Space>
<Button onClick={() => install.mutate("personal")} loading={install.isPending}>
安装个人品牌模板
</Button>
<Button onClick={() => install.mutate("food")} loading={install.isPending}>
安装餐饮模板
</Button>
{(templateCatalog.data?.industries ?? []).map((item) => (
<Button
key={item.key}
onClick={() => install.mutate(item.key)}
loading={install.isPending}
>
安装{item.name}
</Button>
))}
</Space>
}
>
+11 -1
View File
@@ -39,7 +39,13 @@ 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, getVisualTemplate, resolveCapabilities } from "@personal-brand/config";
import {
brandTemplates,
getBrandTemplate,
getVisualTemplate,
resolveCapabilities,
visualTemplates,
} from "@personal-brand/config";
import { AdminWorkspaceController } from "./admin-workspace.controller.js";
import { TemplateWorkspaceService } from "./template-workspace.service.js";
import type {
@@ -99,6 +105,10 @@ export class PublicTrustContentController {
@Controller("public/templates")
export class PublicTemplateController {
@Get()
list(): unknown {
return { industries: Object.values(brandTemplates), visuals: Object.values(visualTemplates) };
}
@Get(":key")
get(@Param("key") key: string): unknown {
const template = getBrandTemplate(key);
+1
View File
@@ -49,6 +49,7 @@
- [x] 后台视觉模板切换增加确认和差异说明,避免误操作覆盖业务内容。
- [x] 视觉模板切换记录历史快照,并提供后台历史查询接口。
- [x] 后台展示视觉模板历史并支持安全回滚。
- [x] 模板中心行业 / 视觉目录由后端注册表接口驱动。
- [ ] Phase 4:Capability Plugin。
- [ ] Phase 5:林境门作与第二行业双模板验证。
- [ ] Phase 6:Stitch 到 Manifest 的转换流水线。
+13
View File
@@ -392,6 +392,19 @@ export class ApiClient {
getPublicTemplate(key: "personal" | "food"): Promise<BrandTemplateDefinition> {
return this.request(`/public/templates/${key}`);
}
listPublicTemplates(): Promise<{
industries: BrandTemplateDefinition[];
visuals: Array<{
key: string;
version: string;
name: string;
description: string;
variants: Record<string, string>;
theme: unknown;
}>;
}> {
return this.request("/public/templates");
}
getPublicOffering(id: string): Promise<Offering> {
return this.request(`/public/offerings/${encodeURIComponent(id)}`);
}