diff --git a/packages/designer/src/document/node/node.ts b/packages/designer/src/document/node/node.ts index 32fa5fdeb..62cb3bf84 100644 --- a/packages/designer/src/document/node/node.ts +++ b/packages/designer/src/document/node/node.ts @@ -157,7 +157,7 @@ export class Node { return this.componentMeta.icon; } - private isInited = false; + isInited = false; constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) { const { componentName, id, children, props, ...extras } = nodeSchema; @@ -168,9 +168,6 @@ export class Node { children: isDOMText(children) || isJSExpression(children) ? children : '', }); } else { - // 这里 props 被初始化两次,一次 new,一次 import,new 的实例需要给 propsReducer 的钩子去使用, - // import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug, - // 所以在 props 里会对 new / import 做一些区别化的解析 this.props = new Props(this, props, extras); this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children)); this._children.internalInitParent(); diff --git a/packages/designer/src/document/node/props/prop.ts b/packages/designer/src/document/node/props/prop.ts index 448f72f9c..4a654a34a 100644 --- a/packages/designer/src/document/node/props/prop.ts +++ b/packages/designer/src/document/node/props/prop.ts @@ -55,6 +55,12 @@ export class Prop implements IPropParent { if (value !== UNSET) { this.setValue(value); } + this.setupItems(); + } + + // TODO: 先用调用方式触发子 prop 的初始化,后续须重构 + private setupItems() { + return this.items; } /** @@ -247,7 +253,9 @@ export class Prop implements IPropParent { }; } - this.dispose(); + if (this.owner.isInited) { + this.dispose(); + } if (oldValue !== this._value) { editor?.emit('node.innerProp.change', { @@ -302,7 +310,6 @@ export class Prop implements IPropParent { owner.addSlot(this._slotNode); this._slotNode.internalSetSlotFor(this); } - this.dispose(); } /**