feat: 完善后台配置工作台

This commit is contained in:
que01 committed 2026-09-27 19:11:01 +08:00
1 parent d7e5b64d84
commit 07d3790aa8
4 files changed
+96 -24

No files matched your search

@@ -1,5 +1,5 @@
import { Button, Card, Col, List, Row, Space, Statistic, Tag, Typography } from "antd";
import { useQueries } from "@tanstack/react-query";
import { Button, Card, Col, List, Progress, Row, Space, Statistic, Tag, Typography } from "antd";
import { useQueries, useQuery } from "@tanstack/react-query";
import { useNavigate } from "react-router-dom";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
@@ -20,9 +20,16 @@ export function OverviewPage() {
},
],
});
const readiness = useQuery({
queryKey: ["admin-overview-readiness"],
queryFn: () => client.getAdminReleaseReadiness(),
});
const loading = results.some((result) => result.isLoading);
const error = results.find((result) => result.isError)?.error;
const retry = () => results.forEach((result) => void result.refetch());
const error = results.find((result) => result.isError)?.error ?? readiness.error;
const retry = () => {
results.forEach((result) => void result.refetch());
void readiness.refetch();
};
const brand = results[0].data;
const workspace = results[1].data as
| {
@@ -51,8 +58,26 @@ export function OverviewPage() {
path: "/admin/workspace",
},
];
const readinessChecks = readiness.data?.checks ?? [];
const checks = readinessChecks.length
? readinessChecks.map((check) => ({
key: check.key,
label: check.label,
passed: check.passed,
destination: check.destination,
}))
: checklist.map((check) => ({
key: check.path,
label: check.label,
passed: check.done,
destination: check.path,
}));
const incompleteChecks = checks.filter((check) => !check.passed);
const completionPercent = checks.length
? Math.round((checks.filter((check) => check.passed).length / checks.length) * 100)
: 0;
return (
<QueryState loading={loading} error={error} onRetry={retry}>
<QueryState loading={loading || readiness.isLoading} error={error} onRetry={retry}>
<AdminPageHeader
title="品牌概览"
description="从这里检查品牌表达、信任内容和业务承接是否完整。"
@@ -96,18 +121,64 @@ export function OverviewPage() {
</Row>
<Row gutter={[16, 16]}>
<Col xs={24} lg={12}>
<Card title="品牌完整度">
<Card
title="发布准备度"
extra={
<Button type="link" onClick={() => navigate("/admin/publication")}>
查看发布页
</Button>
}
>
<Progress
percent={completionPercent}
status={readiness.data?.ready ? "success" : "active"}
/>
<Typography.Paragraph type="secondary">
{readiness.data?.ready
? "当前草稿已满足发布条件,可以进入发布页上线。"
: `还有 ${incompleteChecks.length} 项需要完善,完成后才能发布。`}
</Typography.Paragraph>
{incompleteChecks.length > 0 && (
<List
size="small"
dataSource={incompleteChecks.slice(0, 4)}
renderItem={(item) => (
<List.Item
actions={[
<Button
key={item.key}
type="link"
size="small"
onClick={() => navigate(item.destination ?? "/admin/publication")}
>
去处理
</Button>,
]}
>
{item.label}
</List.Item>
)}
/>
)}
</Card>
</Col>
<Col xs={24} lg={12}>
<Card title="品牌内容检查">
<List
dataSource={checklist}
dataSource={checks}
renderItem={(item) => (
<List.Item>
<Space>
<Tag color={item.done ? "success" : "default"}>
{item.done ? "已完成" : "待完善"}
<Tag color={item.passed ? "success" : "default"}>
{item.passed ? "已完成" : "待完善"}
</Tag>
<span>{item.label}</span>
{!item.done && (
<Button type="link" size="small" onClick={() => navigate(item.path)}>
{!item.passed && (
<Button
type="link"
size="small"
onClick={() => navigate(item.destination ?? "/admin/publication")}
>
去处理
</Button>
)}
@@ -117,16 +188,6 @@ export function OverviewPage() {
/>
</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>