Revert "feat: 组件id重复后,重新赋值 (#10943)" (#10964)

This reverts commit 9180df9dcd.
This commit is contained in:
liaoxuezhi 2024-09-25 16:44:09 +08:00 committed by GitHub
parent 9d0f5dc006
commit ca832e951f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 15 deletions

View File

@ -1879,7 +1879,6 @@ export class EditorManager {
this.patching = true;
this.patchingInvalid = false;
const batch: Array<{id: string; value: any}> = [];
const ids = new Map();
let patchList = (list: Array<EditorNodeType>) => {
// 深度优先
list.forEach((node: EditorNodeType) => {
@ -1888,14 +1887,9 @@ export class EditorManager {
}
if (isAlive(node) && !node.isRegion) {
const schema = node.schema;
node.patch(
this.store,
force,
(id, value) => batch.unshift({id, value}),
ids
node.patch(this.store, force, (id, value) =>
batch.unshift({id, value})
);
ids.set(schema.id, true);
}
});
};

View File

@ -698,8 +698,7 @@ export const EditorNode = types
patch(
store: any,
force = false,
setPatchInfo?: (id: string, value: any) => void,
ids?: Map<string, boolean>
setPatchInfo?: (id: string, value: any) => void
) {
// 避免重复 patch
if (self.patched && !force) {
@ -721,11 +720,6 @@ export const EditorNode = types
patched = {...patched, id: 'u:' + guid()};
}
// id重复了重新生成一个
if (ids?.has(patched.id)) {
patched = {...patched, id: 'u:' + guid()};
}
if (
(Array.isArray(info.regions) && info.regions.length) ||
Array.isArray(info.patchContainers)