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

@@ -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"