feature: cloudcmd: user-menu: runFromCDN

This commit is contained in:
coderiaser 2026-04-04 17:04:55 +03:00
parent 406429aec8
commit 7787bfc22e

View file

@ -1,5 +1,6 @@
const RENAME_FILE = 'Rename file'; const RENAME_FILE = 'Rename file';
const CDN = 'https://cdn.jsdelivr.net/gh/cloudcmd/user-menu@1.2.4'; const CDN = 'https://cdn.jsdelivr.net';
const CDN_GH = `${CDN}/gh/cloudcmd/user-menu@1.2.4`;
export default { export default {
'__settings': { '__settings': {
@ -10,13 +11,7 @@ export default {
await DOM.renameCurrent(); await DOM.renameCurrent();
}, },
'F6 - Copy URL to current file': async ({DOM}) => { 'F6 - Copy URL to current file': runFromCDN('copy-url-to-current-file'),
const {copyURLToCurrentFile} = await import(`${CDN}/menu/copy-url-to-current-file.js`);
await copyURLToCurrentFile({
DOM,
});
},
'R - cd /': async ({CloudCmd}) => { 'R - cd /': async ({CloudCmd}) => {
await CloudCmd.changeDir('/'); await CloudCmd.changeDir('/');
@ -156,3 +151,18 @@ function compare(a, b) {
return result; return result;
} }
const MAP = {
'copy-url-to-current-file': 'copyURLToCurrentFile',
};
function runFromCDN(name) {
return async (...a) => {
const fnName = MAP[name];
const {
[fnName]: fn,
} = await import(`${CDN_GH}/menu/${name}.js`);
await fn(...a);
};
}