mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
feat: 组件id重复后,重新赋值 (#10965)
Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
This commit is contained in:
parent
ca832e951f
commit
d19c7af137
@ -1879,6 +1879,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) => {
|
||||
@ -1887,9 +1888,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, node.schemaPath);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -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, string>
|
||||
) {
|
||||
// 避免重复 patch
|
||||
if (self.patched && !force) {
|
||||
@ -720,6 +721,11 @@ export const EditorNode = types
|
||||
patched = {...patched, id: 'u:' + guid()};
|
||||
}
|
||||
|
||||
// id重复了,重新生成一个
|
||||
if (ids?.has(patched.id) && ids?.get(patched.id) !== self.schemaPath) {
|
||||
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