mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(user-menu) add Compare Directories (#220)
This commit is contained in:
parent
303213c48b
commit
3273c1abe5
2 changed files with 74 additions and 0 deletions
|
|
@ -20,6 +20,37 @@ module.exports = {
|
|||
CloudCmd,
|
||||
});
|
||||
},
|
||||
'D - Compare directories': async ({DOM}) => {
|
||||
const {
|
||||
CurrentInfo,
|
||||
getFilenames,
|
||||
getCurrentByName,
|
||||
selectFile,
|
||||
} = DOM;
|
||||
|
||||
const {
|
||||
files,
|
||||
filesPassive,
|
||||
panel,
|
||||
panelPassive,
|
||||
} = CurrentInfo;
|
||||
|
||||
const names = getFilenames(files);
|
||||
const namesPassive = getFilenames(filesPassive);
|
||||
|
||||
const selectedNames = compare(names, namesPassive);
|
||||
const selectedNamesPassive = compare(namesPassive, names);
|
||||
|
||||
selectNames(selectedNames, panel, {
|
||||
selectFile,
|
||||
getCurrentByName,
|
||||
});
|
||||
|
||||
selectNames(selectedNamesPassive, panelPassive, {
|
||||
selectFile,
|
||||
getCurrentByName,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
async function createDefaultMenu({path, data, DOM, CloudCmd}) {
|
||||
|
|
@ -40,3 +71,23 @@ async function readDefaultMenu({prefix}) {
|
|||
return data;
|
||||
}
|
||||
|
||||
function selectNames(names, panel, {selectFile, getCurrentByName}) {
|
||||
for (const name of names) {
|
||||
const file = getCurrentByName(name, panel);
|
||||
selectFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
function compare(a, b) {
|
||||
const result = [];
|
||||
|
||||
for (const el of a) {
|
||||
if (b.includes(el))
|
||||
continue;
|
||||
|
||||
result.push(el);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue