feat: 重构后台品牌工作台基础骨架
This commit is contained in:
1 parent
ac4abc1305
commit
e402ba58d9
4 files changed
+209
-5
No files matched your search
@@ -0,0 +1,119 @@
|
||||
import { Card, Col, List, Row, Space, Statistic, Tag, Typography } from "antd";
|
||||
import { useQueries } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { QueryState } from "../../components/QueryState.js";
|
||||
|
||||
export function OverviewPage() {
|
||||
const client = createApiClient();
|
||||
const results = useQueries({
|
||||
queries: [
|
||||
{ queryKey: ["admin-overview-brand"], queryFn: () => client.getAdminBrand() },
|
||||
{ queryKey: ["admin-overview-workspace"], queryFn: () => client.getAdminWorkspace() },
|
||||
{ queryKey: ["admin-overview-trust"], queryFn: () => client.listAdminTrustContent() },
|
||||
{ queryKey: ["admin-overview-offerings"], queryFn: () => client.listAdminOfferings() },
|
||||
{
|
||||
queryKey: ["admin-overview-submissions"],
|
||||
queryFn: () => client.listAdminInquirySubmissions(),
|
||||
},
|
||||
],
|
||||
});
|
||||
const loading = results.some((result) => result.isLoading);
|
||||
const error = results.find((result) => result.isError)?.error;
|
||||
const retry = () => results.forEach((result) => void result.refetch());
|
||||
const brand = results[0].data;
|
||||
const workspace = results[1].data;
|
||||
const trust = results[2].data;
|
||||
const offerings = results[3].data;
|
||||
const submissions = results[4].data;
|
||||
const checklist = [
|
||||
{ label: "品牌定位已填写", done: Boolean(brand?.name && brand.tagline) },
|
||||
{ label: "信任内容已发布", done: Boolean(trust?.some((item) => item.isPublished)) },
|
||||
{ label: "至少有一个公开业务提供项", done: Boolean(offerings?.some((item) => item.isEnabled)) },
|
||||
{ label: "咨询入口已配置", done: Boolean(workspace?.inquiryForm?.isEnabled) },
|
||||
];
|
||||
return (
|
||||
<QueryState loading={loading} error={error} onRetry={retry}>
|
||||
<AdminPageHeader
|
||||
title="品牌概览"
|
||||
description="从这里检查品牌表达、信任内容和业务承接是否完整。"
|
||||
/>
|
||||
<Space direction="vertical" size={24} style={{ width: "100%" }}>
|
||||
<Card>
|
||||
<Typography.Title level={3} style={{ marginTop: 0 }}>
|
||||
{brand?.name || "未命名品牌"}
|
||||
</Typography.Title>
|
||||
<Typography.Paragraph type="secondary">
|
||||
{brand?.tagline || "还没有设置一句话定位"}
|
||||
</Typography.Paragraph>
|
||||
<Tag color="blue">
|
||||
当前模板:{brand?.templateKey === "food" ? "餐饮模板" : "个人品牌"}
|
||||
</Tag>
|
||||
</Card>
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col xs={24} sm={12} lg={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="信任内容"
|
||||
value={trust?.filter((item) => item.isPublished).length ?? 0}
|
||||
suffix="条已发布"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} sm={12} lg={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="业务提供项"
|
||||
value={offerings?.filter((item) => item.isEnabled).length ?? 0}
|
||||
suffix="项公开"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} sm={12} lg={6}>
|
||||
<Card>
|
||||
<Statistic title="咨询提交" value={submissions?.length ?? 0} suffix="条" />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} sm={12} lg={6}>
|
||||
<Card>
|
||||
<Statistic
|
||||
title="工作空间模块"
|
||||
value={workspace?.modules.filter((item) => item.isEnabled).length ?? 0}
|
||||
suffix="个启用"
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={[16, 16]}>
|
||||
<Col xs={24} lg={12}>
|
||||
<Card title="品牌完整度">
|
||||
<List
|
||||
dataSource={checklist}
|
||||
renderItem={(item) => (
|
||||
<List.Item>
|
||||
<Space>
|
||||
<Tag color={item.done ? "success" : "default"}>
|
||||
{item.done ? "已完成" : "待完善"}
|
||||
</Tag>
|
||||
<span>{item.label}</span>
|
||||
</Space>
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} lg={12}>
|
||||
<Card title="下一步建议">
|
||||
<Typography.Paragraph>
|
||||
先完善品牌定位和信任证明,再配置业务提供项与咨询入口。所有内容发布前都应通过小程序预览确认。
|
||||
</Typography.Paragraph>
|
||||
<Typography.Paragraph type="secondary" style={{ marginBottom: 0 }}>
|
||||
餐饮模板只是业务表达样例,品牌信任主线仍应优先维护。
|
||||
</Typography.Paragraph>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</Space>
|
||||
</QueryState>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user