feat: 完善后台设计语言细节

- 统一说明文案层级:Typography.Paragraph 次要文案迁移到 admin-section-description
- 状态色补齐边框与中间调令牌,Alert/错误条/Descriptions 与 StatusTag 同源
- 咨询详情描述列表去表格线,改为键值展示并统一令牌
- 新增 BrandMark,侧栏与登录页标识改用品牌首字
- 信任内容改用列表行,空状态、表格骨架屏、主按钮脏检查落地
- design.md 同步令牌映射、切换控件选型与组件清单
This commit is contained in:
que01 committed 2026-10-14 11:21:31 +08:00
1 parent 2f26828f09
commit 3ef46b0aa8
25 files changed
+836 -393

No files matched your search

+115 -29
View File
@@ -51,17 +51,22 @@
强调色只用于:主按钮、选中态、链接、关键数字、聚焦描边。不得用于大面积背景。
例外:小程序预览区(iframe / 模拟器内)显示的是模板自身的品牌色(例如餐饮模板的砖红 `#B54A2C`),与后台无关,不视为违规,也不要「修正」成后台强调色。
### 状态色
状态一律用「浅底 + 深字」,不使用 antd 的实心鲜艳 Tag。
| 语义 | 底色 | 文字色 |
| ------------- | --------- | --------- |
| 成功 / 已发布 | `#ECFDF3` | `#067647` |
| 警告 / 进行中 | `#FFFAEB` | `#B54708` |
| 错误 / 失败 | `#FEF3F2` | `#B42318` |
| 中性 / 草稿 | `#F2F4F7` | `#475467` |
| 信息 / 系统态 | `#EFF4FF` | `#2563EB` |
| 语义 | 底色 | 边框 | 文字色 |
| ------------- | --------- | --------- | --------- |
| 成功 / 已发布 | `#ECFDF3` | `#ABEFC6` | `#067647` |
| 警告 / 进行中 | `#FFFAEB` | `#FEDF89` | `#B54708` |
| 错误 / 失败 | `#FEF3F2` | `#FBD5D1` | `#B42318` |
| 中性 / 草稿 | `#F2F4F7` | `#E7E9EC` | `#475467` |
| 信息 / 系统态 | `#EFF4FF` | `#B2CCFF` | `#2563EB` |
- 底色 + 边框 + 深色文字三件套同时用于 `StatusTag`、`Alert`、错误条与空状态,不得混用其他色阶。
- 需要中间调的场合(图标、进度条完成态)使用中间色:成功 `#12B76A`、警告 `#F79009`、错误 `#F04438`、信息 `#2563EB`。
---
@@ -196,11 +201,36 @@
用于咨询详情、版本信息等只读信息:字段名 13px `#6B7280`,值 14px `#1C1F23`,行间距 12px,不使用表格线。
落地:`<Descriptions className="admin-descriptions" column={1} size="small">`,字号与间距由 `admin.css` 与 `Descriptions` 令牌统一,不逐处传 `bordered`。
### Tabs
- 顶部 1px 分隔线,选中项底部 2px 强调色下划线 + 深色文字,未选中 14px `#6B7280`。
- 不超过 5 个 Tab,超出改用左侧分段导航。
### 切换控件选型
同一层级切换控件只允许两种,按范围选择,不得混用:
| 场景 | 控件 | 现状 |
| ---------------------------------------- | ----------- | ------------------------------ |
| 页面级分区(内容结构不同、各自独立成段) | `Tabs` | 配置与发布 |
| 区块内视图切换(同一份数据换视角) | `Segmented` | 小程序页面、业务提供项编辑弹窗 |
`Segmented` 用作「取值选择」(如能力状态降级/启用/停用)时按表单控件处理,不受本表约束。
### 标题层级
页面内标题只用三档,禁止再用 `Typography.Title level` 直接指定字号:
| 用途 | 类名 | 字号 |
| ---------------------- | --------------------- | ---------- |
| 区块标题 | `admin-section-title` | 16px / 600 |
| 面板内小标题、表单分组 | `admin-subhead` | 15px / 600 |
| 列表行、条目名称 | `admin-row-title` | 14px / 600 |
页面级标题只由 `AdminPageHeader` 输出(24px / 600),一个页面只出现一次。
### 进度
- 高 6px,圆角 3px,轨道 `#F0F1F3`,进度条强调色;完成态用成功色。
@@ -223,25 +253,31 @@
- 提交成功后:关闭弹窗、重置表单、刷新受影响列表;提交失败保持原状。
- 幂等写操作要防止重复点击(提交中禁用)。
落地约定:
- 空状态统一用 `EmptyState`(`components/EmptyState.tsx`);表格内用 `compact` 变体,整块区域用默认变体。禁止再使用 antd 默认 `Empty` 插画。
- 列表 / 表格加载统一用 `TableSkeleton`、`ListSkeleton`(`components/TableSkeleton.tsx`)替换内容区,不使用 antd `Table` 的转圈遮罩;卡片级加载用 `LoadingStack`。
- 卡片内的写操作只在「有未保存修改」时使用主按钮,其余状态用次要按钮并禁用,同时用 `StatusTag` 标明修改状态。
---
## 7. 页面结构
以下为各页面的视觉结构约定,业务逻辑不变。
| 页面 | 结构要点 |
| -------------- | ------------------------------------------------------------------------------ |
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);发布状态卡 + 草稿卡 + 历史版本表 |
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
| 信任内容 | 列表卡片(缩略图 + 标题 + 两行摘要 + 状态标签 + 行内操作),不用表格 |
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
| 模板与表单设置 | 行业模板网格(三列)+ 咨询表单字段编辑器 + 底部危险操作区 |
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
| 页面 | 结构要点 |
| -------------- | ------------------------------------------------------------------------------------- |
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);发布状态卡 + 草稿卡 + 历史版本表 |
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
| 信任内容 | 列表行(缩略图或类型图标 + 标题 + 类型/发布状态标签 + 两行摘要 + 行内操作),不用表格 |
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
| 模板与表单设置 | 行业模板网格(三列)+ 咨询表单字段编辑器 + 底部危险操作区 |
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
@@ -280,17 +316,36 @@ const theme = {
colorText: "#1C1F23",
colorTextSecondary: "#6B7280",
colorTextTertiary: "#9AA1AC",
colorTextQuaternary: "#C3C7CF",
colorBgLayout: "#F7F8FA",
colorBgContainer: "#FFFFFF",
colorBorder: "#D8DBE0",
colorBorderSecondary: "#E7E9EC",
colorSplit: "#F0F1F3",
colorFillTertiary: "#F7F8FA",
colorFillQuaternary: "#FAFAFB",
colorSuccess: "#12B76A",
colorSuccessBg: "#ECFDF3",
colorSuccessBorder: "#ABEFC6",
colorSuccessText: "#067647",
colorWarning: "#F79009",
colorWarningBg: "#FFFAEB",
colorWarningBorder: "#FEDF89",
colorWarningText: "#B54708",
colorError: "#F04438",
colorErrorBg: "#FEF3F2",
colorErrorBorder: "#FBD5D1",
colorErrorText: "#B42318",
colorInfo: "#2563EB",
colorInfoBg: "#EFF4FF",
colorInfoBorder: "#B2CCFF",
colorInfoText: "#2563EB",
borderRadius: 6,
borderRadiusLG: 10,
borderRadiusSM: 4,
fontSize: 14,
fontFamily:
"Inter, 'PingFang SC', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif",
"Inter, 'PingFang SC', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
controlHeight: 32,
controlHeightLG: 40,
boxShadow: "0 1px 2px rgba(16, 24, 40, 0.04)",
@@ -298,30 +353,61 @@ const theme = {
wireframe: false,
},
components: {
Layout: { headerHeight: 56, siderBg: "#FFFFFF", bodyBg: "#F7F8FA" },
Layout: {
headerHeight: 56,
headerBg: "#FFFFFF",
headerPadding: "0 24px",
siderBg: "#FFFFFF",
bodyBg: "#F7F8FA",
triggerBg: "#FFFFFF",
triggerColor: "#475467",
triggerHeight: 40,
},
Menu: {
itemHeight: 36,
itemBorderRadius: 6,
itemBg: "transparent",
itemColor: "#475467",
itemHoverBg: "#F7F8FA",
itemHoverColor: "#1C1F23",
itemSelectedBg: "#EFF4FF",
itemSelectedColor: "#2563EB",
itemHoverBg: "#F7F8FA",
itemMarginInline: 8,
itemMarginBlock: 2,
groupTitleColor: "#9AA1AC",
groupTitleFontSize: 12,
collapsedWidth: 0,
subMenuItemBg: "transparent",
},
Card: { paddingLG: 20, headerFontSize: 16 },
Card: { paddingLG: 20, headerFontSize: 16, headerHeight: 52, headerHeightSM: 44 },
Table: {
headerBg: "#FAFAFB",
headerColor: "#6B7280",
rowHoverBg: "#FAFAFB",
headerSplitColor: "transparent",
borderColor: "#F0F1F3",
cellPaddingBlock: 16,
headerBorderRadius: 8,
},
Button: { fontWeight: 500, primaryShadow: "none", defaultShadow: "none" },
Progress: { defaultColor: "#2563EB", remainingColor: "#F0F1F3", lineBorderRadius: 3 },
Tag: { defaultBg: "#F2F4F7", defaultColor: "#475467", borderRadiusSM: 6 },
Tabs: { inkBarColor: "#2563EB", itemSelectedColor: "#1C1F23", itemColor: "#6B7280" },
Form: { labelColor: "#475467", labelFontSize: 13, verticalLabelPadding: "0 0 6px" },
Modal: { borderRadiusLG: 12 },
Statistic: { titleFontSize: 12, contentFontSize: 28 },
Alert: { borderRadius: 8 },
Descriptions: {
labelBg: "#FAFAFB",
labelColor: "#6B7280",
contentColor: "#1C1F23",
itemPaddingBottom: 12,
},
Button: { primaryShadow: "none", defaultShadow: "none", fontWeight: 500 },
Progress: { defaultColor: "#2563EB", lineBorderRadius: 3 },
Tag: { defaultBg: "#F2F4F7", defaultColor: "#475467" },
},
};
```
- 新增页面优先使用令牌与共享组件,禁止在 JSX 内写内联色值(现有顶栏/侧栏的内联样式需迁移)。
- 共享视觉组件清单:`AdminPageHeader`、`QueryState`,以及后续新增的状态标签、空状态、卡片区块、指标卡。
可执行来源是 `apps/admin/src/lib/theme.ts`,本块为同值快照;改令牌时两处一起改。
- 新增页面优先使用令牌与共享组件;禁止在 JSX 内写内联色值、字号、圆角(唯一的例外是通过 CSS 变量透传的数据色,例如视觉模板色板的 `--swatch-color`)。
- 共享视觉组件清单:`AdminPageHeader`、`AdminSection`、`StatusTag`、`EmptyState`、`TableSkeleton` / `ListSkeleton`、`MetricCard`、`QueryState`。
+17
View File
@@ -0,0 +1,17 @@
/**
* 品牌标识:取品牌名首字渲染单字标记,未取到品牌时回落到中性字。
* 视觉规则见 apps/admin/design.md 的「侧栏导航」。
*/
export function BrandMark({
name,
fallback = "品",
className = "admin-sider-brand-mark",
}: {
name?: string | null | undefined;
fallback?: string;
className?: string;
}) {
const trimmed = name?.trim() ?? "";
const mark = Array.from(trimmed)[0] ?? fallback;
return <span className={className}>{mark}</span>;
}
+25
View File
@@ -0,0 +1,25 @@
import type { ReactNode } from "react";
export function EmptyState({
icon,
title,
description,
action,
compact = false,
}: {
icon?: ReactNode;
title: string;
description?: string;
action?: ReactNode;
compact?: boolean;
}) {
const className = compact ? "admin-empty admin-empty--compact" : "admin-empty";
return (
<div className={className}>
{icon ? <span className="admin-empty__icon">{icon}</span> : null}
<p className="admin-empty__title">{title}</p>
{description ? <p className="admin-empty__description">{description}</p> : null}
{action ? <div className="admin-empty__action">{action}</div> : null}
</div>
);
}
+1 -5
View File
@@ -1,4 +1,4 @@
import { Button, Card, Empty, Skeleton } from "antd";
import { Button, Card, Skeleton } from "antd";
import type { ReactNode } from "react";
function errorMessage(error: unknown, fallback: string) {
@@ -59,7 +59,3 @@ export function ErrorNote({
export function MutationError({ error }: { error?: unknown }) {
return <ErrorNote error={error} />;
}
export function EmptyState({ description }: { description: string }) {
return <Empty description={description} image={Empty.PRESENTED_IMAGE_SIMPLE} />;
}
@@ -88,7 +88,7 @@ export function RecordContentEditor({
}
/>
{save.isPending ? <Typography.Text type="secondary">正在保存内容…</Typography.Text> : null}
<Typography.Paragraph type="secondary">{section.description}</Typography.Paragraph>
<p className="admin-section-description">{section.description}</p>
<div className="admin-flex-1">
<RecordContentFields section={section} />
</div>
@@ -0,0 +1,29 @@
import { Skeleton } from "antd";
export function TableSkeleton({ rows = 4 }: { rows?: number }) {
return (
<div className="admin-table-skeleton" role="status" aria-live="polite">
{Array.from({ length: rows }).map((_, index) => (
<div key={index} className="admin-table-skeleton__row">
<Skeleton.Input active size="small" block />
</div>
))}
</div>
);
}
export function ListSkeleton({ rows = 3 }: { rows?: number }) {
return (
<div className="admin-list-skeleton" role="status" aria-live="polite">
{Array.from({ length: rows }).map((_, index) => (
<div key={index} className="admin-list-skeleton__row">
<Skeleton.Input active size="small" className="admin-list-skeleton__thumb" />
<div className="admin-list-skeleton__body">
<Skeleton.Input active size="small" block />
<Skeleton.Input active size="small" block />
</div>
</div>
))}
</div>
);
}
@@ -1,4 +1,4 @@
import { Button, Card, Collapse, Empty, Form, Input, Space, Typography } from "antd";
import { Button, Card, Collapse, Form, Input, Space, Typography } from "antd";
import {
CaretDownOutlined,
CaretUpOutlined,
@@ -6,6 +6,7 @@ import {
PlusOutlined,
} from "@ant-design/icons";
import type { TemplateAdminField } from "@personal-brand/api-client";
import { EmptyState } from "./EmptyState.js";
export function TemplateListField({
field,
@@ -29,12 +30,7 @@ export function TemplateListField({
>
{(rows, { add, remove, move }, { errors }) => (
<div className="admin-stack admin-stack-tight">
{rows.length === 0 ? (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={`还没有${field.label}内容`}
/>
) : null}
{rows.length === 0 ? <EmptyState compact title={`还没有${field.label}内容`} /> : null}
{rows.map((row, index) => {
const titleField = field.itemFields?.[0];
const primaryTitle = titleField ? (
@@ -1,4 +1,4 @@
import { Alert, Button, Form, Input, Select, Space, Switch, Typography, message } from "antd";
import { Alert, Button, Form, Input, Select, Space, Switch, message } from "antd";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useEffect } from "react";
import type { RuntimeWorkspace } from "@personal-brand/api-client";
@@ -79,9 +79,9 @@ export function InquiryPreviewEditor({
onValuesChange={(_, values) => onDraft(update(values))}
onFinish={(values) => save.mutate(values)}
>
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-bottom">
{record.name} · 编辑字段:{field.label}
</Typography.Paragraph>
</p>
<Form.Item
name="label"
label="字段标题"
@@ -109,7 +109,7 @@ export function InquiryPreviewEditor({
<Form.List name="options">
{(fields, { add, remove }) => (
<div>
{fields.length ? <Typography.Title level={5}>选项</Typography.Title> : null}
{fields.length ? <h4 className="admin-subhead admin-offset-bottom-xs">选项</h4> : null}
{fields.map(({ key, name }) => (
<Space key={key} align="start">
<Form.Item name={[name, "label"]} label="选项名称" rules={[{ required: true }]}>
@@ -538,7 +538,7 @@ export function PresentationEditor({
</Space>
<div className="presentation-editor__workspace">
<div className="presentation-editor__preview">
<Typography.Title level={5}>页面预览</Typography.Title>
<h3 className="admin-section-title admin-flush">页面预览</h3>
{selectedPage === "detail" && draftWorkspace?.offerings.length ? (
<Select
aria-label="选择详情页业务内容"
@@ -568,8 +568,8 @@ export function PresentationEditor({
/>
</div>
<aside className="presentation-editor__outline" aria-label="页面区域">
<Typography.Title level={5}>页面区域</Typography.Title>
<Typography.Paragraph type="secondary">选择区域,编辑对应内容</Typography.Paragraph>
<h3 className="admin-section-title admin-flush">页面区域</h3>
<p className="admin-section-description">选择区域,编辑对应内容</p>
{visibleTargets.length ? (
<Space className="presentation-editor__regions admin-offset-top" wrap>
{visibleTargets.map((target) => (
@@ -610,9 +610,9 @@ export function PresentationEditor({
) : null}
</aside>
<div className="presentation-editor__inspector">
<Typography.Title level={5}>
<h3 className="admin-section-title admin-flush">
{selectedTarget?.label ?? pageTitle(selectedPage ?? "home")}
</Typography.Title>
</h3>
<StatusTag
tone={
save.isError
@@ -784,10 +784,10 @@ export function PresentationEditor({
/>
) : !selectedTarget ? (
<div className="presentation-editor__empty">
<Typography.Title level={5}>选择要编辑的区域</Typography.Title>
<Typography.Paragraph type="secondary">
<h3 className="admin-subhead">选择要编辑的区域</h3>
<p className="admin-section-description">
点击预览中的内容,或使用区域列表,查看并修改对应字段。
</Typography.Paragraph>
</p>
</div>
) : (
<Form
@@ -802,15 +802,15 @@ export function PresentationEditor({
{editableSections.map((section, index) => (
<section key={section.key} aria-labelledby={`section-${section.key}`}>
{selectedTarget && index > 0 ? <Divider /> : null}
<Typography.Title id={`section-${section.key}`} level={5}>
<h4 id={`section-${section.key}`} className="admin-subhead">
{selectedTarget
? fieldTargetTitle(section, selectedTarget.label)
: section.title}
</Typography.Title>
</h4>
{!selectedTarget ? (
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-bottom">
{section.description}
</Typography.Paragraph>
</p>
) : null}
<Row gutter={16}>
{section.fields.map((field) => (
@@ -877,16 +877,14 @@ export function PresentationEditor({
) : null}
{!editableSections.some((section) => section.fields.length) &&
!relevantPageLinks.length ? (
<Typography.Paragraph type="secondary">
这个页面没有单独的品牌文案配置。
</Typography.Paragraph>
<p className="admin-section-description">这个页面没有单独的品牌文案配置。</p>
) : null}
{selectedTarget &&
!editableSections.some((section) => section.fields.length) &&
relevantPageLinks.length ? (
<Typography.Paragraph type="secondary">
<p className="admin-section-description">
此区域内容由对应的业务管理页面维护。
</Typography.Paragraph>
</p>
) : null}
</div>
<div className="presentation-editor__form-actions admin-actions admin-offset-top-lg">
@@ -1,10 +1,14 @@
import { Card, Col, Empty, Row } from "antd";
import { Button, Card, Col, Row } from "antd";
import { AppstoreOutlined } from "@ant-design/icons";
import { useNavigate } from "react-router-dom";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { EmptyState } from "../../components/EmptyState.js";
import { QueryState } from "../../components/QueryState.js";
import { CapabilityCard } from "./components/CapabilityCard.js";
import { useCapabilityQuery } from "./hooks/useCapabilityQueries.js";
export function CapabilitiesPage() {
const navigate = useNavigate();
const query = useCapabilityQuery();
return (
@@ -23,7 +27,14 @@ export function CapabilitiesPage() {
</Row>
) : (
<Card>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="当前模板没有可配置能力。" />
<EmptyState
icon={<AppstoreOutlined />}
title="当前模板没有可配置能力"
description="安装行业模板后,这里会列出可开关的能力插件。"
action={
<Button onClick={() => navigate("/admin/workspace")}>前往模板与表单设置</Button>
}
/>
</Card>
)}
<p className="admin-page-header-description admin-offset-top">
@@ -1,4 +1,4 @@
import { Button, Card, Input, Switch, Typography } from "antd";
import { Button, Card, Input, Space, Switch, Typography } from "antd";
import { useState } from "react";
import { ErrorNote } from "../../../components/QueryState.js";
import { StatusTag } from "../../../components/StatusTag.js";
@@ -29,10 +29,21 @@ function readSwitchValue(value: unknown): boolean {
return value === true;
}
function sameConfig(current: Record<string, unknown>, baseline: Record<string, unknown>): boolean {
const currentKeys = Object.keys(current ?? {}).sort();
const baselineKeys = Object.keys(baseline ?? {}).sort();
if (currentKeys.length !== baselineKeys.length) return false;
return currentKeys.every(
(key, index) =>
key === baselineKeys[index] && JSON.stringify(current[key]) === JSON.stringify(baseline[key]),
);
}
export function CapabilityCard({ capability }: { capability: AdminCapability }) {
const [status, setStatus] = useState<CapabilityStatus>(capability.status);
const [config, setConfig] = useState<Record<string, unknown>>(capability.config);
const mutation = useCapabilityMutation();
const dirty = status !== capability.status || !sameConfig(config, capability.config ?? {});
const save = async () => {
await mutation.mutateAsync({
@@ -55,9 +66,17 @@ export function CapabilityCard({ capability }: { capability: AdminCapability })
</span>
}
extra={
<Button type="primary" loading={mutation.isPending} onClick={() => void save()}>
保存草稿
</Button>
<Space>
{dirty ? <StatusTag tone="warning" label="有未保存修改" /> : null}
<Button
type={dirty ? "primary" : "default"}
disabled={!dirty}
loading={mutation.isPending}
onClick={() => void save()}
>
保存草稿
</Button>
</Space>
}
>
{mutation.isError ? (
@@ -4,8 +4,10 @@ import type { AdminBooking, InquirySubmission } from "@personal-brand/api-client
import { createApiClient } from "../../lib/api.js";
import { useState } from "react";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { EmptyState } from "../../components/EmptyState.js";
import { AdminSection } from "../../components/AdminSection.js";
import { ErrorNote } from "../../components/QueryState.js";
import { ListSkeleton, TableSkeleton } from "../../components/TableSkeleton.js";
import { StatusTag } from "../../components/StatusTag.js";
import type { StatusTone } from "../../components/StatusTag.js";
@@ -125,52 +127,66 @@ export function InquiriesPage() {
</Space>
}
>
<Table
rowKey="id"
loading={query.isLoading}
locale={{ emptyText: "还没有预约咨询。" }}
dataSource={query.data ?? []}
columns={[
{
title: "编号",
dataIndex: "bookingNo",
render: (value: string, item: AdminBooking) => (
<Button type="link" onClick={() => setSelectedId(item.id)}>
{value}
</Button>
{query.isLoading && !query.data ? (
<TableSkeleton />
) : (
<Table
rowKey="id"
locale={{
emptyText: (
<EmptyState
compact
title="还没有预约咨询"
description="访客在小程序提交预约后,会出现在这里。"
/>
),
},
{ title: "联系人", dataIndex: "customerName" },
{
title: "提交时间",
dataIndex: "createdAt",
render: (value: string) => new Date(value).toLocaleString("zh-CN"),
},
{
title: "状态",
dataIndex: "status",
render: (value: string) => (
<StatusTag tone={statusTones[value] ?? "neutral"} label={labels[value] ?? value} />
),
},
{
title: "操作",
render: (_: unknown, item: AdminBooking) => (
<Space>
<Select
size="small"
value={item.status}
onChange={(value) => update.mutate({ id: item.id, value: value as never })}
options={statuses.map((value) => ({ value, label: labels[value] }))}
/>
<Button type="link" size="small" onClick={() => read.mutate(item.id)}>
标记已读
}}
dataSource={query.data ?? []}
columns={[
{
title: "编号",
dataIndex: "bookingNo",
render: (value: string, item: AdminBooking) => (
<Button type="link" onClick={() => setSelectedId(item.id)}>
{value}
</Button>
</Space>
),
},
]}
/>
),
},
{ title: "联系人", dataIndex: "customerName" },
{
title: "提交时间",
dataIndex: "createdAt",
render: (value: string) => new Date(value).toLocaleString("zh-CN"),
},
{
title: "状态",
dataIndex: "status",
render: (value: string) => (
<StatusTag
tone={statusTones[value] ?? "neutral"}
label={labels[value] ?? value}
/>
),
},
{
title: "操作",
render: (_: unknown, item: AdminBooking) => (
<Space>
<Select
size="small"
value={item.status}
onChange={(value) => update.mutate({ id: item.id, value: value as never })}
options={statuses.map((value) => ({ value, label: labels[value] }))}
/>
<Button type="link" size="small" onClick={() => read.mutate(item.id)}>
标记已读
</Button>
</Space>
),
},
]}
/>
)}
<Drawer
title="咨询详情"
open={Boolean(selectedId)}
@@ -179,7 +195,7 @@ export function InquiriesPage() {
width={520}
>
{detail.data && (
<Descriptions column={1} bordered size="small">
<Descriptions className="admin-descriptions" column={1} size="small">
<Descriptions.Item label="编号">{detail.data.bookingNo}</Descriptions.Item>
<Descriptions.Item label="联系人">{detail.data.customerName}</Descriptions.Item>
<Descriptions.Item label="状态">
@@ -219,79 +235,90 @@ export function InquiriesPage() {
options={inquiryStatuses.map((value) => ({ value, label: inquiryLabels[value] }))}
/>
</Space>
<Table<InquirySubmission>
rowKey="id"
loading={submissions.isLoading}
dataSource={(submissions.data ?? []).filter(
(item) => !submissionStatus || item.status === submissionStatus,
)}
locale={{ emptyText: submissions.isLoading ? "加载中" : "暂无动态咨询提交" }}
columns={[
{ title: "表单", dataIndex: ["inquiryForm", "name"] },
{
title: "来源业务",
dataIndex: ["offering", "name"],
render: (value: string | null | undefined) => value || "品牌咨询",
},
{
title: "状态",
dataIndex: "status",
render: (value: InquirySubmission["status"]) => (
<StatusTag
tone={statusTones[value] ?? "neutral"}
label={inquiryLabels[value] ?? value}
{submissions.isLoading && !submissions.data ? (
<ListSkeleton rows={3} />
) : (
<Table<InquirySubmission>
rowKey="id"
dataSource={(submissions.data ?? []).filter(
(item) => !submissionStatus || item.status === submissionStatus,
)}
locale={{
emptyText: (
<EmptyState
compact
title="暂无动态咨询提交"
description="按模板表单提交的咨询会汇总在这里。"
/>
),
},
{ title: "版本", dataIndex: "formVersion", render: (value) => `v${value}` },
{
title: "提交时间",
dataIndex: "createdAt",
render: (value: string) => new Date(value).toLocaleString("zh-CN"),
},
{
title: "内容",
dataIndex: "values",
render: (value: Record<string, unknown>) => {
const entries = Object.entries(value ?? {});
return entries.length
? entries.map(([key, item]) => `${key}: ${String(item)}`).join(";")
: "暂无内容";
}}
columns={[
{ title: "表单", dataIndex: ["inquiryForm", "name"] },
{
title: "来源业务",
dataIndex: ["offering", "name"],
render: (value: string | null | undefined) => value || "品牌咨询",
},
},
{
title: "跟进",
render: (_: unknown, item: InquirySubmission) => (
<Space>
<Button type="link" size="small" onClick={() => setSelectedSubmission(item)}>
查看
</Button>
<Select
size="small"
value={item.status}
options={inquiryStatuses.map((value) => ({
value,
label: inquiryLabels[value],
}))}
onChange={(value) => updateSubmission.mutate({ id: item.id, status: value })}
{
title: "状态",
dataIndex: "status",
render: (value: InquirySubmission["status"]) => (
<StatusTag
tone={statusTones[value] ?? "neutral"}
label={inquiryLabels[value] ?? value}
/>
<Input
size="small"
placeholder="备注"
defaultValue={item.adminNote ?? ""}
onPressEnter={(event) =>
updateSubmission.mutate({
id: item.id,
status: item.status,
adminNote: event.currentTarget.value,
})
}
/>
</Space>
),
},
]}
/>
),
},
{ title: "版本", dataIndex: "formVersion", render: (value) => `v${value}` },
{
title: "提交时间",
dataIndex: "createdAt",
render: (value: string) => new Date(value).toLocaleString("zh-CN"),
},
{
title: "内容",
dataIndex: "values",
render: (value: Record<string, unknown>) => {
const entries = Object.entries(value ?? {});
return entries.length
? entries.map(([key, item]) => `${key}: ${String(item)}`).join(";")
: "暂无内容";
},
},
{
title: "跟进",
render: (_: unknown, item: InquirySubmission) => (
<Space>
<Button type="link" size="small" onClick={() => setSelectedSubmission(item)}>
查看
</Button>
<Select
size="small"
value={item.status}
options={inquiryStatuses.map((value) => ({
value,
label: inquiryLabels[value],
}))}
onChange={(value) => updateSubmission.mutate({ id: item.id, status: value })}
/>
<Input
size="small"
placeholder="备注"
defaultValue={item.adminNote ?? ""}
onPressEnter={(event) =>
updateSubmission.mutate({
id: item.id,
status: item.status,
adminNote: event.currentTarget.value,
})
}
/>
</Space>
),
},
]}
/>
)}
<Drawer
title="动态咨询详情"
open={Boolean(selectedSubmission)}
@@ -299,7 +326,7 @@ export function InquiriesPage() {
width={520}
>
{selectedSubmission && (
<Descriptions column={1} bordered size="small">
<Descriptions className="admin-descriptions" column={1} size="small">
<Descriptions.Item label="表单">
{selectedSubmission.inquiryForm?.name || "品牌咨询"}
</Descriptions.Item>
@@ -1,4 +1,4 @@
import { Button, Card, Col, Progress, Row, Typography } from "antd";
import { Button, Card, Col, Progress, Row } from "antd";
import { useQueries, useQuery } from "@tanstack/react-query";
import { useNavigate } from "react-router-dom";
import { createApiClient } from "../../lib/api.js";
@@ -126,11 +126,11 @@ export function OverviewPage() {
percent={completionPercent}
status={readiness.data?.ready ? "success" : "active"}
/>
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-top-sm admin-offset-bottom">
{readiness.data?.ready
? "当前草稿已满足发布条件,可以进入发布页上线。"
: `还有 ${incompleteChecks.length} 项需要完善,完成后才能发布。`}
</Typography.Paragraph>
</p>
{incompleteChecks.length > 0 && (
<ul className="admin-list">
{incompleteChecks.slice(0, 4).map((item) => (
@@ -5,7 +5,6 @@ import {
Alert,
Button,
Divider,
Empty,
Input,
Modal,
Form,
@@ -20,6 +19,7 @@ import type { BrandTemplateKey } from "@personal-brand/api-client";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { AdminSection } from "../../components/AdminSection.js";
import { EmptyState } from "../../components/EmptyState.js";
import { ErrorNote, MutationError, QueryState } from "../../components/QueryState.js";
import { StatusTag, statusLabel } from "../../components/StatusTag.js";
import { MiniAppReleaseCard } from "./MiniAppReleaseCard.js";
@@ -581,7 +581,11 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
))}
</ul>
) : (
<Empty description="暂无发布记录" image={Empty.PRESENTED_IMAGE_SIMPLE} />
<EmptyState
compact
title="暂无发布记录"
description="完成检查并发布后,这里会保留每个版本的记录。"
/>
)}
<MutationError error={rollback.error} />
</AdminSection>
@@ -623,7 +627,11 @@ export function PublicationPage({ canManageTemplate }: { canManageTemplate: bool
))}
</div>
) : (
<Empty description="暂无小程序发布任务" image={Empty.PRESENTED_IMAGE_SIMPLE} />
<EmptyState
compact
title="暂无小程序发布任务"
description="先发布品牌内容,再上传当前版本到微信。"
/>
)}
</AdminSection>
</div>
@@ -1,4 +1,4 @@
import { Alert, Button, Form, Input, Modal, Segmented, Select, Typography } from "antd";
import { Alert, Button, Form, Input, Modal, Segmented, Select } from "antd";
import type {
Offering,
RuntimeWorkspace,
@@ -103,7 +103,7 @@ export function OfferingEditorModal({
onFinish={onFinish}
>
<div className="service-offering-editor__form-scroll">
<Typography.Title level={5}>基础信息</Typography.Title>
<h4 className="admin-subhead">基础信息</h4>
<Form.Item name="kind" label="类型" rules={[{ required: true }]}>
<Select
options={[
@@ -153,12 +153,12 @@ export function OfferingEditorModal({
</Form.Item>
{activeTemplateFields.length ? (
<div>
<Typography.Title level={5}>
<h4 className="admin-subhead">
{previewPage === "offerings" ? "列表展示字段" : "详情展示字段"}
</Typography.Title>
<Typography.Paragraph type="secondary">
</h4>
<p className="admin-section-description admin-offset-bottom">
这里只编辑左侧预览对应的字段;它们与小程序页面编辑的是同一份业务数据。
</Typography.Paragraph>
</p>
<RecordContentFields
section={{
...templateFieldSection,
@@ -1,6 +1,8 @@
import { Button, Popconfirm, Space, Table } from "antd";
import type { Offering } from "@personal-brand/api-client";
import { AdminSection } from "../../components/AdminSection.js";
import { EmptyState } from "../../components/EmptyState.js";
import { TableSkeleton } from "../../components/TableSkeleton.js";
import { MutationError } from "../../components/QueryState.js";
import { StatusTag } from "../../components/StatusTag.js";
import type { useOfferingMutations } from "./use-offering-data.js";
@@ -95,17 +97,24 @@ export function OfferingsTable({
: "已启用的项目会公开展示。"
}
>
<Table
scroll={{ x: 760 }}
rowKey="id"
loading={loading}
dataSource={items}
columns={columns}
/>
{items.length === 0 && (
<p className="admin-empty-inline">
还没有公开业务提供项。创建后,小程序服务页会优先读取这些内容。
</p>
{loading && items.length === 0 ? (
<TableSkeleton />
) : (
<Table
scroll={{ x: 760 }}
rowKey="id"
dataSource={items}
columns={columns}
locale={{
emptyText: (
<EmptyState
compact
title="还没有业务提供项"
description="创建后,小程序业务展示页会优先读取这些内容。"
/>
),
}}
/>
)}
<MutationError error={saveError} />
<MutationError error={toggleOffering.error} />
+10 -1
View File
@@ -5,6 +5,7 @@ import { useState } from "react";
import { createApiClient } from "../../lib/api.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { MutationError, QueryState } from "../../components/QueryState.js";
import { EmptyState } from "../../components/EmptyState.js";
import { StatusTag } from "../../components/StatusTag.js";
const roleLabels: Record<string, string> = {
@@ -75,8 +76,16 @@ export function MembersPage() {
/>
<Table
rowKey="id"
loading={members.isLoading}
dataSource={members.data ?? []}
locale={{
emptyText: (
<EmptyState
compact
title="还没有其他成员"
description="添加协作者后,他们可以按角色维护当前品牌。"
/>
),
}}
columns={[
{
title: "成员",
@@ -3,7 +3,7 @@ import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { AdminSection } from "../../components/AdminSection.js";
import { QueryState } from "../../components/QueryState.js";
import { TrustContentEditorModal } from "./components/TrustContentEditorModal.js";
import { TrustContentTable } from "./components/TrustContentTable.js";
import { TrustContentList } from "./components/TrustContentList.js";
import { TrustRequirementsList } from "./components/TrustRequirementsList.js";
import type { TrustTypeOption } from "./domain/trust-content-domain.js";
import {
@@ -74,11 +74,12 @@ export function TrustContentPage() {
/>
</AdminSection>
<AdminSection title="已配置的品牌内容">
<TrustContentTable
<TrustContentList
availableTypes={availableTypes}
items={query.data ?? []}
removeError={remove.error}
removePending={remove.isPending}
onCreate={() => begin()}
onEdit={(item) => begin(item)}
onDelete={(id) => remove.mutate(id)}
/>
@@ -1,4 +1,4 @@
import { Form, Input, Modal, Select, Typography } from "antd";
import { Form, Input, Modal, Select } from "antd";
import type { FormInstance } from "antd";
import type { TrustContent, TrustContentInput } from "@personal-brand/api-client";
import { ImageUrlField } from "../../../components/ImageUrlField.js";
@@ -49,9 +49,9 @@ export function TrustContentEditorModal({
/>
</Form.Item>
{selectedTypeMeta?.pages?.length ? (
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-bottom">
这类内容会显示在:{selectedTypeMeta.pages.map(pageLabel).join("、")}
</Typography.Paragraph>
</p>
) : null}
<Form.Item
name="title"
@@ -0,0 +1,89 @@
import { Button, Popconfirm } from "antd";
import { FileTextOutlined } from "@ant-design/icons";
import type { TrustContent } from "@personal-brand/api-client";
import { EmptyState } from "../../../components/EmptyState.js";
import { MutationError } from "../../../components/QueryState.js";
import { StatusTag } from "../../../components/StatusTag.js";
import type { TrustTypeOption } from "../domain/trust-content-domain.js";
import { getTrustContentPreview } from "../domain/trust-content-domain.js";
export function TrustContentList({
availableTypes,
items,
removeError,
removePending,
onCreate,
onEdit,
onDelete,
}: {
availableTypes: TrustTypeOption[];
items: TrustContent[];
removeError: unknown;
removePending: boolean;
onCreate: () => void;
onEdit: (item: TrustContent) => void;
onDelete: (id: string) => void;
}) {
if (!items.length) {
return (
<section aria-label="已配置的品牌内容">
<EmptyState
icon={<FileTextOutlined />}
title="还没有品牌内容"
description="按上方模板要求逐项添加,访客才能看到你的经历与证明。"
action={
<Button type="primary" onClick={onCreate}>
添加品牌内容
</Button>
}
/>
</section>
);
}
return (
<section aria-label="已配置的品牌内容">
<ul className="admin-list">
{items.map((item) => {
const typeMeta = availableTypes.find((type) => type.type === item.type);
return (
<li key={item.id} className="admin-row admin-record">
<div className="admin-record__thumb">
{item.coverUrl ? (
<img src={item.coverUrl} alt="" loading="lazy" />
) : (
<FileTextOutlined />
)}
</div>
<div className="admin-row-main">
<div className="admin-row-line">
<span className="admin-row-title">{item.title}</span>
<StatusTag tone="neutral" label={typeMeta?.label ?? item.type} />
<StatusTag
tone={item.isPublished ? "success" : "neutral"}
label={item.isPublished ? "随发布展示" : "草稿"}
/>
</div>
<p className="admin-row-summary">{getTrustContentPreview(item, typeMeta)}</p>
</div>
<div className="admin-record__actions">
<Button type="link" size="small" onClick={() => onEdit(item)}>
编辑
</Button>
<Popconfirm
title="确认删除这条信任内容?"
description="删除后需发布品牌,才会更新小程序展示。"
onConfirm={() => onDelete(item.id)}
>
<Button type="link" size="small" danger loading={removePending}>
删除
</Button>
</Popconfirm>
</div>
</li>
);
})}
</ul>
<MutationError error={removeError} />
</section>
);
}
@@ -1,84 +0,0 @@
import { Button, Popconfirm, Space, Table } from "antd";
import type { TrustContent } from "@personal-brand/api-client";
import type { TrustTypeOption } from "../domain/trust-content-domain.js";
import { getTrustContentPreview } from "../domain/trust-content-domain.js";
import { MutationError } from "../../../components/QueryState.js";
import { StatusTag } from "../../../components/StatusTag.js";
export function TrustContentTable({
availableTypes,
items,
removeError,
removePending,
onEdit,
onDelete,
}: {
availableTypes: TrustTypeOption[];
items: TrustContent[];
removeError: unknown;
removePending: boolean;
onEdit: (item: TrustContent) => void;
onDelete: (id: string) => void;
}) {
return (
<section aria-label="已配置的品牌内容">
<Table
rowKey="id"
dataSource={items}
locale={{ emptyText: "还没有品牌内容,请先按上方模板要求添加。" }}
columns={[
{
title: "内容类型",
dataIndex: "type",
render: (value) => (
<StatusTag
tone="neutral"
label={availableTypes.find((item) => item.type === value)?.label ?? String(value)}
/>
),
},
{ title: "标题", dataIndex: "title" },
{
title: "内容预览",
ellipsis: { showTitle: true },
render: (_value: unknown, item: TrustContent) =>
getTrustContentPreview(
item,
availableTypes.find((type) => type.type === item.type),
),
},
{
title: "发布状态",
dataIndex: "isPublished",
render: (value) => (
<StatusTag
tone={value ? "success" : "neutral"}
label={value ? "随发布展示" : "草稿"}
/>
),
},
{
title: "操作",
render: (_: unknown, item: TrustContent) => (
<Space>
<Button type="link" size="small" onClick={() => onEdit(item)}>
编辑
</Button>
<Popconfirm
title="确认删除这条信任内容?"
description="删除后需发布品牌,才会更新小程序展示。"
onConfirm={() => onDelete(item.id)}
>
<Button type="link" size="small" danger loading={removePending}>
删除
</Button>
</Popconfirm>
</Space>
),
},
]}
/>
<MutationError error={removeError} />
</section>
);
}
@@ -17,8 +17,10 @@ import {
} from "./workspace-mutations.js";
import { supportsIndustry, type IndustryTarget } from "./workspace-templates.js";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { EmptyState } from "../../components/EmptyState.js";
import { MutationError } from "../../components/QueryState.js";
import { StatusTag } from "../../components/StatusTag.js";
import { ListSkeleton } from "../../components/TableSkeleton.js";
export const inquiryFieldTypes = [
{ value: "text", label: "简短文字" },
@@ -153,9 +155,9 @@ export function WorkspacePage() {
description="日常小程序内容请从页面配置、业务展示和信任证明进入;这里主要管理模板、咨询入口和负责人设置。"
/>
<Card title="先完成日常配置">
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-bottom">
下面这些入口面向日常经营,不需要理解模板或技术设置。完成后回到“配置与发布”统一检查并上线。
</Typography.Paragraph>
</p>
<Space wrap>
<Button onClick={() => navigate("/admin/brand")}>配置小程序页面</Button>
<Button onClick={() => navigate("/admin/services")}>添加业务展示内容</Button>
@@ -201,7 +203,7 @@ export function WorkspacePage() {
</Card>
))}
{!runtimeQuery.data?.plugins?.length && (
<p className="admin-empty-inline">当前模板未启用能力插件。</p>
<EmptyState compact title="当前模板未启用能力插件" />
)}
</div>
<Space wrap>
@@ -237,7 +239,7 @@ export function WorkspacePage() {
))}
</div>
) : (
<p className="admin-empty-inline">暂无历史版本</p>
<EmptyState compact title="暂无历史版本" />
)}
{visualHistory.data?.history.length ? (
<Button
@@ -290,9 +292,9 @@ export function WorkspacePage() {
当前模板:{runtimeQuery.data?.visualTemplate?.name ?? "林境建筑画册"}
</Typography.Paragraph>
<Typography.Paragraph>目标模板:林境建筑画册</Typography.Paragraph>
<Typography.Paragraph type="secondary">
<p className="admin-section-description">
只会替换视觉主题和模块变体,不会覆盖品牌内容、业务提供项或咨询记录。
</Typography.Paragraph>
</p>
</Modal>
</div>
)}
@@ -313,9 +315,9 @@ export function WorkspacePage() {
</Space>
}
>
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-bottom">
模板只提供行业表达样例,不会替代你的品牌定位、经历、作品和合作方式。
</Typography.Paragraph>
</p>
<StatusTag
tone={installations.length ? "info" : "neutral"}
label={installations.length ? `已安装 ${installations.length} 个模板` : "尚未安装模板"}
@@ -329,10 +331,10 @@ export function WorkspacePage() {
</Typography.Text>
{templatePreview.data?.canUpgrade ? (
<>
<Typography.Paragraph type="secondary" className="admin-flush">
<p className="admin-section-description">
可升级内容:新增 {templatePreview.data.missingModules.length} 个模块,新增{" "}
{templatePreview.data.missingFields.length} 个字段。已有内容不会被覆盖。
</Typography.Paragraph>
</p>
<Button
type="primary"
onClick={() => upgrade.mutate()}
@@ -369,20 +371,20 @@ export function WorkspacePage() {
}}
confirmLoading={install.isPending}
>
<Typography.Title level={5}>{industryTarget?.name}</Typography.Title>
<Typography.Paragraph>{industryTarget?.description}</Typography.Paragraph>
<Typography.Paragraph type="secondary">
<h3 className="admin-subhead">{industryTarget?.name}</h3>
<p className="admin-section-description">{industryTarget?.description}</p>
<p className="admin-section-description">
模板会初始化模块、字段和默认业务表达,不会覆盖已有品牌内容。依赖能力:
{industryTarget?.capabilities.join("、") || "无"}。
</Typography.Paragraph>
</p>
</Modal>
<Card
title="模板组合预览"
extra={<Typography.Text type="secondary">高级预览</Typography.Text>}
>
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-bottom">
用于负责人确认行业表达和视觉风格是否匹配,日常内容配置通常不需要使用这里。
</Typography.Paragraph>
</p>
<Space wrap>
<Select
value={previewIndustryKey ?? null}
@@ -423,73 +425,84 @@ export function WorkspacePage() {
</Button>
}
>
<Table
rowKey="id"
loading={forms.isLoading}
dataSource={forms.data ?? []}
locale={{ emptyText: "还没有咨询入口,点击右上角即可从默认表单开始。" }}
columns={[
{ title: "名称", dataIndex: "name" },
{
title: "版本",
dataIndex: "version",
render: (value) => <StatusTag tone="neutral" label={`v${value}`} />,
},
{
title: "字段数",
dataIndex: "fieldsSnapshot",
render: (value: unknown[]) => value?.length ?? 0,
},
{
title: "状态",
dataIndex: "isEnabled",
render: (value: boolean) => (
<StatusTag tone={value ? "success" : "neutral"} label={value ? "启用" : "停用"} />
{forms.isLoading && !forms.data ? (
<ListSkeleton rows={2} />
) : (
<Table
rowKey="id"
dataSource={forms.data ?? []}
locale={{
emptyText: (
<EmptyState
compact
title="还没有咨询入口"
description="点击右上角「新增表单」,从默认表单开始配置。"
/>
),
},
{
title: "操作",
render: (_: unknown, item: InquiryForm) => (
<Space>
<Button
type="link"
size="small"
onClick={() => {
setEditingForm(item);
inquiryForm.resetFields();
inquiryForm.setFieldsValue({
name: item.name,
purpose: item.purpose,
offeringId: item.offeringId ?? undefined,
fieldsSnapshot: item.fieldsSnapshot.map((field: unknown) => {
const value = field as Record<string, unknown>;
return {
...value,
options: normalizeOptionLabels(value.options),
};
}),
});
setFormOpen(true);
}}
>
编辑
</Button>
<Select
size="small"
value={item.isEnabled}
options={[
{ value: true, label: "启用" },
{ value: false, label: "停用" },
]}
onChange={(isEnabled) =>
updateForm.mutate({ id: item.id, body: { isEnabled } })
}
/>
</Space>
),
},
]}
/>
}}
columns={[
{ title: "名称", dataIndex: "name" },
{
title: "版本",
dataIndex: "version",
render: (value) => <StatusTag tone="neutral" label={`v${value}`} />,
},
{
title: "字段数",
dataIndex: "fieldsSnapshot",
render: (value: unknown[]) => value?.length ?? 0,
},
{
title: "状态",
dataIndex: "isEnabled",
render: (value: boolean) => (
<StatusTag tone={value ? "success" : "neutral"} label={value ? "启用" : "停用"} />
),
},
{
title: "操作",
render: (_: unknown, item: InquiryForm) => (
<Space>
<Button
type="link"
size="small"
onClick={() => {
setEditingForm(item);
inquiryForm.resetFields();
inquiryForm.setFieldsValue({
name: item.name,
purpose: item.purpose,
offeringId: item.offeringId ?? undefined,
fieldsSnapshot: item.fieldsSnapshot.map((field: unknown) => {
const value = field as Record<string, unknown>;
return {
...value,
options: normalizeOptionLabels(value.options),
};
}),
});
setFormOpen(true);
}}
>
编辑
</Button>
<Select
size="small"
value={item.isEnabled}
options={[
{ value: true, label: "启用" },
{ value: false, label: "停用" },
]}
onChange={(isEnabled) =>
updateForm.mutate({ id: item.id, body: { isEnabled } })
}
/>
</Space>
),
},
]}
/>
)}
<MutationError error={createForm.error} />
<MutationError error={updateForm.error} />
</Card>
@@ -507,6 +520,15 @@ export function WorkspacePage() {
<Table
rowKey="id"
dataSource={fields.filter((item) => item.source === "custom")}
locale={{
emptyText: (
<EmptyState
compact
title="还没有高级自定义字段"
description="仅在需要跨业务复用的字段时才添加。"
/>
),
}}
columns={[
{ title: "字段", dataIndex: "label" },
{
@@ -614,9 +636,9 @@ export function WorkspacePage() {
confirmLoading={createForm.isPending || updateForm.isPending}
width={760}
>
<Typography.Paragraph type="secondary">
<p className="admin-section-description admin-offset-bottom">
先确定客户要提交的事情,再设置你希望客户填写的问题。保存后还需要在“配置与发布”中检查并发布,才会在小程序生效。
</Typography.Paragraph>
</p>
<Form
form={inquiryForm}
layout="vertical"
+23
View File
@@ -16,6 +16,22 @@ export const adminTheme: ThemeConfig = {
colorSplit: "#F0F1F3",
colorFillTertiary: "#F7F8FA",
colorFillQuaternary: "#FAFAFB",
colorSuccess: "#12B76A",
colorSuccessBg: "#ECFDF3",
colorSuccessBorder: "#ABEFC6",
colorSuccessText: "#067647",
colorWarning: "#F79009",
colorWarningBg: "#FFFAEB",
colorWarningBorder: "#FEDF89",
colorWarningText: "#B54708",
colorError: "#F04438",
colorErrorBg: "#FEF3F2",
colorErrorBorder: "#FBD5D1",
colorErrorText: "#B42318",
colorInfo: "#2563EB",
colorInfoBg: "#EFF4FF",
colorInfoBorder: "#B2CCFF",
colorInfoText: "#2563EB",
borderRadius: 6,
borderRadiusLG: 10,
borderRadiusSM: 4,
@@ -77,6 +93,13 @@ export const adminTheme: ThemeConfig = {
Form: { labelColor: "#475467", labelFontSize: 13, verticalLabelPadding: "0 0 6px" },
Modal: { borderRadiusLG: 12 },
Statistic: { titleFontSize: 12, contentFontSize: 28 },
Alert: { borderRadius: 8 },
Descriptions: {
labelBg: "#FAFAFB",
labelColor: "#6B7280",
contentColor: "#1C1F23",
itemPaddingBottom: 12,
},
},
};
+4 -3
View File
@@ -28,6 +28,7 @@ import {
} from "@ant-design/icons";
import { createApiClient } from "./lib/api.js";
import { adminTheme } from "./lib/theme.js";
import { BrandMark } from "./components/BrandMark.js";
import { LoadingStack } from "./components/QueryState.js";
import { StatusTag } from "./components/StatusTag.js";
import "./styles/admin.css";
@@ -105,7 +106,7 @@ function Login({
<div className="admin-auth">
<Card className="admin-auth-card">
<div className="admin-auth-brand">
<span className="admin-sider-brand-mark">品</span>
<BrandMark />
<span className="admin-header-brand">个人品牌后台</span>
</div>
<p className="admin-auth-hint">管理你的品牌表达、内容发布与客户咨询。</p>
@@ -158,7 +159,7 @@ function ChangePassword({ onComplete }: { onComplete: () => void }) {
<div className="admin-auth">
<Card className="admin-auth-card">
<div className="admin-auth-brand">
<span className="admin-sider-brand-mark">品</span>
<BrandMark />
<span className="admin-header-brand">首次登录需要修改密码</span>
</div>
<p className="admin-auth-hint">请先设置只有你本人知道的新密码。</p>
@@ -237,7 +238,7 @@ function Dashboard({ onLogout, role }: { onLogout: () => void; role: string }) {
<Layout className="admin-shell">
<Layout.Sider className="admin-sider" breakpoint="lg" collapsedWidth={0} width={232}>
<div className="admin-sider-brand">
<span className="admin-sider-brand-mark">品</span>
<BrandMark name={brand.data?.name} />
<span className="admin-sider-brand-name">品牌工作区</span>
</div>
<Menu
+170 -9
View File
@@ -16,14 +16,19 @@
--admin-fill-quiet: #fafafb;
--admin-tone-success-bg: #ecfdf3;
--admin-tone-success-border: #abefc6;
--admin-tone-success-fg: #067647;
--admin-tone-warning-bg: #fffaeb;
--admin-tone-warning-border: #fedf89;
--admin-tone-warning-fg: #b54708;
--admin-tone-error-bg: #fef3f2;
--admin-tone-error-border: #fbd5d1;
--admin-tone-error-fg: #b42318;
--admin-tone-neutral-bg: #f2f4f7;
--admin-tone-neutral-border: #e7e9ec;
--admin-tone-neutral-fg: #475467;
--admin-tone-info-bg: #eff4ff;
--admin-tone-info-border: #b2ccff;
--admin-tone-info-fg: #2563eb;
}
@@ -217,6 +222,14 @@ body {
color: var(--admin-text);
}
.admin-subhead {
margin: 0;
font-size: 15px;
font-weight: 600;
line-height: 1.45;
color: var(--admin-text);
}
.admin-section-description {
margin: 6px 0 0;
font-size: 13px;
@@ -266,14 +279,6 @@ body {
overflow: hidden;
}
.admin-empty-inline {
padding: 24px 0;
text-align: center;
font-size: 13px;
color: var(--admin-text-tertiary);
margin: 0;
}
/* 列表行 */
.admin-list {
margin: 0;
@@ -281,6 +286,38 @@ body {
list-style: none;
}
.admin-record {
gap: 12px;
}
.admin-record__thumb {
flex: none;
display: inline-flex;
align-items: center;
justify-content: center;
width: 48px;
height: 48px;
border-radius: 8px;
border: 1px solid var(--admin-border);
background: var(--admin-fill);
color: var(--admin-text-tertiary);
font-size: 18px;
overflow: hidden;
}
.admin-record__thumb img {
width: 100%;
height: 100%;
object-fit: cover;
}
.admin-record__actions {
flex: none;
display: flex;
align-items: center;
gap: 4px;
}
.admin-row {
display: flex;
align-items: center;
@@ -490,6 +527,11 @@ body {
background: var(--swatch-color, transparent);
}
/* 描述列表(键值展示) */
.admin-descriptions .ant-descriptions-item-label {
font-size: 13px;
}
/* 状态标签 */
.admin-status-tag {
display: inline-flex;
@@ -548,9 +590,128 @@ body {
}
/* 反馈 */
.admin-empty {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 40px 24px;
}
.admin-empty--compact {
padding: 24px 16px;
}
.admin-empty__icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
margin-bottom: 12px;
border-radius: 10px;
background: var(--admin-fill);
color: var(--admin-text-tertiary);
font-size: 20px;
}
.admin-empty--compact .admin-empty__icon {
width: 32px;
height: 32px;
margin-bottom: 8px;
font-size: 16px;
}
.admin-empty__title {
margin: 0;
font-size: 15px;
font-weight: 600;
line-height: 1.5;
color: var(--admin-text);
}
.admin-empty--compact .admin-empty__title {
font-size: 14px;
}
.admin-empty__description {
margin: 6px 0 0;
max-width: 360px;
font-size: 13px;
line-height: 1.6;
color: var(--admin-text-secondary);
}
.admin-empty__action {
margin-top: 16px;
}
.admin-empty--compact .admin-empty__action {
margin-top: 12px;
}
.admin-table-skeleton {
border-top: 1px solid var(--admin-divider);
}
.admin-table-skeleton__row {
display: flex;
align-items: center;
min-height: 52px;
padding: 0 16px;
border-bottom: 1px solid var(--admin-divider);
}
.admin-table-skeleton__row:last-child {
border-bottom: 0;
}
.admin-table-skeleton__row .ant-skeleton {
width: 100%;
}
.admin-table-skeleton__row .ant-skeleton-input {
width: 60%;
min-width: 120px;
}
.admin-list-skeleton {
display: flex;
flex-direction: column;
}
.admin-list-skeleton__row {
display: flex;
align-items: center;
gap: 12px;
padding: 14px 0;
border-bottom: 1px solid var(--admin-divider);
}
.admin-list-skeleton__row:last-child {
border-bottom: 0;
}
.admin-list-skeleton__thumb .ant-skeleton-input {
width: 48px;
min-width: 48px;
height: 48px;
}
.admin-list-skeleton__body {
flex: 1;
display: grid;
gap: 8px;
min-width: 0;
}
.admin-list-skeleton__body .ant-skeleton-input:last-child {
width: 45%;
}
.admin-error-note {
padding: 12px 16px;
border: 1px solid #fbd5d1;
border: 1px solid var(--admin-tone-error-border);
border-radius: 8px;
background: var(--admin-tone-error-bg);
color: var(--admin-tone-error-fg);