feat: 在后台展示当前行业模板定义
This commit is contained in:
1 parent
c6785892ed
commit
6ee0dffdb8
2 files changed
+19
-1
No files matched your search
@@ -8,6 +8,11 @@ export function BrandPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const [form] = Form.useForm<BrandProfile>();
|
||||
const brand = useQuery({ queryKey: ["admin-brand"], queryFn: () => client.getAdminBrand() });
|
||||
const template = useQuery({
|
||||
queryKey: ["template", brand.data?.templateKey],
|
||||
queryFn: () => client.getPublicTemplate(brand.data!.templateKey as "personal" | "food"),
|
||||
enabled: Boolean(brand.data?.templateKey),
|
||||
});
|
||||
const save = useMutation({
|
||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
@@ -18,7 +23,10 @@ export function BrandPage() {
|
||||
if (brand.isLoading) return <Card loading />;
|
||||
if (brand.isError || !brand.data) return <Card>品牌配置加载失败</Card>;
|
||||
return (
|
||||
<Card title="品牌信任配置">
|
||||
<Card
|
||||
title="品牌信任配置"
|
||||
extra={template.data ? `${template.data.name}:${template.data.description}` : undefined}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
|
||||
@@ -101,6 +101,13 @@ export interface ApiErrorBody {
|
||||
error: { code: string; message: string };
|
||||
requestId: string | null;
|
||||
}
|
||||
export interface BrandTemplateDefinition {
|
||||
key: "personal" | "food";
|
||||
name: string;
|
||||
description: string;
|
||||
serviceCategories: string[];
|
||||
trustContentTypes: string[];
|
||||
}
|
||||
|
||||
export class ApiClientError extends Error {
|
||||
constructor(
|
||||
@@ -208,6 +215,9 @@ export class ApiClient {
|
||||
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile> {
|
||||
return this.request("/admin/config/brand", { method: "PATCH", body });
|
||||
}
|
||||
getPublicTemplate(key: "personal" | "food"): Promise<BrandTemplateDefinition> {
|
||||
return this.request(`/public/templates/${key}`);
|
||||
}
|
||||
updateAdminService(id: string, body: ServiceUpdate): Promise<PublicService> {
|
||||
return this.request(`/admin/config/services/${encodeURIComponent(id)}`, {
|
||||
method: "PATCH",
|
||||
|
||||
Reference in new issue
Block a user