mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
feat: 组件id重复后,重新赋值 (#10943)
Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
This commit is contained in:
parent
e342fad3d0
commit
a22fc82283
@ -1878,6 +1878,7 @@ 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) => {
|
||||
@ -1886,9 +1887,14 @@ export class EditorManager {
|
||||
}
|
||||
|
||||
if (isAlive(node) && !node.isRegion) {
|
||||
node.patch(this.store, force, (id, value) =>
|
||||
batch.unshift({id, value})
|
||||
const schema = node.schema;
|
||||
node.patch(
|
||||
this.store,
|
||||
force,
|
||||
(id, value) => batch.unshift({id, value}),
|
||||
ids
|
||||
);
|
||||
ids.set(schema.id, true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -698,7 +698,8 @@ export const EditorNode = types
|
||||
patch(
|
||||
store: any,
|
||||
force = false,
|
||||
setPatchInfo?: (id: string, value: any) => void
|
||||
setPatchInfo?: (id: string, value: any) => void,
|
||||
ids?: Map<string, boolean>
|
||||
) {
|
||||
// 避免重复 patch
|
||||
if (self.patched && !force) {
|
||||
@ -720,6 +721,11 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user