|
1 | | -/* global CloudCmd */ |
2 | | -/* global Util */ |
3 | | -/* global DOM */ |
4 | | -/* global fileop */ |
5 | | - |
6 | | -'use strict'; |
7 | | - |
8 | | -const currify = require('currify'); |
9 | | -const wraptile = require('wraptile'); |
10 | | -const {promisify} = require('es6-promisify'); |
11 | | -const exec = require('execon'); |
12 | | -const load = require('load.js'); |
13 | | -const {tryToCatch} = require('try-to-catch'); |
14 | | - |
15 | | -const {encode} = require('../../../common/entity'); |
16 | | -const removeExtension = require('./remove-extension'); |
17 | | -const setListeners = require('./set-listeners'); |
18 | | -const getNextCurrentName = require('./get-next-current-name'); |
| 1 | +import currify from 'currify'; |
| 2 | +import wraptile from 'wraptile'; |
| 3 | +import {promisify} from 'es6-promisify'; |
| 4 | +import exec from 'execon'; |
| 5 | +import load from 'load.js'; |
| 6 | +import {tryToCatch} from 'try-to-catch'; |
| 7 | +import {encode} from '../../../common/entity.js'; |
| 8 | +import removeExtension from './remove-extension.js'; |
| 9 | +import setListeners from './set-listeners.js'; |
| 10 | +import getNextCurrentName from './get-next-current-name.js'; |
| 11 | + |
| 12 | +const {DOM, CloudCmd} = globalThis; |
19 | 13 |
|
20 | 14 | const removeQuery = (a) => a.replace(/\?.*/, ''); |
21 | 15 |
|
22 | 16 | const Name = 'Operation'; |
23 | 17 |
|
24 | | -CloudCmd[Name] = exports; |
25 | | - |
26 | 18 | const {config} = CloudCmd; |
27 | 19 | const {Dialog, Images} = DOM; |
28 | 20 |
|
@@ -53,7 +45,7 @@ const noFilesCheck = () => { |
53 | 45 | return is; |
54 | 46 | }; |
55 | 47 |
|
56 | | -module.exports.init = promisify((callback) => { |
| 48 | +export const init = promisify((callback) => { |
57 | 49 | showLoad(); |
58 | 50 |
|
59 | 51 | exec.series([ |
@@ -92,7 +84,7 @@ const onConnect = currify((fn, operator) => { |
92 | 84 | async function initOperations(prefix, socketPrefix, fn) { |
93 | 85 | socketPrefix = `${socketPrefix}/fileop`; |
94 | 86 |
|
95 | | - const operator = await fileop({ |
| 87 | + const operator = await globalThis.fileop({ |
96 | 88 | prefix, |
97 | 89 | socketPrefix, |
98 | 90 | }); |
@@ -198,11 +190,11 @@ function getPacker(type) { |
198 | 190 | return packTarFn; |
199 | 191 | } |
200 | 192 |
|
201 | | -module.exports.hide = () => { |
| 193 | +export const hide = () => { |
202 | 194 | CloudCmd.View.hide(); |
203 | 195 | }; |
204 | 196 |
|
205 | | -module.exports.show = (operation, data) => { |
| 197 | +export const show = (operation, data) => { |
206 | 198 | if (!Loaded) |
207 | 199 | return; |
208 | 200 |
|
@@ -411,8 +403,11 @@ async function _processFiles(options, data) { |
411 | 403 | to, |
412 | 404 | names, |
413 | 405 | }; |
| 406 | + debugger; |
414 | 407 |
|
415 | 408 | operation(files, async () => { |
| 409 | + console.log('sssss'); |
| 410 | + debugger; |
416 | 411 | await DOM.Storage.remove(from); |
417 | 412 |
|
418 | 413 | const {panel, panelPassive} = Info; |
@@ -505,8 +500,14 @@ async function prompt(msg, to, names) { |
505 | 500 | return await Dialog.prompt(msg, to); |
506 | 501 | } |
507 | 502 |
|
| 503 | +globalThis.CloudCmd[Name] = { |
| 504 | + init, |
| 505 | + hide, |
| 506 | + show, |
| 507 | +}; |
| 508 | + |
508 | 509 | async function loadAll() { |
509 | | - const {prefix} = CloudCmd; |
| 510 | + const {prefix} = globalThis.CloudCmd; |
510 | 511 | const file = `${prefix}/fileop/fileop.js`; |
511 | 512 |
|
512 | 513 | const [error] = await tryToCatch(load.js, file); |
|
0 commit comments