mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-04-20 04:18:05 +00:00
fix: fieldId 重复
This commit is contained in:
parent
28f0213bcb
commit
5d643124c4
@ -51,7 +51,7 @@ export class DocumentModel {
|
|||||||
*/
|
*/
|
||||||
readonly modalNodesManager: ModalNodesManager;
|
readonly modalNodesManager: ModalNodesManager;
|
||||||
|
|
||||||
private nodesMap = new Map<string, Node>();
|
private _nodesMap = new Map<string, Node>();
|
||||||
@obx.val private nodes = new Set<Node>();
|
@obx.val private nodes = new Set<Node>();
|
||||||
private seqId = 0;
|
private seqId = 0;
|
||||||
private _simulator?: ISimulatorHost;
|
private _simulator?: ISimulatorHost;
|
||||||
@ -70,6 +70,10 @@ export class DocumentModel {
|
|||||||
return this._simulator || null;
|
return this._simulator || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get nodesMap(): Map<string, Node> {
|
||||||
|
return this._nodesMap;
|
||||||
|
}
|
||||||
|
|
||||||
get fileName(): string {
|
get fileName(): string {
|
||||||
return this.rootNode.getExtraProp('fileName')?.getAsString() || this.id;
|
return this.rootNode.getExtraProp('fileName')?.getAsString() || this.id;
|
||||||
}
|
}
|
||||||
@ -148,7 +152,7 @@ export class DocumentModel {
|
|||||||
* 根据 id 获取节点
|
* 根据 id 获取节点
|
||||||
*/
|
*/
|
||||||
getNode(id: string): Node | null {
|
getNode(id: string): Node | null {
|
||||||
return this.nodesMap.get(id) || null;
|
return this._nodesMap.get(id) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,13 +206,13 @@ export class DocumentModel {
|
|||||||
// todo: this.activeNodes?.push(node);
|
// todo: this.activeNodes?.push(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
const origin = this.nodesMap.get(node.id);
|
const origin = this._nodesMap.get(node.id);
|
||||||
if (origin && origin !== node) {
|
if (origin && origin !== node) {
|
||||||
// almost will not go here, ensure the id is unique
|
// almost will not go here, ensure the id is unique
|
||||||
origin.internalSetWillPurge();
|
origin.internalSetWillPurge();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nodesMap.set(node.id, node);
|
this._nodesMap.set(node.id, node);
|
||||||
this.nodes.add(node);
|
this.nodes.add(node);
|
||||||
|
|
||||||
this.emitter.emit('nodecreate', node);
|
this.emitter.emit('nodecreate', node);
|
||||||
@ -259,7 +263,7 @@ export class DocumentModel {
|
|||||||
if (!this.nodes.has(node)) {
|
if (!this.nodes.has(node)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.nodesMap.delete(node.id);
|
this._nodesMap.delete(node.id);
|
||||||
this.nodes.delete(node);
|
this.nodes.delete(node);
|
||||||
this.selection.remove(node.id);
|
this.selection.remove(node.id);
|
||||||
node.remove();
|
node.remove();
|
||||||
@ -584,7 +588,7 @@ export class DocumentModel {
|
|||||||
const componentsMap: ComponentMap[] = [];
|
const componentsMap: ComponentMap[] = [];
|
||||||
// 组件去重
|
// 组件去重
|
||||||
const map: any = {};
|
const map: any = {};
|
||||||
for (let node of this.nodesMap.values()) {
|
for (let node of this._nodesMap.values()) {
|
||||||
const { componentName } = node || {};
|
const { componentName } = node || {};
|
||||||
if (!map[componentName] && node?.componentMeta?.npm?.package) {
|
if (!map[componentName] && node?.componentMeta?.npm?.package) {
|
||||||
map[componentName] = true;
|
map[componentName] = true;
|
||||||
|
|||||||
@ -27,6 +27,9 @@ editor.set('designer', designer);
|
|||||||
|
|
||||||
const nodeCache: any = {};
|
const nodeCache: any = {};
|
||||||
designer.project.onCurrentDocumentChange((doc) => {
|
designer.project.onCurrentDocumentChange((doc) => {
|
||||||
|
doc.nodesMap.forEach((node) => {
|
||||||
|
nodeCache[node.id] = node;
|
||||||
|
});
|
||||||
doc.onRendererReady(() => {
|
doc.onRendererReady(() => {
|
||||||
bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY);
|
bus.emit(VE_EVENTS.VE_PAGE_PAGE_READY);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user