diff --git a/src/UI/Components/ToolBar/Layer/LayerManager.tsx b/src/UI/Components/ToolBar/Layer/LayerManager.tsx index b96bfa612..7c88cc967 100644 --- a/src/UI/Components/ToolBar/Layer/LayerManager.tsx +++ b/src/UI/Components/ToolBar/Layer/LayerManager.tsx @@ -151,25 +151,28 @@ export class LayerManager extends React.Component<{}, {}> SelectLayerEntitys(selected); }} /> - - { - this.ClickInnerEvent(e); - const ens = app.Editor.SelectCtrl.SelectSet.SelectEntityList; - if (ens.length > 0) - LayerCMD.PutEntitysInLayer(ens, selected); - else + { + !selected.children && + { - AppToaster.show({ - message: "请先选中实体", - timeout: 2000, - intent: Intent.DANGER - }, 'openfile'); - } - }} - /> + this.ClickInnerEvent(e); + const ens = app.Editor.SelectCtrl.SelectSet.SelectEntityList; + if (ens.length > 0) + LayerCMD.PutEntitysInLayer(ens, selected); + else + { + AppToaster.show({ + message: "请先选中实体", + timeout: 2000, + intent: Intent.DANGER + }, 'openfile'); + } + }} + /> + } , { left: e.clientX, top: e.clientY }, () => this.setState({ isContextMenuOpen: false }), @@ -219,9 +222,13 @@ export class LayerManager extends React.Component<{}, {}> const line = dom.children[0] as HTMLDivElement; const key = dom.getAttribute("data-key"); const node = TreeAction.FindNode(layerStore.data, (node: ILayerNode) => node.name === key); + const isInSelf = data.name === key; + // 拖拽到文件夹里 if (e.clientY > rect.top && e.clientY < rect.bottom && node.children) { - if (!data.children || !TreeAction.FindNode(data.children, (node: ILayerNode) => node.name === key)) + const isInChildren = data.children && TreeAction.FindNode(node.children, (node: ILayerNode) => node.name === key); + // 确保不拖拽到自身及其子文件里 + if (!isInSelf && !isInChildren) { const div = dom.children[1] as HTMLDivElement; div.style.background = "rgba(150, 180, 210, 0.5)"; @@ -230,11 +237,17 @@ export class LayerManager extends React.Component<{}, {}> return; } } + // 拖拽到文件上方 if (e.clientY < boundary) { - line.style.height = "5px"; - this._ToWhere = key; - return; + const isInChildren = data.children && TreeAction.FindNode(data.children, (node: ILayerNode) => node.name === key); + // 确保不拖拽到自身及其子文件里 + if (!isInSelf && !isInChildren) + { + line.style.height = "5px"; + this._ToWhere = key; + return; + } } } this._ToWhere = "--LAST"; @@ -383,7 +396,7 @@ export class LayerManager extends React.Component<{}, {}> } - {data.expanded && data.children && this.CreateList(data.children)} + {data.expanded && data.children && data.children.length > 0 && this.CreateList(data.children)} ); }) );