feat: 完善模板区域预览与详情页编辑边界

This commit is contained in:
que01 committed 2026-10-10 09:51:12 +08:00
1 parent df2b1f6031
commit 849ae5df05
11 files changed
+236 -28

No files matched your search

@@ -35,7 +35,11 @@ import { TemplateListField } from "../../components/TemplateListField.js";
import { MutationError } from "../../components/QueryState.js";
import { TemplatePreview } from "./TemplatePreview.js";
import { InquiryPreviewEditor } from "./InquiryPreviewEditor.js";
import { resolvePreviewSelection, type PreviewSelection } from "./preview-selection.js";
import {
resolvePreviewSelection,
type PreviewSelection,
type PreviewTarget,
} from "./preview-selection.js";
import {
applyBrandPreviewValues,
applyStandardBrandValues,
@@ -219,7 +223,12 @@ export function PresentationEditor({
const selectedPage = pageOptions.some((item) => item.value === activePage)
? activePage
: pageOptions[0]?.value;
const visibleSections = sections.filter((section) => section.page === selectedPage);
const visibleSections = sections.filter(
(section) =>
section.page === selectedPage &&
// 详情页内容来自所选业务记录;不再展示一套额外的品牌级详情编辑器。
!(selectedPage === "detail" && section.target === "brand"),
);
const recordSections = useMemo(
() =>
(templateContent?.trustContentTypes ?? [])
@@ -227,10 +236,14 @@ export function PresentationEditor({
.map((item) => trustSection(item, selectedPage ?? "home")),
[templateContent, selectedPage],
);
const visibleTargets = useMemo(
const visibleTargets = useMemo<PreviewTarget[]>(
() =>
[...(templateContent?.admin.sections ?? []), ...recordSections]
.filter((section) => section.page === selectedPage)
.filter(
(section) =>
section.page === selectedPage &&
!(selectedPage === "detail" && section.target === "brand"),
)
.flatMap((section) =>
(section.previewTargets ?? []).map((target) => ({
...target,
@@ -621,7 +634,14 @@ export function PresentationEditor({
<Typography.Title level={5}>
{selectedTarget?.label ?? pageTitle(selectedPage ?? "home")}
</Typography.Title>
{activeTarget?.startsWith("inquiry-field:") && inquiryRuntime ? (
{selectedPage === "detail" ? (
<Alert
type="info"
showIcon
message="详情页由所选业务内容动态生成"
description="选择不同的业务内容即可预览对应详情;内容请在业务提供项中维护。"
/>
) : activeTarget?.startsWith("inquiry-field:") && inquiryRuntime ? (
<InquiryPreviewEditor
runtime={
draftWorkspace?.inquiryForms.find((item) => item.key === inquiryRuntime.key) ??
@@ -630,6 +650,43 @@ export function PresentationEditor({
fieldKey={activeTarget.slice("inquiry-field:".length)}
onDraft={setInquiryDraft}
/>
) : selectedTarget?.composite ? (
<Alert
type="info"
showIcon
message="这是一个组合区域"
description={
<Space wrap>
{(selectedTarget.children ?? []).map((childKey) => {
const child = visibleTargets.find((item) => item.key === childKey);
if (!child) return null;
return (
<Button
key={child.key}
onClick={() => {
const recordId =
child.source === "offering"
? selectedPage === "detail"
? selectedDetailOfferingId
: draftWorkspace?.offerings[0]?.id
: child.source === "trust"
? draftWorkspace?.trustItems.find(
(item) => child.key === `trust:${item.type}`,
)?.id
: undefined;
handleTargetSelected({
targetKey: child.key,
...(recordId ? { recordId } : {}),
});
}}
>
编辑{child.label}
</Button>
);
})}
</Space>
}
/>
) : selectedRecordSource && selection?.recordId && selectedSection ? (
selectedRecord ? (
<RecordEditor