不允许拖动到另一个脚本上。

This commit is contained in:
tengge1 2020-03-20 21:05:23 +08:00
parent 43bdafca7a
commit 09d0caea64
2 changed files with 11 additions and 2 deletions

View File

@ -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.": "不允许拖动到另一个脚本上。"
}

View File

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