feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -3,7 +3,13 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { BrandProfile } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
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();
|
||||
@@ -15,6 +21,10 @@ export function BrandPage() {
|
||||
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: () => {
|
||||
@@ -115,13 +125,17 @@ export function BrandPage() {
|
||||
</Form.Item>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="avatarUrl" label="头像 URL">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="avatarUrl"
|
||||
label="头像图片地址"
|
||||
help="粘贴一张可公开访问的图片地址。"
|
||||
>
|
||||
<ImageUrlField />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="coverUrl" label="品牌封面 URL">
|
||||
<Input />
|
||||
<Form.Item name="coverUrl" label="品牌封面图片地址" help="建议使用横向图片。">
|
||||
<ImageUrlField />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -133,6 +147,45 @@ export function BrandPage() {
|
||||
</Button>
|
||||
</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}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={24} xl={9}>
|
||||
<Card title="公开表达预览" style={{ position: "sticky", top: 24 }}>
|
||||
|
||||
Reference in new issue
Block a user