- 统一说明文案层级:Typography.Paragraph 次要文案迁移到 admin-section-description - 状态色补齐边框与中间调令牌,Alert/错误条/Descriptions 与 StatusTag 同源 - 咨询详情描述列表去表格线,改为键值展示并统一令牌 - 新增 BrandMark,侧栏与登录页标识改用品牌首字 - 信任内容改用列表行,空状态、表格骨架屏、主按钮脏检查落地 - design.md 同步令牌映射、切换控件选型与组件清单
102 lines
3.7 KiB
TypeScript
102 lines
3.7 KiB
TypeScript
import { Button, Form } from "antd";
|
|
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 { TrustContentList } from "./components/TrustContentList.js";
|
|
import { TrustRequirementsList } from "./components/TrustRequirementsList.js";
|
|
import type { TrustTypeOption } from "./domain/trust-content-domain.js";
|
|
import {
|
|
createTrustPageLabelResolver,
|
|
groupTrustContentByType,
|
|
selectTrustTypeOptions,
|
|
} from "./domain/trust-content-domain.js";
|
|
import { useTrustContentEditor } from "./hooks/useTrustContentEditor.js";
|
|
import { useTrustContentQueries } from "./hooks/useTrustContentQueries.js";
|
|
|
|
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 firstMissingRequiredType =
|
|
availableTypes.find((item) => item.required && !contentByType.has(item.type))?.type ??
|
|
availableTypes[0]?.type ??
|
|
"credential";
|
|
const {
|
|
begin,
|
|
closeEditor,
|
|
editing,
|
|
form: editorForm,
|
|
open,
|
|
remove,
|
|
save,
|
|
} = useTrustContentEditor({
|
|
availableTypes,
|
|
contentByType,
|
|
firstMissingRequiredType,
|
|
});
|
|
const selectedType = Form.useWatch("type", editorForm);
|
|
const selectedTypeMeta: TrustTypeOption | undefined = availableTypes.find(
|
|
(item) => item.type === selectedType,
|
|
);
|
|
const trustPageLabels = [
|
|
...new Set(availableTypes.flatMap((item) => item.pages ?? []).map(pageLabel)),
|
|
];
|
|
const trustPlacement = trustPageLabels.length
|
|
? `小程序的${trustPageLabels.join("、")}中`
|
|
: "小程序对应的信任展示区域中";
|
|
|
|
return (
|
|
<QueryState
|
|
loading={query.isLoading || workspace.isLoading}
|
|
error={query.error || workspace.error}
|
|
onRetry={() => void Promise.all([query.refetch(), workspace.refetch()])}
|
|
>
|
|
<AdminPageHeader
|
|
title="小程序内容:品牌介绍与信任"
|
|
description={`填写真实的经历、案例、资历、流程和服务说明。这些内容会显示在${trustPlacement};保存后需发布品牌,小程序才会更新。`}
|
|
extra={
|
|
<Button type="primary" onClick={() => begin()}>
|
|
添加品牌内容
|
|
</Button>
|
|
}
|
|
/>
|
|
<AdminSection
|
|
title="当前模板需要配置的内容"
|
|
description="标记为「发布必填」的项目需要填写完整后,才能发布小程序。"
|
|
>
|
|
<TrustRequirementsList
|
|
availableTypes={availableTypes}
|
|
contentByType={contentByType}
|
|
items={query.data ?? []}
|
|
onEdit={begin}
|
|
/>
|
|
</AdminSection>
|
|
<AdminSection title="已配置的品牌内容">
|
|
<TrustContentList
|
|
availableTypes={availableTypes}
|
|
items={query.data ?? []}
|
|
removeError={remove.error}
|
|
removePending={remove.isPending}
|
|
onCreate={() => begin()}
|
|
onEdit={(item) => begin(item)}
|
|
onDelete={(id) => remove.mutate(id)}
|
|
/>
|
|
</AdminSection>
|
|
<TrustContentEditorModal
|
|
availableTypes={availableTypes}
|
|
editing={editing}
|
|
form={editorForm}
|
|
open={open}
|
|
pageLabel={pageLabel}
|
|
saveError={save.error}
|
|
savePending={save.isPending}
|
|
selectedTypeMeta={selectedTypeMeta}
|
|
onCancel={closeEditor}
|
|
onFinish={(values) => save.mutate(values)}
|
|
/>
|
|
</QueryState>
|
|
);
|
|
}
|