From 09d0caea64e996f682b296ea5df8b5ad61647ebd Mon Sep 17 00:00:00 2001 From: tengge1 <930372551@qq.com> Date: Fri, 20 Mar 2020 21:05:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=85=81=E8=AE=B8=E6=8B=96=E5=8A=A8?= =?UTF-8?q?=E5=88=B0=E5=8F=A6=E4=B8=80=E4=B8=AA=E8=84=9A=E6=9C=AC=E4=B8=8A?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ShadowEditor.Web/locales/zh-CN.json | 3 ++- ShadowEditor.Web/src/editor/sidebar/ScriptPanel.jsx | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ShadowEditor.Web/locales/zh-CN.json b/ShadowEditor.Web/locales/zh-CN.json index ac38dcdf..b9ef8ef1 100644 --- a/ShadowEditor.Web/locales/zh-CN.json +++ b/ShadowEditor.Web/locales/zh-CN.json @@ -1020,5 +1020,6 @@ "Folder Name": "文件夹名称", "New folder": "新文件夹", "Create Folder": "新建文件夹", - "Input New Name": "输入新名称" + "Input New Name": "输入新名称", + "It is not allowed to drop on another script.": "不允许拖动到另一个脚本上。" } \ No newline at end of file diff --git a/ShadowEditor.Web/src/editor/sidebar/ScriptPanel.jsx b/ShadowEditor.Web/src/editor/sidebar/ScriptPanel.jsx index 747396fc..2b467a53 100644 --- a/ShadowEditor.Web/src/editor/sidebar/ScriptPanel.jsx +++ b/ShadowEditor.Web/src/editor/sidebar/ScriptPanel.jsx @@ -271,13 +271,21 @@ class ScriptPanel extends React.Component { handleDrop(current, newParent, newIndex) { let scripts = this.state.scripts; + if (newParent) { + let parent = scripts[newParent]; + if (parent.type !== 'folder') { + app.toast(_t('It is not allowed to drop on another script.')); + return; + } + } + let currentScript = scripts[current]; currentScript.pid = newParent; // 排序 scripts = Object.values(scripts); - if(!newParent) { + if (!newParent) { scripts = scripts.filter(n => !n.pid && n !== currentScript); } else { scripts = scripts.filter(n => n.pid === newParent && n !== currentScript);