mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:48:13 +08:00
perf: 优化编辑器性能 (#9432)
This commit is contained in:
parent
4603f4648b
commit
f45cb59072
@ -100,13 +100,14 @@ export class ContainerWrapper extends React.Component<ContainerWrapperProps> {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
const region = Array.isArray(rest[key])
|
let region = Array.isArray(rest[key])
|
||||||
? rest[key].concat()
|
? rest[key]
|
||||||
: rest[key]
|
: rest[key]
|
||||||
? [rest[key]]
|
? [rest[key]]
|
||||||
: defaultRegion;
|
: defaultRegion;
|
||||||
|
|
||||||
if (!region.length) {
|
if (!region.length) {
|
||||||
|
region = region.concat();
|
||||||
region.push({children: () => null});
|
region.push({children: () => null});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,20 +222,23 @@ export const EditorNode = types
|
|||||||
},
|
},
|
||||||
|
|
||||||
get uniqueChildren() {
|
get uniqueChildren() {
|
||||||
let children = self.children.filter(
|
let children: Array<any> = [];
|
||||||
(child, index, list) =>
|
let map: Record<string, any> = {};
|
||||||
list.findIndex(a =>
|
self.children.forEach(child => {
|
||||||
child.isRegion
|
const key = child.isRegion ? `${child.region}-${child.id}` : child.id;
|
||||||
? a.id === child.id && a.region === child.region
|
if (map[key]) {
|
||||||
: a.id === child.id
|
return;
|
||||||
) === index
|
}
|
||||||
);
|
|
||||||
|
map[key] = true;
|
||||||
|
children.push(child);
|
||||||
|
});
|
||||||
|
|
||||||
if (Array.isArray(this.schema)) {
|
if (Array.isArray(this.schema)) {
|
||||||
const arr = this.schema;
|
const arr = this.schema.map(item => item?.$$id).filter(item => item);
|
||||||
children = children.sort((a, b) => {
|
children = children.sort((a, b) => {
|
||||||
const idxa = findIndex(arr, item => item?.$$id === a.id);
|
const idxa = arr.indexOf(a.id);
|
||||||
const idxb = findIndex(arr, item => item?.$$id === b.id);
|
const idxb = arr.indexOf(b.id);
|
||||||
return idxa - idxb;
|
return idxa - idxb;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user