feat: 完善模板驱动的品牌内容工作台
This commit is contained in:
1 parent
77224ea51f
commit
dd55af8d73
46 files changed
+2204
-295
No files matched your search
@@ -7,24 +7,20 @@ import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
import { PresentationEditor } from "./PresentationEditor.js";
|
||||
|
||||
function textValue(value: unknown): string {
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
export function BrandPage() {
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [form] = Form.useForm<BrandProfile>();
|
||||
const brand = useQuery({ queryKey: ["admin-brand"], queryFn: () => client.getAdminBrand() });
|
||||
const workspace = useQuery({
|
||||
queryKey: ["admin-workspace"],
|
||||
queryFn: () => client.getAdminWorkspace(),
|
||||
});
|
||||
const template = useQuery({
|
||||
queryKey: ["template", brand.data?.templateKey],
|
||||
queryFn: () => client.getPublicTemplate(brand.data!.templateKey),
|
||||
enabled: Boolean(brand.data?.templateKey),
|
||||
});
|
||||
const runtime = useQuery({
|
||||
queryKey: ["public-runtime-workspace"],
|
||||
queryFn: () => client.getPublicWorkspace(),
|
||||
});
|
||||
const save = useMutation({
|
||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
@@ -148,43 +144,10 @@ export function BrandPage() {
|
||||
</Space>
|
||||
</Form>
|
||||
<PresentationEditor
|
||||
initialValue={{
|
||||
identity: {
|
||||
founder: textValue(brand.data.config?.founder),
|
||||
title: textValue(brand.data.config?.title),
|
||||
slogan: textValue(brand.data.config?.slogan),
|
||||
phone: textValue(brand.data.config?.phone),
|
||||
wechat: textValue(brand.data.config?.wechat),
|
||||
studioAddress: textValue(brand.data.config?.studioAddress),
|
||||
},
|
||||
...((brand.data.config?.visualPresentation as {
|
||||
home?: Record<string, string>;
|
||||
offerings?: Record<string, string>;
|
||||
detail?: Record<string, string>;
|
||||
profile?: Record<string, string>;
|
||||
inquiry?: Record<string, string>;
|
||||
success?: Record<string, string>;
|
||||
records?: Record<string, string>;
|
||||
}) ?? {}),
|
||||
}}
|
||||
runtimeValue={
|
||||
runtime.data?.brand
|
||||
? {
|
||||
identity: {
|
||||
founder: textValue(runtime.data.brand.config?.founder),
|
||||
title: textValue(runtime.data.brand.config?.title),
|
||||
slogan: textValue(runtime.data.brand.config?.slogan),
|
||||
},
|
||||
...((runtime.data.brand.config?.visualPresentation as {
|
||||
home?: Record<string, string>;
|
||||
inquiry?: Record<string, string>;
|
||||
profile?: Record<string, string>;
|
||||
}) ?? {}),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
runtimeLoading={runtime.isLoading}
|
||||
runtimeError={runtime.error}
|
||||
templateContent={workspace.data?.templateContent}
|
||||
config={brand.data.config}
|
||||
loading={workspace.isLoading}
|
||||
error={workspace.error}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={24} xl={9}>
|
||||
|
||||
Reference in new issue
Block a user