mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-21 16:48:18 +00:00
fix: 修复在切换页面时,没有销毁相应节点导致的一系列bug
This commit is contained in:
parent
fe0fa8ea0b
commit
59fac25553
@ -33,7 +33,7 @@ export class DocumentModel {
|
|||||||
/**
|
/**
|
||||||
* 根节点 类型有:Page/Component/Block
|
* 根节点 类型有:Page/Component/Block
|
||||||
*/
|
*/
|
||||||
readonly rootNode: RootNode;
|
rootNode: RootNode | null;
|
||||||
/**
|
/**
|
||||||
* 文档编号
|
* 文档编号
|
||||||
*/
|
*/
|
||||||
@ -461,12 +461,16 @@ export class DocumentModel {
|
|||||||
* 从项目中移除
|
* 从项目中移除
|
||||||
*/
|
*/
|
||||||
remove() {
|
remove() {
|
||||||
|
this.purge();
|
||||||
this.project.removeDocument(this);
|
this.project.removeDocument(this);
|
||||||
// todo: ...
|
this.designer.postEvent('document.remove', { id: this.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
purge() {
|
purge() {
|
||||||
// todo:
|
this.rootNode?.purge();
|
||||||
|
this.nodes.clear();
|
||||||
|
this._nodesMap.clear();
|
||||||
|
this.rootNode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNesting(dropTarget: ParentalNode, dragObject: DragNodeObject | DragNodeDataObject): boolean {
|
checkNesting(dropTarget: ParentalNode, dragObject: DragNodeObject | DragNodeDataObject): boolean {
|
||||||
|
|||||||
@ -699,11 +699,11 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
if (this.purged) {
|
if (this.purged) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this._parent) {
|
// if (this._parent) {
|
||||||
// should remove thisNode before purge
|
// // should remove thisNode before purge
|
||||||
this.remove(useMutator);
|
// this.remove(useMutator);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
this.purged = true;
|
this.purged = true;
|
||||||
if (this.isParental()) {
|
if (this.isParental()) {
|
||||||
this.children.purge(useMutator);
|
this.children.purge(useMutator);
|
||||||
@ -711,8 +711,8 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
this.autoruns?.forEach((dispose) => dispose());
|
this.autoruns?.forEach((dispose) => dispose());
|
||||||
this.props.purge();
|
this.props.purge();
|
||||||
this.document.internalRemoveAndPurgeNode(this);
|
this.document.internalRemoveAndPurgeNode(this);
|
||||||
|
|
||||||
this.document.destroyNode(this);
|
this.document.destroyNode(this);
|
||||||
|
this.remove(useMutator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -54,6 +54,9 @@ export class TreeMaster {
|
|||||||
time: (endTime - startTime).toFixed(2),
|
time: (endTime - startTime).toFixed(2),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
designer.editor.on('designer.document.remove', ({ id }) => {
|
||||||
|
this.treeMap.delete(id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private toVision() {
|
private toVision() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user