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