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);