From 88f5677682a1b1f1a4aa57f7ac6b667800ff8227 Mon Sep 17 00:00:00 2001 From: "lihao.ylh" Date: Wed, 1 Sep 2021 16:10:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E9=81=BF=E5=85=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E7=9A=84=20metadataTransducer=20=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=89=A7=E8=A1=8C=E5=AF=BC=E8=87=B4=E4=B8=8D=E5=B9=82?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor-skeleton/src/transducers/addon-combine.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/editor-skeleton/src/transducers/addon-combine.ts b/packages/editor-skeleton/src/transducers/addon-combine.ts index c8fa496a0..fd24f49b1 100644 --- a/packages/editor-skeleton/src/transducers/addon-combine.ts +++ b/packages/editor-skeleton/src/transducers/addon-combine.ts @@ -4,6 +4,11 @@ import { getConvertedExtraKey } from '@ali/lowcode-designer'; export default function (metadata: TransformedComponentMetadata): TransformedComponentMetadata { const { componentName, configure = {} } = metadata; + + // 如果已经处理过,不再重新执行一遍 + if (configure.combined) { + return metadata; + } if (componentName === 'Leaf') { return { ...metadata, From a10641daff328b3f45d46d36efecfde873ee3244 Mon Sep 17 00:00:00 2001 From: "lihao.ylh" Date: Wed, 1 Sep 2021 16:28:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=20actived=20?= =?UTF-8?q?typo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builtin-simulator/bem-tools/drag-resize-engine.ts | 3 +-- packages/designer/src/builtin-simulator/host.ts | 2 +- packages/designer/src/designer/designer.ts | 10 +++++----- packages/designer/src/designer/dragon.ts | 5 ++--- packages/designer/src/document/document-model.ts | 11 +++++++++-- packages/designer/src/project/project.ts | 10 +++++----- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts b/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts index 6d678f2fd..162ada1b7 100644 --- a/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts +++ b/packages/designer/src/builtin-simulator/bem-tools/drag-resize-engine.ts @@ -146,8 +146,7 @@ export default class DragResizeEngine { private getMasterSensors(): ISimulatorHost[] { return this.designer.project.documents .map(doc => { - // TODO: not use actived, - if (doc.actived && doc.simulator?.sensorAvailable) { + if (doc.active && doc.simulator?.sensorAvailable) { return doc.simulator; } return null; diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index 7ce160fa4..713f47247 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -1053,7 +1053,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost focusNode.contains(item)); let target; let index: number | undefined; diff --git a/packages/designer/src/designer/dragon.ts b/packages/designer/src/designer/dragon.ts index 56c2177be..5bf5e20fb 100644 --- a/packages/designer/src/designer/dragon.ts +++ b/packages/designer/src/designer/dragon.ts @@ -195,7 +195,7 @@ export class Dragon { private sensors: ISensor[] = []; /** - * current actived sensor, 可用于感应区高亮 + * current active sensor, 可用于感应区高亮 */ @obx.ref private _activeSensor: ISensor | undefined; @@ -619,8 +619,7 @@ export class Dragon { new Set( this.designer.project.documents .map((doc) => { - // TODO: not use actived, - if (doc.actived && doc.simulator?.sensorAvailable) { + if (doc.active && doc.simulator?.sensorAvailable) { return doc.simulator; } return null; diff --git a/packages/designer/src/document/document-model.ts b/packages/designer/src/document/document-model.ts index ccba5912d..1417a0c58 100644 --- a/packages/designer/src/document/document-model.ts +++ b/packages/designer/src/document/document-model.ts @@ -446,10 +446,17 @@ export class DocumentModel { /** * 与 suspensed 相反,是否为激活状态,这个函数可能用的更多一点 */ - get actived(): boolean { + get active(): boolean { return !this._suspensed; } + /** + * @deprecated 兼容 + */ + get actived(): boolean { + return this.active; + } + /** * 是否打开 */ @@ -476,7 +483,7 @@ export class DocumentModel { this.setSuspense(true); } - active() { + activate() { this.setSuspense(false); } diff --git a/packages/designer/src/project/project.ts b/packages/designer/src/project/project.ts index 5a12b7e14..bce7876b4 100644 --- a/packages/designer/src/project/project.ts +++ b/packages/designer/src/project/project.ts @@ -28,7 +28,7 @@ export class Project { } @computed get currentDocument() { - return this.documents.find((doc) => doc.actived); + return this.documents.find((doc) => doc.active); } @obx private _config: any = {}; @@ -67,7 +67,7 @@ export class Project { */ setSchema(schema?: ProjectSchema) { // FIXME: 这里的行为和 getSchema 并不对等,感觉不太对 - const doc = this.documents.find((doc) => doc.actived); + const doc = this.documents.find((doc) => doc.active); doc && doc.import(schema?.componentsTree[0]); } @@ -231,13 +231,13 @@ export class Project { return doc.open(); } - checkExclusive(actived: DocumentModel) { + checkExclusive(activeDoc: DocumentModel) { this.documents.forEach((doc) => { - if (doc !== actived) { + if (doc !== activeDoc) { doc.suspense(); } }); - this.emitter.emit('current-document.change', actived); + this.emitter.emit('current-document.change', activeDoc); } closeOthers(opened: DocumentModel) { From 3f2cd667d0fea6c741fbdc449d512650350e20ae Mon Sep 17 00:00:00 2001 From: "lihao.ylh" Date: Wed, 1 Sep 2021 21:10:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20prop=20=E7=9A=84=E5=AD=90?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E4=B8=8D=E5=86=8D=E5=BB=B6=E8=BF=9F=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96,=20=E4=B9=9F=E4=B8=8D=E5=86=8D=20node=20?= =?UTF-8?q?=E6=9C=AA=E5=88=9D=E5=A7=8B=E5=8C=96=E5=AE=8C=E6=88=90=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E5=B0=B1=E8=B0=83=E7=94=A8=20dispose=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/designer/src/document/node/node.ts | 5 +---- packages/designer/src/document/node/props/prop.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) 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(); } /**