mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:39:05 +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])
|
||||
? rest[key].concat()
|
||||
let region = Array.isArray(rest[key])
|
||||
? rest[key]
|
||||
: rest[key]
|
||||
? [rest[key]]
|
||||
: defaultRegion;
|
||||
|
||||
if (!region.length) {
|
||||
region = region.concat();
|
||||
region.push({children: () => null});
|
||||
}
|
||||
|
||||
|
@ -222,20 +222,23 @@ export const EditorNode = types
|
||||
},
|
||||
|
||||
get uniqueChildren() {
|
||||
let children = self.children.filter(
|
||||
(child, index, list) =>
|
||||
list.findIndex(a =>
|
||||
child.isRegion
|
||||
? a.id === child.id && a.region === child.region
|
||||
: a.id === child.id
|
||||
) === index
|
||||
);
|
||||
let children: Array<any> = [];
|
||||
let map: Record<string, any> = {};
|
||||
self.children.forEach(child => {
|
||||
const key = child.isRegion ? `${child.region}-${child.id}` : child.id;
|
||||
if (map[key]) {
|
||||
return;
|
||||
}
|
||||
|
||||
map[key] = true;
|
||||
children.push(child);
|
||||
});
|
||||
|
||||
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) => {
|
||||
const idxa = findIndex(arr, item => item?.$$id === a.id);
|
||||
const idxb = findIndex(arr, item => item?.$$id === b.id);
|
||||
const idxa = arr.indexOf(a.id);
|
||||
const idxb = arr.indexOf(b.id);
|
||||
return idxa - idxb;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user