mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
docs(user-menu) module.exports -> export default
parent
f0906a3a9d
commit
ac82fd2aa6
1 changed files with 28 additions and 8 deletions
|
|
@ -11,7 +11,7 @@ You can combine them in any way, and also add yours 😉.
|
|||
The simplest way to show rename file dialog.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
export default {
|
||||
'F2 - Rename file': async ({DOM}) => {
|
||||
await DOM.renameCurrent();
|
||||
},
|
||||
|
|
@ -37,11 +37,13 @@ export default {
|
|||
Simple example of running bash scripts with help of `TerminalRun`.
|
||||
|
||||
```js
|
||||
'use strict';
|
||||
|
||||
const isMp3 = (a) => /\.mp3$/.test(a);
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
'F - Convert flac to mp3': async ({DOM, CloudCmd}) => {
|
||||
const {IO, CurrentInfo} = DOM;
|
||||
const {IO, CurrentInfo} = DOM;
|
||||
|
||||
const root = CloudCmd.config('root');
|
||||
const {dirPath, files} = CurrentInfo;
|
||||
|
|
@ -62,12 +64,30 @@ module.exports = {
|
|||
|
||||
const names = DOM.getFilenames(files);
|
||||
const mp3Names = names.filter(isMp3);
|
||||
|
||||
|
||||
await IO.createDirectory(mp3Dir);
|
||||
await IO.move(dirPath, 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;
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -76,7 +96,7 @@ module.exports = {
|
|||
This is how you can create `.cloudcmd.menu.js` file.
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
export default {
|
||||
'C - Create User Menu File': async ({DOM, CloudCmd}) => {
|
||||
const {CurrentInfo} = DOM;
|
||||
|
||||
|
|
@ -116,7 +136,7 @@ async function readDefaultMenu({prefix}) {
|
|||
## Compare Directories
|
||||
|
||||
```js
|
||||
module.exports =
|
||||
export default {
|
||||
'D - Compare directories': async ({DOM}) => {
|
||||
const {
|
||||
CurrentInfo,
|
||||
|
|
@ -174,7 +194,7 @@ function compare(a, b) {
|
|||
## Execute Npm Script
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
export default {
|
||||
'D - Build Dev': async ({CloudCmd}) => {
|
||||
await CloudCmd.TerminalRun.show({
|
||||
command: 'npm run build:client:dev',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue