fix: 完善模板可视化编辑闭环与通用验收
This commit is contained in:
1 parent
fa6b492bce
commit
22a82dbfba
39 files changed
+7773
-443
No files matched your search
@@ -1,11 +1,21 @@
|
||||
export type PreviewSelection = { targetKey: string; recordId?: string };
|
||||
|
||||
// 与模板 slot 一致,优先选择承载结构化内容的记录。
|
||||
export function previewTrustRecordId(
|
||||
items: { id?: string; type: string; config: Record<string, unknown> }[],
|
||||
type: string | undefined,
|
||||
): string | undefined {
|
||||
const matches = items.filter((item) => item.type === type);
|
||||
return (matches.find((item) => Object.keys(item.config).length > 0) ?? matches[0])?.id;
|
||||
}
|
||||
|
||||
export type PreviewTarget = {
|
||||
key: string;
|
||||
label: string;
|
||||
source: "brand" | "offering" | "trust" | "inquiry";
|
||||
page: string;
|
||||
composite?: boolean;
|
||||
trustType?: string;
|
||||
children?: string[];
|
||||
};
|
||||
|
||||
@@ -18,6 +28,6 @@ export function resolvePreviewSelection(
|
||||
const target = targets.find((item) => item.key === targetKey && item.page === page);
|
||||
if (!target) return undefined;
|
||||
if (recordId && target.source !== "offering" && target.source !== "trust") return undefined;
|
||||
if (!recordId && (target.source === "offering" || target.source === "trust")) return undefined;
|
||||
// 空区域仍可选中,编辑面板提供创建内容的入口。
|
||||
return recordId ? { targetKey, recordId } : { targetKey };
|
||||
}
|
||||
Reference in new issue
Block a user