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
+121 -30

No files matched your search

+2 -2
View File
@@ -266,13 +266,13 @@
以下为各页面的视觉结构约定,业务逻辑不变。 以下为各页面的视觉结构约定,业务逻辑不变。
| 页面 | 结构要点 | | 页面 | 结构要点 |
| -------------- | ------------------------------------------------------------------------------------- | | -------------- | ---------------------------------------------------------------------------------------------------------------------- |
| 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 | | 登录 | 居中 400px 卡片,标识 + 说明 + 表单 + 通栏主按钮;错误态展示在字段下方 |
| 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 | | 首次改密 | 同登录卡片形态,说明文案 + 三个密码字段 + 「保存新密码」 |
| 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) | | 品牌概览 | 品牌卡 + 三张指标卡(等宽一行)+ 两栏(发布准备度 / 品牌内容检查) |
| 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);发布状态卡 + 草稿卡 + 历史版本表 | | 配置与发布 | 三 Tab(内容发布 / 小程序发布 / 小程序配置);发布状态卡 + 草稿卡 + 历史版本表 |
| 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 | | 小程序页面 | 左右两栏:左 380px 编辑面板,右预览画布;预览内选中区域虚线高亮 + 区域名气泡 |
| 信任内容 | 列表行(缩略图或类型图标 + 标题 + 类型/发布状态标签 + 两行摘要 + 行内操作),不用表格 | | 信任内容 | 列表行(类型图标或配图 + 标题 + 发布状态标签 + 类型/展示位置说明 + 两行摘要 + 行内操作),按模板类型顺序排列,不用表格 |
| 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 | | 业务提供项 | 表格(名称 / 价格 / 状态开关 / 排序 / 操作)+ 新增弹窗 |
| 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 | | 咨询记录 | 顶部三指标 + 左 380px 列表 + 右详情的主从布局 |
| 模板与表单设置 | 行业模板网格(三列)+ 咨询表单字段编辑器 + 底部危险操作区 | | 模板与表单设置 | 行业模板网格(三列)+ 咨询表单字段编辑器 + 底部危险操作区 |
+1 -1
View File
@@ -148,7 +148,7 @@ export function MembersPage() {
}} }}
onOk={() => addForm.submit()} onOk={() => addForm.submit()}
confirmLoading={create.isPending} confirmLoading={create.isPending}
destroyOnClose destroyOnHidden
> >
<Form <Form
form={addForm} form={addForm}
@@ -2,6 +2,7 @@ import { Button, Form } from "antd";
import { AdminPageHeader } from "../../components/AdminPageHeader.js"; import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { AdminSection } from "../../components/AdminSection.js"; import { AdminSection } from "../../components/AdminSection.js";
import { QueryState } from "../../components/QueryState.js"; import { QueryState } from "../../components/QueryState.js";
import { StatusTag } from "../../components/StatusTag.js";
import { TrustContentEditorModal } from "./components/TrustContentEditorModal.js"; import { TrustContentEditorModal } from "./components/TrustContentEditorModal.js";
import { TrustContentList } from "./components/TrustContentList.js"; import { TrustContentList } from "./components/TrustContentList.js";
import { TrustRequirementsList } from "./components/TrustRequirementsList.js"; import { TrustRequirementsList } from "./components/TrustRequirementsList.js";
@@ -10,6 +11,7 @@ import {
createTrustPageLabelResolver, createTrustPageLabelResolver,
groupTrustContentByType, groupTrustContentByType,
selectTrustTypeOptions, selectTrustTypeOptions,
sortTrustContentByTypeOrder,
} from "./domain/trust-content-domain.js"; } from "./domain/trust-content-domain.js";
import { useTrustContentEditor } from "./hooks/useTrustContentEditor.js"; import { useTrustContentEditor } from "./hooks/useTrustContentEditor.js";
import { useTrustContentQueries } from "./hooks/useTrustContentQueries.js"; import { useTrustContentQueries } from "./hooks/useTrustContentQueries.js";
@@ -18,7 +20,8 @@ export function TrustContentPage() {
const { query, workspace } = useTrustContentQueries(); const { query, workspace } = useTrustContentQueries();
const availableTypes = selectTrustTypeOptions(workspace.data?.templateContent?.trustContentTypes); const availableTypes = selectTrustTypeOptions(workspace.data?.templateContent?.trustContentTypes);
const pageLabel = createTrustPageLabelResolver(workspace.data?.templateContent?.navigation); const pageLabel = createTrustPageLabelResolver(workspace.data?.templateContent?.navigation);
const contentByType = groupTrustContentByType(query.data ?? []); const items = sortTrustContentByTypeOrder(query.data ?? [], availableTypes);
const contentByType = groupTrustContentByType(items);
const firstMissingRequiredType = const firstMissingRequiredType =
availableTypes.find((item) => item.required && !contentByType.has(item.type))?.type ?? availableTypes.find((item) => item.required && !contentByType.has(item.type))?.type ??
availableTypes[0]?.type ?? availableTypes[0]?.type ??
@@ -69,16 +72,22 @@ export function TrustContentPage() {
<TrustRequirementsList <TrustRequirementsList
availableTypes={availableTypes} availableTypes={availableTypes}
contentByType={contentByType} contentByType={contentByType}
items={query.data ?? []} items={items}
pageLabel={pageLabel}
onEdit={begin} onEdit={begin}
/> />
</AdminSection> </AdminSection>
<AdminSection title="已配置的品牌内容"> <AdminSection
title="已配置的品牌内容"
description="同一类型可以保存多条;标记为草稿的内容不会随品牌发布展示。"
extra={<StatusTag tone="info" label={`共 ${items.length} 条`} />}
>
<TrustContentList <TrustContentList
availableTypes={availableTypes} availableTypes={availableTypes}
items={query.data ?? []} items={items}
pageLabel={pageLabel}
removeError={remove.error} removeError={remove.error}
removePending={remove.isPending} removePendingId={remove.isPending ? remove.variables : undefined}
onCreate={() => begin()} onCreate={() => begin()}
onEdit={(item) => begin(item)} onEdit={(item) => begin(item)}
onDelete={(id) => remove.mutate(id)} onDelete={(id) => remove.mutate(id)}
@@ -36,7 +36,7 @@ export function TrustContentEditorModal({
onCancel={onCancel} onCancel={onCancel}
onOk={() => form.submit()} onOk={() => form.submit()}
confirmLoading={savePending} confirmLoading={savePending}
destroyOnClose destroyOnHidden
> >
<Form <Form
form={form} form={form}
@@ -6,20 +6,23 @@ import { MutationError } from "../../../components/QueryState.js";
import { StatusTag } from "../../../components/StatusTag.js"; import { StatusTag } from "../../../components/StatusTag.js";
import type { TrustTypeOption } from "../domain/trust-content-domain.js"; import type { TrustTypeOption } from "../domain/trust-content-domain.js";
import { getTrustContentPreview } from "../domain/trust-content-domain.js"; import { getTrustContentPreview } from "../domain/trust-content-domain.js";
import { TrustContentTypeIcon } from "./TrustContentTypeIcon.js";
export function TrustContentList({ export function TrustContentList({
availableTypes, availableTypes,
items, items,
pageLabel,
removeError, removeError,
removePending, removePendingId,
onCreate, onCreate,
onEdit, onEdit,
onDelete, onDelete,
}: { }: {
availableTypes: TrustTypeOption[]; availableTypes: TrustTypeOption[];
items: TrustContent[]; items: TrustContent[];
pageLabel: (page: string) => string;
removeError: unknown; removeError: unknown;
removePending: boolean; removePendingId?: string | undefined;
onCreate: () => void; onCreate: () => void;
onEdit: (item: TrustContent) => void; onEdit: (item: TrustContent) => void;
onDelete: (id: string) => void; onDelete: (id: string) => void;
@@ -31,11 +34,7 @@ export function TrustContentList({
icon={<FileTextOutlined />} icon={<FileTextOutlined />}
title="还没有品牌内容" title="还没有品牌内容"
description="按上方模板要求逐项添加,访客才能看到你的经历与证明。" description="按上方模板要求逐项添加,访客才能看到你的经历与证明。"
action={ action={<Button onClick={onCreate}>添加品牌内容</Button>}
<Button type="primary" onClick={onCreate}>
添加品牌内容
</Button>
}
/> />
</section> </section>
); );
@@ -45,24 +44,28 @@ export function TrustContentList({
<ul className="admin-list"> <ul className="admin-list">
{items.map((item) => { {items.map((item) => {
const typeMeta = availableTypes.find((type) => type.type === item.type); 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 ( return (
<li key={item.id} className="admin-row admin-record"> <li key={item.id} className="admin-row admin-record">
<div className="admin-record__thumb"> <div className="admin-record__thumb">
{item.coverUrl ? ( {item.coverUrl ? (
<img src={item.coverUrl} alt="" loading="lazy" /> <img src={item.coverUrl} alt="" loading="lazy" />
) : ( ) : (
<FileTextOutlined /> <TrustContentTypeIcon type={item.type} />
)} )}
</div> </div>
<div className="admin-row-main"> <div className="admin-row-main">
<div className="admin-row-line"> <div className="admin-row-line">
<span className="admin-row-title">{item.title}</span> <span className="admin-row-title">{item.title}</span>
<StatusTag tone="neutral" label={typeMeta?.label ?? item.type} />
<StatusTag <StatusTag
tone={item.isPublished ? "success" : "neutral"} tone={item.isPublished ? "success" : "neutral"}
label={item.isPublished ? "随发布展示" : "草稿"} label={item.isPublished ? "已发布" : "草稿"}
/> />
</div> </div>
<p className="admin-row-meta">{meta}</p>
<p className="admin-row-summary">{getTrustContentPreview(item, typeMeta)}</p> <p className="admin-row-summary">{getTrustContentPreview(item, typeMeta)}</p>
</div> </div>
<div className="admin-record__actions"> <div className="admin-record__actions">
@@ -70,11 +73,11 @@ export function TrustContentList({
编辑 编辑
</Button> </Button>
<Popconfirm <Popconfirm
title="确认删除这条信任内容?" title="确认删除这条品牌内容?"
description="删除后需发布品牌,才会更新小程序展示。" description="删除后需发布品牌,才会更新小程序展示。"
onConfirm={() => onDelete(item.id)} onConfirm={() => onDelete(item.id)}
> >
<Button type="link" size="small" danger loading={removePending}> <Button type="link" size="small" danger loading={removePendingId === item.id}>
删除 删除
</Button> </Button>
</Popconfirm> </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, availableTypes,
contentByType, contentByType,
items, items,
pageLabel,
onEdit, onEdit,
}: { }: {
availableTypes: TrustTypeOption[]; availableTypes: TrustTypeOption[];
contentByType: Map<string, TrustContent>; contentByType: Map<string, TrustContent>;
items: TrustContent[]; items: TrustContent[];
pageLabel: (page: string) => string;
onEdit: (item?: TrustContent, type?: string) => void; onEdit: (item?: TrustContent, type?: string) => void;
}) { }) {
return ( return (
@@ -22,6 +24,7 @@ export function TrustRequirementsList({
const publishedCount = items.filter( const publishedCount = items.filter(
(record) => record.type === item.type && record.isPublished, (record) => record.type === item.type && record.isPublished,
).length; ).length;
const configuredCount = items.filter((record) => record.type === item.type).length;
const tooMany = const tooMany =
item.maxPublishedItems !== undefined && publishedCount > item.maxPublishedItems; item.maxPublishedItems !== undefined && publishedCount > item.maxPublishedItems;
const complete = Boolean(content && isTrustContentComplete(content, item) && !tooMany); 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) => ( {(item.pages ?? []).map((page) => (
<span key={page} className="admin-row-meta"> <span key={page} className="admin-row-meta">
{page} {pageLabel(page)}
</span> </span>
))} ))}
</div> </div>
@@ -65,8 +65,10 @@ export const fallbackTrustTypes: TrustTypeOption[] = fallbackTypeSeeds.map(
const pageLabels: Record<string, string> = { const pageLabels: Record<string, string> = {
home: "首页", home: "首页",
offerings: "业务展示页", offerings: "业务展示页",
service: "服务介绍页",
detail: "详情页", detail: "详情页",
profile: "主理人页", profile: "主理人页",
inquiry: "咨询页",
}; };
export function createTrustPageLabelResolver(navigation?: Array<{ page: string; label: string }>) { 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 { export function getTrustContentPreview(item: TrustContent, typeMeta?: TrustTypeOption): string {
if (typeMeta?.hideStandardFields?.includes("content")) { if (typeMeta?.hideStandardFields?.includes("content")) {
return ( const fragments =
typeMeta.configFields typeMeta.configFields?.flatMap((field) => {
?.flatMap((field) => {
const value = item.config?.[field.key]; const value = item.config?.[field.key];
if (Array.isArray(value)) { if (Array.isArray(value)) {
return value.length ? [`${field.label}:${value.length} 项`] : []; return value.length ? [`${field.label}:${value.length} 项`] : [];
} }
return typeof value === "string" && value.trim() ? [`${field.label}:${value}`] : []; if (typeof value !== "string") return [];
}) const text = value.trim();
.join(";") || "尚未填写区块内容" 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 || "未填写"; 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; list-style: none;
} }
.admin-record { .admin-row.admin-record {
align-items: flex-start;
gap: 12px; gap: 12px;
} }
@@ -295,6 +296,7 @@ body {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top: 2px;
width: 48px; width: 48px;
height: 48px; height: 48px;
border-radius: 8px; border-radius: 8px;
@@ -315,6 +317,7 @@ body {
flex: none; flex: none;
display: flex; display: flex;
align-items: center; align-items: center;
align-self: center;
gap: 4px; gap: 4px;
} }
@@ -332,9 +335,20 @@ body {
} }
.admin-row-main { .admin-row-main {
display: flex;
flex-direction: column;
gap: 4px;
flex: 1 1 auto;
min-width: 0; 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 { .admin-row-line {
display: flex; display: flex;
align-items: center; align-items: center;