From 40b2af7c5bae4060e56a1e8c13eac252b4e217bf Mon Sep 17 00:00:00 2001 From: "zhili.wzl" Date: Wed, 22 Sep 2021 21:29:35 +0800 Subject: [PATCH] refactor(core): change defaultComponentTree type ITreeNode[] to ITreeNode --- packages/core/src/models/Engine.ts | 1 - packages/core/src/models/Operation.ts | 2 +- packages/core/src/types.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/core/src/models/Engine.ts b/packages/core/src/models/Engine.ts index 2c77cabaf..3d48763e4 100644 --- a/packages/core/src/models/Engine.ts +++ b/packages/core/src/models/Engine.ts @@ -91,7 +91,6 @@ export class Engine extends Event { shortcuts: [], effects: [], drivers: [], - defaultComponentTree: [], rootComponentName: 'Root', sourceIdAttrName: 'data-designer-source-id', nodeIdAttrName: 'data-designer-node-id', diff --git a/packages/core/src/models/Operation.ts b/packages/core/src/models/Operation.ts index 7aecb160b..2eefca5bf 100644 --- a/packages/core/src/models/Operation.ts +++ b/packages/core/src/models/Operation.ts @@ -45,8 +45,8 @@ export class Operation { this.workspace = workspace this.tree = new TreeNode({ componentName: this.engine.props.rootComponentName, + ...this.engine.props.defaultComponentTree, operation: this, - children: this.engine.props.defaultComponentTree, }) this.selection = new Selection({ operation: this, diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index f007b9496..9d078c840 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -20,7 +20,7 @@ export type IEngineProps = IEventProps & { clickStopPropagationAttrName?: string //点击阻止冒泡属性 outlineNodeIdAttrName?: string //大纲树节点ID的dom属性名 nodeHelpersIdAttrName?: string //节点工具栏属性名 - defaultComponentTree?: ITreeNode[] //默认组件树 + defaultComponentTree?: ITreeNode //默认组件树 defaultScreenType?: ScreenType rootComponentName?: string }