Skip to content

Commit 7787bfc

Browse files
committed
feature: cloudcmd: user-menu: runFromCDN
1 parent 406429a commit 7787bfc

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

static/user-menu.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const RENAME_FILE = 'Rename file';
2-
const CDN = 'https://cdn.jsdelivr.net/gh/cloudcmd/user-menu@1.2.4';
2+
const CDN = 'https://cdn.jsdelivr.net';
3+
const CDN_GH = `${CDN}/gh/cloudcmd/user-menu@1.2.4`;
34

45
export default {
56
'__settings': {
@@ -10,13 +11,7 @@ export default {
1011
await DOM.renameCurrent();
1112
},
1213

13-
'F6 - Copy URL to current file': async ({DOM}) => {
14-
const {copyURLToCurrentFile} = await import(`${CDN}/menu/copy-url-to-current-file.js`);
15-
16-
await copyURLToCurrentFile({
17-
DOM,
18-
});
19-
},
14+
'F6 - Copy URL to current file': runFromCDN('copy-url-to-current-file'),
2015

2116
'R - cd /': async ({CloudCmd}) => {
2217
await CloudCmd.changeDir('/');
@@ -156,3 +151,18 @@ function compare(a, b) {
156151

157152
return result;
158153
}
154+
155+
const MAP = {
156+
'copy-url-to-current-file': 'copyURLToCurrentFile',
157+
};
158+
159+
function runFromCDN(name) {
160+
return async (...a) => {
161+
const fnName = MAP[name];
162+
const {
163+
[fnName]: fn,
164+
} = await import(`${CDN_GH}/menu/${name}.js`);
165+
166+
await fn(...a);
167+
};
168+
}

0 commit comments

Comments
 (0)