mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(user-menu) add default user menu
This commit is contained in:
parent
7b6e767ccb
commit
76184c0251
11 changed files with 325 additions and 272 deletions
42
static/user-menu.js
Normal file
42
static/user-menu.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
'F2 - Rename file': async ({DOM}) => {
|
||||
await DOM.renameCurrent();
|
||||
},
|
||||
|
||||
'C - Create User Menu File': async ({DOM, CloudCmd}) => {
|
||||
const {CurrentInfo} = DOM;
|
||||
|
||||
const {dirPath} = CurrentInfo;
|
||||
const path = `${dirPath}.cloudcmd.menu.js`;
|
||||
const {prefix} = CloudCmd;
|
||||
|
||||
const data = await readDefaultMenu({prefix});
|
||||
await createDefaultMenu({
|
||||
path,
|
||||
data,
|
||||
DOM,
|
||||
CloudCmd,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue