feat: 完善后台配置工作台
This commit is contained in:
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>
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
Menu,
|
||||
Select,
|
||||
Space,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from "antd";
|
||||
@@ -206,7 +207,7 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
];
|
||||
return (
|
||||
<Layout style={{ minHeight: "100vh" }}>
|
||||
<Layout.Sider>
|
||||
<Layout.Sider breakpoint="lg" collapsedWidth={0}>
|
||||
<Typography.Title level={4} style={{ color: "white", padding: 20 }}>
|
||||
当前品牌工作区
|
||||
</Typography.Title>
|
||||
@@ -229,6 +230,9 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
|
||||
<Space>
|
||||
<Typography.Text strong>{brand.data?.name || "当前品牌"}</Typography.Text>
|
||||
<Typography.Text type="secondary">品牌工作区</Typography.Text>
|
||||
<Tag color={role === "owner" ? "blue" : "default"}>
|
||||
{role === "owner" ? "负责人" : "内容编辑"}
|
||||
</Tag>
|
||||
<Select
|
||||
size="small"
|
||||
value={brand.data?.id}
|
||||
|
||||
Reference in new issue
Block a user