From e402ba58d9bf74eff6b1af153eb6c49f6468c567 Mon Sep 17 00:00:00 2001 From: que01 Date: Sun, 20 Sep 2026 16:41:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E6=9E=84=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E5=93=81=E7=89=8C=E5=B7=A5=E4=BD=9C=E5=8F=B0=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E9=AA=A8=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/src/components/AdminPageHeader.tsx | 31 +++++ apps/admin/src/components/QueryState.tsx | 47 +++++++ .../src/features/overview/OverviewPage.tsx | 119 ++++++++++++++++++ apps/admin/src/main.tsx | 17 ++- 4 files changed, 209 insertions(+), 5 deletions(-) create mode 100644 apps/admin/src/components/AdminPageHeader.tsx create mode 100644 apps/admin/src/components/QueryState.tsx create mode 100644 apps/admin/src/features/overview/OverviewPage.tsx diff --git a/apps/admin/src/components/AdminPageHeader.tsx b/apps/admin/src/components/AdminPageHeader.tsx new file mode 100644 index 0000000..df78326 --- /dev/null +++ b/apps/admin/src/components/AdminPageHeader.tsx @@ -0,0 +1,31 @@ +import { Space, Typography } from "antd"; +import type { ReactNode } from "react"; + +export function AdminPageHeader({ + title, + description, + extra, +}: { + title: string; + description?: string; + extra?: ReactNode; +}) { + return ( + +
+ + {title} + + {description && ( + + {description} + + )} +
+ {extra} +
+ ); +} diff --git a/apps/admin/src/components/QueryState.tsx b/apps/admin/src/components/QueryState.tsx new file mode 100644 index 0000000..c76e43b --- /dev/null +++ b/apps/admin/src/components/QueryState.tsx @@ -0,0 +1,47 @@ +import { Alert, Button, Card, Empty, Result, Spin } from "antd"; +import type { ReactNode } from "react"; + +export function QueryState({ + loading, + error, + onRetry, + children, +}: { + loading?: boolean; + error?: unknown; + onRetry?: () => void; + children: ReactNode; +}) { + if (loading) + return ( + + + + ); + if (error) { + return ( + 重新加载 : undefined} + /> + ); + } + return <>{children}; +} + +export function EmptyState({ description }: { description: string }) { + return ; +} + +export function MutationError({ error }: { error?: unknown }) { + if (!error) return null; + return ( + + ); +} diff --git a/apps/admin/src/features/overview/OverviewPage.tsx b/apps/admin/src/features/overview/OverviewPage.tsx new file mode 100644 index 0000000..da7c5d9 --- /dev/null +++ b/apps/admin/src/features/overview/OverviewPage.tsx @@ -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 ( + + + + + + {brand?.name || "未命名品牌"} + + + {brand?.tagline || "还没有设置一句话定位"} + + + 当前模板:{brand?.templateKey === "food" ? "餐饮模板" : "个人品牌"} + + + + + + item.isPublished).length ?? 0} + suffix="条已发布" + /> + + + + + item.isEnabled).length ?? 0} + suffix="项公开" + /> + + + + + + + + + + item.isEnabled).length ?? 0} + suffix="个启用" + /> + + + + + + + ( + + + + {item.done ? "已完成" : "待完善"} + + {item.label} + + + )} + /> + + + + + + 先完善品牌定位和信任证明,再配置业务提供项与咨询入口。所有内容发布前都应通过小程序预览确认。 + + + 餐饮模板只是业务表达样例,品牌信任主线仍应优先维护。 + + + + + + + ); +} diff --git a/apps/admin/src/main.tsx b/apps/admin/src/main.tsx index 3120514..10395db 100644 --- a/apps/admin/src/main.tsx +++ b/apps/admin/src/main.tsx @@ -49,6 +49,11 @@ const FeatureWorkspacePage = React.lazy(() => default: module.WorkspacePage, })), ); +const FeatureOverviewPage = React.lazy(() => + import("./features/overview/OverviewPage.js").then((module) => ({ + default: module.OverviewPage, + })), +); import { BrowserRouter, Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom"; import type { BrandProfile, @@ -96,12 +101,13 @@ function Login({ onLogin }: { onLogin: () => void }) { function Dashboard({ onLogout }: { onLogout: () => void }) { const navigate = useNavigate(); const location = useLocation(); - const page = location.pathname.split("/")[2] || "brand"; + const page = location.pathname.split("/")[2] || "overview"; const items = [ - { key: "brand", label: "品牌信任" }, - { key: "workspace", label: "工作空间" }, + { key: "overview", label: "品牌概览" }, + { key: "brand", label: "品牌表达" }, { key: "trust", label: "信任内容" }, - { key: "services", label: "服务与合作" }, + { key: "services", label: "业务提供项" }, + { key: "workspace", label: "模板与设置" }, { key: "inquiries", label: "咨询记录" }, ]; return ( @@ -134,12 +140,13 @@ function Dashboard({ onLogout }: { onLogout: () => void }) { }> + } /> } /> } /> } /> } /> } /> - } /> + } />