fix: 修复信任内容列表展示问题

- 列表按模板声明的类型顺序排列,与必填清单顺序一致
- 类型标签并入说明行,去掉与类型重复的标签;展示位置改为可读页面名
- 类型未识别时页面名补充中文映射(service/inquiry)
- 无配图时按类型显示线性图标,替换统一的文件图标
- 摘要长文本按前 3 个字段截断,避免单行超长
- 记录行改为顶部对齐,操作按钮垂直居中,行内段落间距交给 gap
- Modal destroyOnClose 迁移到 destroyOnHidden,消除 antd 弃用告警
- 发布必填清单显示同类已配置条数,已配置区块显示总数
This commit is contained in:
que01 committed 2026-10-14 11:47:56 +08:00
1 parent 3ef46b0aa8
commit ebab77057a
9 files changed
+136 -45

No files matched your search

+13 -13
View File
@@ -265,19 +265,19 @@
以下为各页面的视觉结构约定,业务逻辑不变。
| 页面 | 结构要点 |
| -------------- | ------------------------------------------------------------------------------------- |
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);发布状态卡 + 草稿卡 + 历史版本表 |
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
| 信任内容 | 列表行(缩略图或类型图标 + 标题 + 类型/发布状态标签 + 两行摘要 + 行内操作),不用表格 |
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
| 模板与表单设置 | 行业模板网格(三列)+ 咨询表单字段编辑器 + 底部危险操作区 |
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
| 页面 | 结构要点 |
| -------------- | ---------------------------------------------------------------------------------------------------------------------- |
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);发布状态卡 + 草稿卡 + 历史版本表 |
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
| 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
| 模板与表单设置 | 行业模板网格(三列)+ 咨询表单字段编辑器 + 底部危险操作区 |
| 能力插件 | 插件卡片列表(图标 + 名称 + 说明 + 开关),停用态降低对比度 |
| 团队成员 | 表格(成员 / 角色 / 状态 / 最近登录 / 操作)+ 邀请弹窗 |
两栏页面在小屏下折叠为单列,编辑/预览改为上下排列。
+1 -1
View File
@@ -148,7 +148,7 @@ export function MembersPage() {
}}
onOk={() => addForm.submit()}
confirmLoading={create.isPending}
destroyOnClose
destroyOnHidden
>
<Form
form={addForm}
@@ -2,6 +2,7 @@ import { Button, Form } from "antd";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { AdminSection } from "../../components/AdminSection.js";
import { QueryState } from "../../components/QueryState.js";
import { StatusTag } from "../../components/StatusTag.js";
import { TrustContentEditorModal } from "./components/TrustContentEditorModal.js";
import { TrustContentList } from "./components/TrustContentList.js";
import { TrustRequirementsList } from "./components/TrustRequirementsList.js";
@@ -10,6 +11,7 @@ import {
createTrustPageLabelResolver,
groupTrustContentByType,
selectTrustTypeOptions,
sortTrustContentByTypeOrder,
} from "./domain/trust-content-domain.js";
import { useTrustContentEditor } from "./hooks/useTrustContentEditor.js";
import { useTrustContentQueries } from "./hooks/useTrustContentQueries.js";
@@ -18,7 +20,8 @@ export function TrustContentPage() {
const { query, workspace } = useTrustContentQueries();
const availableTypes = selectTrustTypeOptions(workspace.data?.templateContent?.trustContentTypes);
const pageLabel = createTrustPageLabelResolver(workspace.data?.templateContent?.navigation);
const contentByType = groupTrustContentByType(query.data ?? []);
const items = sortTrustContentByTypeOrder(query.data ?? [], availableTypes);
const contentByType = groupTrustContentByType(items);
const firstMissingRequiredType =
availableTypes.find((item) => item.required && !contentByType.has(item.type))?.type ??
availableTypes[0]?.type ??
@@ -69,16 +72,22 @@ export function TrustContentPage() {
<TrustRequirementsList
availableTypes={availableTypes}
contentByType={contentByType}
items={query.data ?? []}
items={items}
pageLabel={pageLabel}
onEdit={begin}
/>
</AdminSection>
<AdminSection title="已配置的品牌内容">
<AdminSection
title="已配置的品牌内容"
description="同一类型可以保存多条;标记为草稿的内容不会随品牌发布展示。"
extra={<StatusTag tone="info" label={`共 ${items.length} 条`} />}
>
<TrustContentList
availableTypes={availableTypes}
items={query.data ?? []}
items={items}
pageLabel={pageLabel}
removeError={remove.error}
removePending={remove.isPending}
removePendingId={remove.isPending ? remove.variables : undefined}
onCreate={() => begin()}
onEdit={(item) => begin(item)}
onDelete={(id) => remove.mutate(id)}
@@ -36,7 +36,7 @@ export function TrustContentEditorModal({
onCancel={onCancel}
onOk={() => form.submit()}
confirmLoading={savePending}
destroyOnClose
destroyOnHidden
>
<Form
form={form}
@@ -6,20 +6,23 @@ 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";
import { TrustContentTypeIcon } from "./TrustContentTypeIcon.js";
export function TrustContentList({
availableTypes,
items,
pageLabel,
removeError,
removePending,
removePendingId,
onCreate,
onEdit,
onDelete,
}: {
availableTypes: TrustTypeOption[];
items: TrustContent[];
pageLabel: (page: string) => string;
removeError: unknown;
removePending: boolean;
removePendingId?: string | undefined;
onCreate: () => void;
onEdit: (item: TrustContent) => void;
onDelete: (id: string) => void;
@@ -31,11 +34,7 @@ export function TrustContentList({
icon={<FileTextOutlined />}
title="还没有品牌内容"
description="按上方模板要求逐项添加,访客才能看到你的经历与证明。"
action={
<Button type="primary" onClick={onCreate}>
添加品牌内容
</Button>
}
action={<Button onClick={onCreate}>添加品牌内容</Button>}
/>
</section>
);
@@ -45,24 +44,28 @@ export function TrustContentList({
<ul className="admin-list">
{items.map((item) => {
const typeMeta = availableTypes.find((type) => type.type === item.type);
const pages = (typeMeta?.pages ?? []).map(pageLabel);
const meta = [typeMeta?.label ?? item.type]
.concat(pages.length ? `展示于${pages.join("、")}` : [])
.join(" · ");
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 />
<TrustContentTypeIcon type={item.type} />
)}
</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 ? "随发布展示" : "草稿"}
label={item.isPublished ? "已发布" : "草稿"}
/>
</div>
<p className="admin-row-meta">{meta}</p>
<p className="admin-row-summary">{getTrustContentPreview(item, typeMeta)}</p>
</div>
<div className="admin-record__actions">
@@ -70,11 +73,11 @@ export function TrustContentList({
编辑
</Button>
<Popconfirm
title="确认删除这条信任内容?"
title="确认删除这条品牌内容?"
description="删除后需发布品牌,才会更新小程序展示。"
onConfirm={() => onDelete(item.id)}
>
<Button type="link" size="small" danger loading={removePending}>
<Button type="link" size="small" danger loading={removePendingId === item.id}>
删除
</Button>
</Popconfirm>
@@ -0,0 +1,24 @@
import {
ApartmentOutlined,
ClockCircleOutlined,
EnvironmentOutlined,
FileTextOutlined,
SafetyCertificateOutlined,
StarOutlined,
CheckCircleOutlined,
} from "@ant-design/icons";
import type { ReactNode } from "react";
// 类型图标只为让列表可扫读,模板未声明的类型回落到通用图标。
const TYPE_ICONS: Record<string, ReactNode> = {
schedule: <ClockCircleOutlined />,
coverage: <EnvironmentOutlined />,
process: <ApartmentOutlined />,
credential: <SafetyCertificateOutlined />,
case: <StarOutlined />,
promise: <CheckCircleOutlined />,
};
export function TrustContentTypeIcon({ type }: { type: string }) {
return <>{TYPE_ICONS[type] ?? <FileTextOutlined />}</>;
}
@@ -8,11 +8,13 @@ export function TrustRequirementsList({
availableTypes,
contentByType,
items,
pageLabel,
onEdit,
}: {
availableTypes: TrustTypeOption[];
contentByType: Map<string, TrustContent>;
items: TrustContent[];
pageLabel: (page: string) => string;
onEdit: (item?: TrustContent, type?: string) => void;
}) {
return (
@@ -22,6 +24,7 @@ export function TrustRequirementsList({
const publishedCount = items.filter(
(record) => record.type === item.type && record.isPublished,
).length;
const configuredCount = items.filter((record) => record.type === item.type).length;
const tooMany =
item.maxPublishedItems !== undefined && publishedCount > item.maxPublishedItems;
const complete = Boolean(content && isTrustContentComplete(content, item) && !tooMany);
@@ -44,9 +47,12 @@ export function TrustRequirementsList({
: "尚未填写"
}
/>
{configuredCount > 1 ? (
<span className="admin-row-meta">已配置 {configuredCount} 条</span>
) : null}
{(item.pages ?? []).map((page) => (
<span key={page} className="admin-row-meta">
{page}
{pageLabel(page)}
</span>
))}
</div>
@@ -65,8 +65,10 @@ export const fallbackTrustTypes: TrustTypeOption[] = fallbackTypeSeeds.map(
const pageLabels: Record<string, string> = {
home: "首页",
offerings: "业务展示页",
service: "服务介绍页",
detail: "详情页",
profile: "主理人页",
inquiry: "咨询页",
};
export function createTrustPageLabelResolver(navigation?: Array<{ page: string; label: string }>) {
@@ -100,18 +102,51 @@ export function groupTrustContentByType(items: TrustContent[]) {
export function getTrustContentPreview(item: TrustContent, typeMeta?: TrustTypeOption): string {
if (typeMeta?.hideStandardFields?.includes("content")) {
return (
typeMeta.configFields
?.flatMap((field) => {
const value = item.config?.[field.key];
if (Array.isArray(value)) {
return value.length ? [`${field.label}:${value.length} 项`] : [];
}
return typeof value === "string" && value.trim() ? [`${field.label}:${value}`] : [];
})
.join(";") || "尚未填写区块内容"
);
const fragments =
typeMeta.configFields?.flatMap((field) => {
const value = item.config?.[field.key];
if (Array.isArray(value)) {
return value.length ? [`${field.label}:${value.length} 项`] : [];
}
if (typeof value !== "string") return [];
const text = value.trim();
return text ? [`${field.label}:${stripFieldLabel(field.label, text)}`] : [];
}) ?? [];
if (!fragments.length) return "尚未填写区块内容";
return fragments.length > 3 ? `${fragments.slice(0, 3).join(";")}…` : fragments.join(";");
}
return item.summary || item.content || "未填写";
}
// 模板示例数据常把展示前缀写进值内(如“地点:…”),与字段名重复时去掉。
function stripFieldLabel(label: string, value: string): string {
const match = /^([^::]{1,8})[::]\s*/.exec(value);
if (!match) return value;
const token = (match[1] ?? "").trim();
if (token && sharesMeaningfulOverlap(label, token)) return value.slice(match[0].length);
return value;
}
// 前缀与字段名只要有两个连续字重合,就视为重复标签。
function sharesMeaningfulOverlap(label: string, token: string): boolean {
if (token.length < 2) return label.includes(token);
for (let index = 0; index + 2 <= token.length; index += 1) {
if (label.includes(token.slice(index, index + 2))) return true;
}
return false;
}
// 列表按模板声明的类型顺序排列,与「当前模板需要配置的内容」保持一致。
export function sortTrustContentByTypeOrder(
items: TrustContent[],
availableTypes: TrustTypeOption[],
): TrustContent[] {
const orderOf = new Map(availableTypes.map((item, index) => [item.type, index]));
return [...items].sort((left, right) => {
const leftOrder = orderOf.get(left.type) ?? availableTypes.length;
const rightOrder = orderOf.get(right.type) ?? availableTypes.length;
if (leftOrder !== rightOrder) return leftOrder - rightOrder;
return left.title.localeCompare(right.title, "zh-Hans-CN");
});
}
+15 -1
View File
@@ -286,7 +286,8 @@ body {
list-style: none;
}
.admin-record {
.admin-row.admin-record {
align-items: flex-start;
gap: 12px;
}
@@ -295,6 +296,7 @@ body {
display: inline-flex;
align-items: center;
justify-content: center;
margin-top: 2px;
width: 48px;
height: 48px;
border-radius: 8px;
@@ -315,6 +317,7 @@ body {
flex: none;
display: flex;
align-items: center;
align-self: center;
gap: 4px;
}
@@ -332,9 +335,20 @@ body {
}
.admin-row-main {
display: flex;
flex-direction: column;
gap: 4px;
flex: 1 1 auto;
min-width: 0;
}
/* 行内段落默认自带浏览器下边距,行内布局统一交给 gap 控制。 */
.admin-row-main > .admin-row-meta,
.admin-row-main > .admin-row-summary,
.admin-row-main > .admin-row-help {
margin: 0;
}
.admin-row-line {
display: flex;
align-items: center;