mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(user-menu) add default option: create user menu
This commit is contained in:
parent
5fb5652f3d
commit
9ff5982a5b
3 changed files with 42 additions and 5 deletions
38
client/modules/user-menu/default-menu.js
Normal file
38
client/modules/user-menu/default-menu.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
const data = `'use strict';
|
||||
|
||||
module.exports = {
|
||||
'F2 - Rename file': async ({DOM}) => {
|
||||
await DOM.renameCurrent();
|
||||
},
|
||||
};
|
||||
`;
|
||||
|
||||
module.exports = {
|
||||
'F2 - Rename file': async ({DOM}) => {
|
||||
await DOM.renameCurrent();
|
||||
},
|
||||
|
||||
'C - Create User Menu File': async ({DOM, CloudCmd, tryToPromisify}) => {
|
||||
const {
|
||||
Dialog,
|
||||
RESTful,
|
||||
CurrentInfo,
|
||||
} = DOM;
|
||||
|
||||
const {dirPath} = CurrentInfo;
|
||||
const path = `${dirPath}/.cloudcmd.menu.js`;
|
||||
|
||||
const [e] = await tryToPromisify(RESTful.write, path, data);
|
||||
|
||||
if (e)
|
||||
return Dialog.alert(e);
|
||||
|
||||
await tryToPromisify(CloudCmd.refresh);
|
||||
DOM.setCurrentByName('.cloudcmd.menu.js');
|
||||
|
||||
await CloudCmd.EditFile.show();
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -1,10 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const defaultUserMenu = {
|
||||
'F2 - Rename file': async ({DOM}) => {
|
||||
DOM.renameCurrent();
|
||||
},
|
||||
};
|
||||
const defaultUserMenu = require('./default-menu.js');
|
||||
|
||||
module.exports = (menuFn) => {
|
||||
if (!menuFn)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ const createElement = require('@cloudcmd/create-element');
|
|||
const tryCatch = require('try-catch');
|
||||
const tryToCatch = require('try-to-catch/legacy');
|
||||
|
||||
const tryToPromisify = require('../../../common/try-to-promisify.js');
|
||||
|
||||
const Images = require('../../dom/images');
|
||||
const Dialog = require('../../dom/dialog');
|
||||
const getUserMenu = require('./get-user-menu');
|
||||
|
|
@ -122,6 +124,7 @@ const runUserMenu = async (value, options, userMenu) => {
|
|||
const [e] = await tryToCatch(userMenu[value], {
|
||||
DOM,
|
||||
CloudCmd,
|
||||
tryToPromisify,
|
||||
});
|
||||
|
||||
if (e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue