mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 02:29:23 +00:00
docs(user-menu-cookbook) files -> CurrentInfo.files
parent
7ca319d694
commit
6d7181fe2b
1 changed files with 5 additions and 27 deletions
|
|
@ -37,8 +37,6 @@ export default {
|
|||
Simple example of running bash scripts with help of `TerminalRun`.
|
||||
|
||||
```js
|
||||
'use strict';
|
||||
|
||||
const isMp3 = (a) => /\.mp3$/.test(a);
|
||||
|
||||
export default {
|
||||
|
|
@ -46,8 +44,7 @@ export default {
|
|||
const {IO, CurrentInfo} = DOM;
|
||||
|
||||
const root = CloudCmd.config('root');
|
||||
const {dirPath, files} = CurrentInfo;
|
||||
const cwd = `${root}${dirPath}`;
|
||||
const cwd = `${root}${CurrentInfo.dirPath}`;
|
||||
|
||||
const convert = 'for f in *.flac; do ffmpeg -vsync 2 -i "$f" -b:a 320k "${f%flac}mp3"; done';
|
||||
const exitCode = await CloudCmd.TerminalRun.show({
|
||||
|
|
@ -58,37 +55,18 @@ export default {
|
|||
if (exitCode)
|
||||
return;
|
||||
|
||||
await IO.createDirectory('/mp3');
|
||||
await CloudCmd.refresh();
|
||||
|
||||
const mp3Dir = `${cwd}mp3`;
|
||||
|
||||
const names = DOM.getFilenames(files);
|
||||
const names = DOM.getFilenames(CurrentInfo.files);
|
||||
const mp3Names = names.filter(isMp3);
|
||||
|
||||
await IO.createDirectory(mp3Dir);
|
||||
await IO.move(dirPath, mp3Dir, mp3Names);
|
||||
const mp3Dir = `${cwd}/mp3`;
|
||||
await IO.move(cwd, mp3Dir, mp3Names);
|
||||
|
||||
await CloudCmd.refresh();
|
||||
},
|
||||
};
|
||||
|
||||
async function createDefaultMenu({path, data, DOM, CloudCmd}) {
|
||||
const {IO} = DOM;
|
||||
|
||||
await IO.write(path, data);
|
||||
await CloudCmd.refresh();
|
||||
|
||||
DOM.setCurrentByName('.cloudcmd.menu.js');
|
||||
|
||||
await CloudCmd.EditFile.show();
|
||||
}
|
||||
|
||||
async function readDefaultMenu({prefix}) {
|
||||
const res = await fetch(`${prefix}/api/v1/user-menu/default`);
|
||||
const data = await res.text();
|
||||
|
||||
return data;
|
||||
}
|
||||
```
|
||||
|
||||
## Create User Menu File
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue