feat: 重构品牌表达编辑工作台
This commit is contained in:
1 parent
e402ba58d9
commit
24ab55c0d0
1 file changed
+145
-47
@@ -1,7 +1,9 @@
|
||||
import { Button, Card, Form, Input, Select, message } from "antd";
|
||||
import { Button, Card, Col, Form, Input, Row, Select, Space, Tag, Typography, message } from "antd";
|
||||
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 { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
|
||||
export function BrandPage() {
|
||||
const client = createApiClient();
|
||||
@@ -16,56 +18,152 @@ export function BrandPage() {
|
||||
const save = useMutation({
|
||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||
onSuccess: () => {
|
||||
message.success("品牌配置已保存");
|
||||
message.success("品牌表达已保存");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
||||
},
|
||||
});
|
||||
if (brand.isLoading) return <Card loading />;
|
||||
if (brand.isError || !brand.data) return <Card>品牌配置加载失败</Card>;
|
||||
return (
|
||||
<Card
|
||||
title="品牌信任配置"
|
||||
extra={template.data ? `${template.data.name}:${template.data.description}` : undefined}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={brand.data}
|
||||
onFinish={(values) => save.mutate(values)}
|
||||
>
|
||||
<Form.Item name="templateKey" label="行业模板">
|
||||
<Select
|
||||
options={[
|
||||
{ value: "personal", label: "个人品牌" },
|
||||
{ value: "food", label: "餐饮模板" },
|
||||
]}
|
||||
<QueryState loading={brand.isLoading} error={brand.error} onRetry={() => void brand.refetch()}>
|
||||
{!brand.data ? null : (
|
||||
<>
|
||||
<AdminPageHeader
|
||||
title="品牌表达"
|
||||
description="先让访客理解你是谁、服务谁,以及为什么值得信任。"
|
||||
extra={<Tag color="blue">{template.data?.name ?? "当前模板"}</Tag>}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name="name" label="品牌名称" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="tagline" label="一句话定位">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="description" label="品牌简介">
|
||||
<Input.TextArea rows={5} />
|
||||
</Form.Item>
|
||||
<Form.Item name="hours" label="服务时间">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="address" label="所在位置">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="contactPhone" label="联系电话">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="contactWechat" label="微信号">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit" loading={save.isPending}>
|
||||
保存配置
|
||||
</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
<Row gutter={[24, 24]} align="top">
|
||||
<Col xs={24} xl={15}>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={brand.data}
|
||||
onFinish={(values) => save.mutate(values)}
|
||||
>
|
||||
<Card
|
||||
title="我是谁"
|
||||
extra={<Typography.Text type="secondary">公开展示</Typography.Text>}
|
||||
>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="品牌名称"
|
||||
help="可以是个人姓名、工作室名称或品牌名。"
|
||||
rules={[{ required: true, message: "请输入品牌名称" }]}
|
||||
>
|
||||
<Input size="large" placeholder="例如:林然|品牌顾问" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="tagline"
|
||||
label="一句话定位"
|
||||
help="用一句话说明你为谁提供什么价值。"
|
||||
rules={[{ required: true, message: "请输入一句话定位" }]}
|
||||
>
|
||||
<Input size="large" placeholder="例如:帮助独立创作者建立可信的个人品牌" />
|
||||
</Form.Item>
|
||||
<Form.Item name="description" label="品牌简介" help="介绍背景、方法和合作风格。">
|
||||
<Input.TextArea
|
||||
rows={5}
|
||||
showCount
|
||||
maxLength={500}
|
||||
placeholder="让第一次认识你的人快速建立基本信任。"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Card>
|
||||
<Card title="如何联系与合作" style={{ marginTop: 24 }}>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="hours" label="可联系时间">
|
||||
<Input placeholder="例如:工作日 10:00–18:00" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="address" label="所在位置">
|
||||
<Input placeholder="城市或服务范围" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="contactPhone" label="联系电话">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="contactWechat" label="微信号">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
<Form.Item
|
||||
name="deliveryNote"
|
||||
label="合作预期"
|
||||
help="说明响应时间、合作方式或重要边界。"
|
||||
>
|
||||
<Input.TextArea rows={3} placeholder="例如:收到咨询后 1 个工作日内回复。" />
|
||||
</Form.Item>
|
||||
</Card>
|
||||
<Card title="模板与品牌视觉" style={{ marginTop: 24 }}>
|
||||
<Form.Item
|
||||
name="templateKey"
|
||||
label="业务表达模板"
|
||||
help="模板只改变业务表达,不改变个人品牌主线。"
|
||||
>
|
||||
<Select
|
||||
disabled
|
||||
options={[
|
||||
{ value: "personal", label: "个人品牌" },
|
||||
{ value: "food", label: "餐饮模板" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Row gutter={16}>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="avatarUrl" label="头像 URL">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Form.Item name="coverUrl" label="品牌封面 URL">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
</Card>
|
||||
<Space direction="vertical" style={{ width: "100%", marginTop: 24 }}>
|
||||
<MutationError error={save.error} />
|
||||
<Button type="primary" htmlType="submit" loading={save.isPending} size="large">
|
||||
保存品牌表达
|
||||
</Button>
|
||||
</Space>
|
||||
</Form>
|
||||
</Col>
|
||||
<Col xs={24} xl={9}>
|
||||
<Card title="公开表达预览" style={{ position: "sticky", top: 24 }}>
|
||||
<Typography.Text type="secondary">小程序首页将优先使用以下信息</Typography.Text>
|
||||
<Typography.Title level={3}>{brand.data.name || "品牌名称"}</Typography.Title>
|
||||
<Typography.Title level={5}>{brand.data.tagline || "一句话定位"}</Typography.Title>
|
||||
<Typography.Paragraph>
|
||||
{brand.data.description || "品牌简介将在这里展示。"}
|
||||
</Typography.Paragraph>
|
||||
<Typography.Text strong>合作方式</Typography.Text>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{brand.data.deliveryNote || "补充你的响应时间和合作预期。"}
|
||||
</Typography.Paragraph>
|
||||
<Space wrap>
|
||||
{brand.data.contactPhone && <Tag>电话:{brand.data.contactPhone}</Tag>}
|
||||
{brand.data.contactWechat && <Tag>微信:{brand.data.contactWechat}</Tag>}
|
||||
{brand.data.hours && <Tag>时间:{brand.data.hours}</Tag>}
|
||||
</Space>
|
||||
</Card>
|
||||
{template.data && (
|
||||
<Card title="模板说明" style={{ marginTop: 24 }}>
|
||||
<Typography.Paragraph>{template.data.description}</Typography.Paragraph>
|
||||
<Typography.Text type="secondary">
|
||||
服务分类:{template.data.serviceCategories.join("、")}
|
||||
</Typography.Text>
|
||||
</Card>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
</>
|
||||
)}
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user