diff --git a/.codex-tasks/template-audit-execution/raw/completion-evidence.json b/.codex-tasks/template-audit-execution/raw/completion-evidence.json index 2b3c673..eec19bc 100644 --- a/.codex-tasks/template-audit-execution/raw/completion-evidence.json +++ b/.codex-tasks/template-audit-execution/raw/completion-evidence.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "scope": "模板完成证据登记,保留命令、日志与产物哈希", - "generatedAt": "2026-10-23T14:07:47.923Z", + "generatedAt": "2026-10-24T02:02:12.474Z", "templates": { "acheng-campus-food": { "real-manifest-interaction": { @@ -256,5 +256,5 @@ } } }, - "sourceTreeHash": "9394ffb025e5f6b777f2dd991cbb8b56026d5d63d9161a8639cc612bcc39f730" + "sourceTreeHash": "9d33ce8dbbddd34b91f045f49dc2316e36738ffec1429a93733d45d1b7b2a356" } diff --git a/apps/admin/src/components/RecordContentEditor.tsx b/apps/admin/src/components/RecordContentEditor.tsx index b7f5014..90b3fd5 100644 --- a/apps/admin/src/components/RecordContentEditor.tsx +++ b/apps/admin/src/components/RecordContentEditor.tsx @@ -20,7 +20,7 @@ export function RecordContentFields({ return ( {section.fields.map((field) => ( - + {field.input === "list" ? ( ) : ( diff --git a/apps/admin/src/features/services/OfferingEditorModal.tsx b/apps/admin/src/features/services/OfferingEditorModal.tsx index 991fbd4..7e629eb 100644 --- a/apps/admin/src/features/services/OfferingEditorModal.tsx +++ b/apps/admin/src/features/services/OfferingEditorModal.tsx @@ -1,4 +1,5 @@ import { Alert, Button, Form, Input, Modal, Segmented, Select } from "antd"; +import { useEffect, useRef } from "react"; import type { Offering, RuntimeWorkspace, @@ -8,7 +9,7 @@ import type { import { ImageUrlField } from "../../components/ImageUrlField.js"; import { RecordContentFields } from "../../components/RecordContentEditor.js"; import { ComponentTemplatePreview } from "../brand/ComponentTemplatePreview.js"; -import type { PreviewTarget } from "../brand/preview-selection.js"; +import type { PreviewSelection, PreviewTarget } from "../brand/preview-selection.js"; import type { FormInstance } from "antd"; import "./ServicesPage.css"; @@ -20,6 +21,8 @@ type OfferingEditorModalProps = { previewWorkspace: RuntimeWorkspace | undefined; previewTargets: Record<"offerings" | "detail", PreviewTarget[]>; activeTemplateFields: TemplateAdminField[]; + activePreviewBindings: string[]; + selectedTarget: PreviewTarget | undefined; templateFieldSection: TemplateAdminSection; hasTemplateDetailCopy: boolean; listTarget: PreviewTarget; @@ -27,6 +30,7 @@ type OfferingEditorModalProps = { saving: boolean; onClose: () => void; onPreviewPageChange: (page: "offerings" | "detail") => void; + onPreviewTargetSelected: (selection?: PreviewSelection) => void; onValuesChange: (values: Record) => void; onFinish: (values: Record) => void; onEditInBrand: () => void; @@ -40,6 +44,8 @@ export function OfferingEditorModal({ previewWorkspace, previewTargets, activeTemplateFields, + activePreviewBindings, + selectedTarget, templateFieldSection, hasTemplateDetailCopy, listTarget, @@ -47,10 +53,33 @@ export function OfferingEditorModal({ saving, onClose, onPreviewPageChange, + onPreviewTargetSelected, onValuesChange, onFinish, onEditInBrand, }: OfferingEditorModalProps) { + const formScroll = useRef(null); + const defaultPreviewTarget = previewPage === "offerings" ? listTarget : detailTarget; + const previewSelectionTarget = selectedTarget ?? defaultPreviewTarget; + const previewSelection: PreviewSelection | undefined = previewSelectionTarget + ? previewSelectionTarget.source === "offering" && editingOffering + ? { targetKey: previewSelectionTarget.key, recordId: editingOffering.id } + : { targetKey: previewSelectionTarget.key } + : undefined; + + // 点选区块后,在右侧滚动到并高亮对应的输入项;品牌通用区块没有对应输入项时只保留提示。 + useEffect(() => { + const host = formScroll.current; + if (!host || !selectedTarget || activePreviewBindings.length === 0) return; + const bindings = new Set(activePreviewBindings); + const nodes = Array.from( + host.querySelectorAll("[data-presentation-binding]"), + ).filter((node) => bindings.has(node.dataset.presentationBinding ?? "")); + nodes.forEach((node) => node.classList.add("is-preview-active")); + nodes[0]?.scrollIntoView({ block: "center", behavior: "smooth" }); + return () => nodes.forEach((node) => node.classList.remove("is-preview-active")); + }, [selectedTarget, activePreviewBindings]); + return ( {}} + {...(previewSelection ? { selection: previewSelection } : {})} + onTargetSelected={onPreviewTargetSelected} /> ) : null} @@ -102,7 +128,7 @@ export function OfferingEditorModal({ onValuesChange={(_, allValues) => onValuesChange(allValues)} onFinish={onFinish} > -
+

基础信息

- + {!hasTemplateDetailCopy ? ( - + ) : null} - + @@ -151,13 +195,28 @@ export function OfferingEditorModal({ ]} /> + {selectedTarget && selectedTarget.source !== "offering" ? ( + + ) : null} {activeTemplateFields.length ? (

- {previewPage === "offerings" ? "列表展示字段" : "详情展示字段"} + {selectedTarget + ? `${selectedTarget.label}对应字段` + : previewPage === "offerings" + ? "列表展示字段" + : "详情展示字段"}

- 这里只编辑左侧预览对应的字段;它们与小程序页面编辑的是同一份业务数据。 + {selectedTarget + ? "右侧已定位到该区块使用的字段,修改会实时反映在左侧预览。" + : "这里只编辑左侧预览对应的字段;它们与小程序页面编辑的是同一份业务数据。"}

+ ) : selectedTarget?.source === "offering" ? ( + ) : null} {editingOffering ? (