PageSourceSearch

https://www.lingyuzhao.top/js/diskMirror.js

js lingyuzhao.top collected 2026-10-06 13:17:57 UTC 30,746 bytes, 766 lines download raw bytes

1/**
2 * 盘镜 JS 脚本类 您可以通过此脚本来实现盘镜相关的操作调用
3 * TODO 此脚本需要先引入依赖 axios
4 */
5class DiskMirror {
6
7    /**
8     * 获取到盘镜对象
9     * @param url {string} 盘镜后端服务器后端的url
10     */
11    constructor(url) {
12        // constructor body
13        this.diskMirrorUrl = url; // This is the diskMirrorUrl variable
14        this.setSk();
15        this.setController('/FsCrud');
16    }
17
18    /**
19     * 通过异或算法加密
20     * @param value {number} 要加密的字符串
21     * @return {number} 加密后的结果
22     */
23    xorEncrypt(value) {
24        let encrypted = value;
25        const sk_str = this.sk.toString();
26        for (let i = 0; i < sk_str.length; i++) {
27            encrypted -= sk_str.charCodeAt(i) << 1;
28        }
29        return encrypted;
30    }
31
32    /**
33     * 设置本组件要使用的盘镜控制器
34     * @param controllerName 盘镜控制器名称
35     */
36    setController(controllerName) {
37        this.controller = controllerName;
38    }
39
40    /**
41     *
42     * @return {string} 本组件的盘镜控制器名称
43     */
44    getController() {
45        return this.controller;
46    }
47
48    /**
49     * 设置本组件使用的盘镜的 安全key
50     * @param key {int} 此key 用于标识您的身份,让服务器相信您,且允许您访问,需要设置与服务器相同
51     * @param domain {string} 您希望在哪个域下使用此安全密钥?默认情况下,此值是 undefined,表示您希望在当前域下使用此安全密钥,值得注意是,请确保您的盘镜后端服务器在此域下哦!因为您要携带这个cookie 访问后端呢!
52     */
53    setSk(key = 0, domain = undefined) {
54        this.sk = key;
55        if (key !== 0) {
56            this.setDiskMirrorXorSecureKey(domain);
57        }
58    }
59
60    /**
61     * 获取本组件使用的盘镜的 安全key
62     * @return {int} 安全密钥 如果目标 diskMirror 服务器需要密钥访问,则您需要在这里设置密钥
63     */
64    getSk() {
65        return this.sk;
66    }
67
68    /**
69     * 向后端中上传一个文件
70     * @param params {{
71     *      fileName: string,
72     *      userId: int,
73     *      type: 'Binary'|'TEXT'
74     * }} 这里是请求参数对象 其中的文件名字代表上传到后端之后的文件名字,userId 代表的就是文件要上传到的指定空间的id;type就是代表的文件的类型 支持二进制和文本两种格式
75     * @param file {File} 需要被上传的文件对象
76     * @param okFun {function} 操作成功之后的回调函数 输入是被上传文件的json对象
77     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
78     * @param checkFun {function} 上传前的检查函数 输入是上传的文件对象的 json 数据 以及 文件对象本身,如果返回的是一个false 则代表不进行上传操作
79     */
80    upload(params, file, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) {
81        if (checkFun !== undefined && !checkFun(params, file)) {
82            return;
83        }
84        const formData = new FormData();
85        // 设置请求参数数据包
86        params["secure.key"] = this.getSk();
87        const blob = new Blob([JSON.stringify(params)], {
88            type: 'application/json'
89        });
90        formData.append('params', blob, "params");
91        // 设置文件数据包
92        formData.append('file', file, "file");
93        // 开始进行请求发送
94        axios.defaults.withCredentials = true;
95        axios(
96            {
97                method: 'post',
98                url: this.diskMirrorUrl + this.getController() + '/add',
99                data: formData,
100                headers: {
101                    'Content-Type': 'multipart/form-data'
102                }
103            }
104        ).then(function (res) {
105            if (res.data['res'] !== 'ok!!!!') {
106                if (errorFun !== undefined) {
107                    errorFun(res.data);
108                }
109                return;
110            }
111            // 处理成功
112            if (okFun !== undefined) {
113                okFun(res.data);
114            } else {
115                console.info(res.data);
116            }
117        }).catch(function (err) {
118            // 处理错误
119            if (errorFun !== undefined) {
120                errorFun(err);
121            } else {
122                console.error(err);
123            }
124        });
125    }
126
127    /**
128     * 获取到指定空间的所有 文本文件的 url
129     * @param userId {int} 需要被读取的空间id
130     * @param type {'TEXT'|'Binary'} 文件类型
131     * @param okFun {function} 操作成功之后的回调函数 输入是被获取额结果文件的json对象
132     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
133     * @param checkFun {function} 获取前的检查函数 输入是请求参数对象,如果返回的是一个false 则代表不进行获取操作
134     */
135    getUrls(userId, type, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined,) {
136        // getUrls function body
137        if (userId === undefined || type === undefined || type === '') {
138            const err = "您必须要输入 userId 以及 type 参数才可以进行 url 的获取";
139            if (errorFun !== undefined) {
140                errorFun(err);
141            } else {
142                console.error(err);
143            }
144            return;
145        }
146        const formData = new FormData();
147        // 设置请求参数
148        const params = {
149            userId: userId,
150            type: type,
151            "secure.key": this.getSk()
152        };
153        if (checkFun !== undefined && !checkFun(params)) {
154            return;
155        }
156        const blob = new Blob([JSON.stringify(params)], {
157            type: 'application/json'
158        });
159        formData.append('params', blob, "params");
160        // 开始进行请求发送
161        axios.defaults.withCredentials = true;
162        axios(
163            {
164                method: 'post',
165                url: this.diskMirrorUrl + this.getController() + '/getUrls',
166                data: formData,
167                headers: {
168                    'Content-Type': 'multipart/form-data'
169                }
170            }
171        ).then(function (res) {
172            if (res.data['res'] !== 'ok!!!!') {
173                if (errorFun !== undefined) {
174                    errorFun(res.data);
175                }
176                return;
177            }
178            if (okFun !== undefined) {
179                okFun(res.data);
180            } else {
181                console.info(res.data);
182            }
183        }).catch(function (err) {
184            if (errorFun !== undefined) {
185                errorFun(err);
186            } else {
187                console.error(err);
188            }
189        });
190    }
191
192    /**
193     * 删除指定空间的指定文件
194     * @param userId {int} 空间id
195     * @param type {'TEXT'|'Binary'} 文件类型
196     * @param fileName {string} 需要被删除的文件名称
197     * @param okFun {function} 操作成功之后的回调函数 输入是被删除的文件的json对象
198     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
199     * @param checkFun {function} 删除前的检查函数 输入是请求参数对象,如果返回的是一个false 则代表不进行删除操作
200     */
201    remove(userId, type, fileName, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined,) {
202        if (userId === undefined || type == null || type === '' || fileName === undefined || fileName === '') {
203            const err = "您必须要输入 userId 以及 type 和 fileName 参数才可以进行删除";
204            if (errorFun !== undefined) {
205                errorFun(err);
206            } else {
207                console.error(err);
208            }
209            return
210        }
211        const formData = new FormData();
212        // 设置请求参数
213        const params = {
214            fileName: fileName,
215            userId: userId,
216            type: type,
217            "secure.key": this.getSk()
218        };
219        if (checkFun !== undefined && !checkFun(params)) {
220            return;
221        }
222        const blob = new Blob([JSON.stringify(params)], {
223            type: 'application/json'
224        });
225        formData.append('params', blob, "params");
226        // 开始进行请求发送
227        axios.defaults.withCredentials = true;
228        axios(
229            {
230                method: 'post',
231                url: this.diskMirrorUrl + this.getController() + '/remove',
232                data: formData,
233                headers: {
234                    'Content-Type': 'multipart/form-data'
235                }
236            }
237        ).then(function (res) {
238            if (res.data['res'] !== 'ok!!!!') {
239                if (errorFun !== undefined) {
240                    errorFun(res.data);
241                }
242                return;
243            }
244            if (okFun !== undefined) {
245                okFun(res.data);
246            } else {
247                console.info(res.data);
248            }
249        }).catch(function (err) {
250            if (errorFun !== undefined) {
251                errorFun(err);
252            } else {
253                console.error(err);
254            }
255        });
256    }
257
258    /**
259     * 针对指定空间的指定文件进行重命名
260     * @param userId {int} 空间id
261     * @param type {'TEXT'|'Binary'} 文件类型
262     * @param fileName {string} 需要被变更的文件名称
263     * @param newName {string} 变更之后的文件名称
264     * @param okFun {function} 操作成功之后的回调函数 输入是被删除的文件的json对象
265     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
266     * @param checkFun {function} 操作前的检查函数 输入是请求参数对象,如果返回的是一个false 则代表检查失败不继续操作
267     */
268    reName(userId, type, fileName, newName, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) {
269        if (userId === undefined || type == null || type === '' || fileName === undefined || fileName === '' || newName === undefined || newName === '') {
270            const err = "您必须要输入 userId 和 type 以及 fileName 和 newName 参数才可以进行重命名";
271            if (errorFun !== undefined) {
272                errorFun(err);
273            } else {
274                console.error(err);
275            }
276            return
277        }
278        const formData = new FormData();
279        // 设置请求参数
280        const params = {
281            fileName: fileName,
282            newName: newName,
283            userId: userId,
284            type: type,
285            "secure.key": this.getSk()
286        };
287        if (checkFun !== undefined && !checkFun(params)) {
288            return;
289        }
290        const blob = new Blob([JSON.stringify(params)], {
291            type: 'application/json'
292        });
293        formData.append('params', blob, "params");
294        // 开始进行请求发送
295        axios.defaults.withCredentials = true;
296        axios(
297            {
298                method: 'post',
299                url: this.diskMirrorUrl + this.getController() + '/reName',
300                data: formData,
301                headers: {
302                    'Content-Type': 'multipart/form-data'
303                }
304            }
305        ).then(function (res) {
306            if (res.data['res'] !== 'ok!!!!') {
307                if (errorFun !== undefined) {
308                    errorFun(res.data);
309                }
310                return;
311            }
312            if (okFun !== undefined) {
313                okFun(res.data);
314            } else {
315                console.info(res.data);
316            }
317        }).catch(function (err) {
318            if (errorFun !== undefined) {
319                errorFun(err);
320            } else {
321                console.error(err);
322            }
323        });
324    }
325
326    /**
327     * 针对指定空间的指定文件目录进行创建
328     * @param userId {int} 空间id
329     * @param type {'TEXT'|'Binary'} 文件类型
330     * @param fileName {string} 需要被创建的文件目录名称
331     * @param okFun {function} 操作成功之后的回调函数 输入是被创建的文件目录的json对象
332     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
333     * @param checkFun {function} 操作前的检查函数 输入是请求参数对象,如果返回的是一个false 则代表检查失败不继续操作
334     */
335    mkdirs(userId, type, fileName, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) {
336        if (userId === undefined || type == null || type === '' || fileName === undefined || fileName === '') {
337            const err = "您必须要输入 userId 和 type 以及 fileName 参数才可以进行文件目录的创建";
338            if (errorFun !== undefined) {
339                errorFun(err);
340            } else {
341                console.error(err);
342            }
343            return
344        }
345        const formData = new FormData();
346        // 设置请求参数
347        const params = {
348            fileName: fileName,
349            userId: userId,
350            type: type,
351            "secure.key": this.getSk()
352        };
353        if (checkFun !== undefined && !checkFun(params)) {
354            return;
355        }
356        const blob = new Blob([JSON.stringify(params)], {
357            type: 'application/json'
358        });
359        formData.append('params', blob, "params");
360        // 开始进行请求发送
361        axios.defaults.withCredentials = true;
362        axios(
363            {
364                method: 'post',
365                url: this.diskMirrorUrl + this.getController() + '/mkdirs',
366                data: formData,
367                headers: {
368                    'Content-Type': 'multipart/form-data'
369                }
370            }
371        ).then(function (res) {
372            if (res.data['res'] !== 'ok!!!!') {
373                if (errorFun !== undefined) {
374                    errorFun(res.data);
375                }
376                return;
377            }
378            if (okFun !== undefined) {
379                okFun(res.data);
380            } else {
381                console.info(res.data);
382            }
383        }).catch(function (err) {
384            if (errorFun !== undefined) {
385                errorFun(err);
386            } else {
387                console.error(err);
388            }
389        });
390    }
391
392    /**
393     * 将指定的文件的对象获取到,并传递给您自己提供的函数中!
394     * @param userId {int} 空间id
395     * @param type {'TEXT'|'Binary'} 文件类型
396     * @param fileName {string} 需要被获取的文件目录名称
397     * @param okFun {function} 操作成功之后的回调函数 输入是获取的文件的 url 地址!
398     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息的错误码
399     * @param checkFun {function} 操作前的检查函数 输入是请求参数对象,如果返回的是一个false 则代表检查失败不继续操作
400     * @param version {int} 要使用第几代的控制器下载文件 默认是第一代 兼容性最好
401     */
402    downLoad(userId, type, fileName, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined, version = 1) {
403        if (userId === undefined || type == null || type === '' || fileName === undefined || fileName === '' || okFun === undefined) {
404            const err = "您必须要输入 userId 和 type 以及 fileName 和 okFun 参数才可以进行文件对象的获取!";
405            if (errorFun !== undefined) {
406                errorFun(err);
407            } else {
408                console.error(err);
409            }
410            return
411        }
412        if (checkFun !== undefined && !checkFun({
413            userId: userId,
414            type: type,
415            fileName: fileName
416        })) {
417            return;
418        }
419        // 判断是否有名为 diskMirror_xor_secure_key 的 cookie 如果没有就直接追加一个 cookie 的名字是 diskMirror_xor_secure_key 内容是 ${this.xorEncrypt(this.sk.toString())}
420        // 开始计算 url
421        okFun(version < 2 ? this.diskMirrorUrl + this.getController() + `/downLoad/${userId}/${type}?fileName=${fileName}` : this.diskMirrorUrl + this.getController() + `/downLoad2/${userId}/${type}/${this.getSk()}/${fileName.startsWith('/') ? fileName.substring(1) : fileName}`);
422    }
423
424    /**
425     * 向后端中转存一个文件
426     * @param params {{
427     *      fileName: string,
428     *      userId: int,
429     *      type: 'Binary'|'TEXT',
430     *      url: string
431     * }} 这里是请求参数对象 其中的文件名字代表上传到后端之后的文件名字,userId 代表的就是文件要上传到的指定空间的id;type就是代表的文件的类型 支持二进制和文本两种格式
432     * @param okFun {function} 操作成功之后的回调函数 输入是被上传文件的json对象
433     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
434     * @param checkFun {function} 上传前的检查函数 输入是上传的文件对象的 json 数据 ,如果返回的是一个false 则代表不进行上传操作
435     */
436    transferDeposit(params, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) {
437        if (checkFun !== undefined && !checkFun(params)) {
438            return;
439        }
440        const formData = new FormData();
441        // 设置请求参数数据包
442        params["secure.key"] = this.getSk();
443        const blob = new Blob([JSON.stringify(params)], {
444            type: 'application/json'
445        });
446        formData.append('params', blob, "params");
447        // 开始进行请求发送
448        axios.defaults.withCredentials = true;
449        axios(
450            {
451                method: 'post',
452                url: this.diskMirrorUrl + this.getController() + '/transferDeposit',
453                data: formData,
454                headers: {
455                    'Content-Type': 'multipart/form-data'
456                }
457            }
458        ).then(function (res) {
459            if (res.data['res'] !== 'ok!!!!') {
460                if (errorFun !== undefined) {
461                    errorFun(res.data);
462                }
463                return;
464            }
465            // 处理成功
466            if (okFun !== undefined) {
467                okFun(res.data);
468            } else {
469                console.info(res.data);
470            }
471        }).catch(function (err) {
472            // 处理错误
473            if (errorFun !== undefined) {
474                errorFun(err);
475            } else {
476                console.error(err);
477            }
478        });
479    }
480
481    /**
482     * 向后端中查询文件转存情况
483     * @param params {{
484     *      userId: int,
485     *      type: 'Binary'|'TEXT',
486     * }} 这里是请求参数对象 其中的文件名字代表上传到后端之后的文件名字,userId 代表的就是文件要上传到的指定空间的id;type就是代表的文件的类型 支持二进制和文本两种格式
487     * @param okFun {function} 操作成功之后的回调函数 输入是被上传文件的json对象
488     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
489     * @param checkFun {function} 上传前的检查函数 输入是上传的文件对象的 json 数据 以及 文件对象本身,如果返回的是一个false 则代表不进行上传操作
490     */
491    transferDepositStatus(params, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) {
492        if (checkFun !== undefined && !checkFun(params)) {
493            return;
494        }
495        const formData = new FormData();
496        // 设置请求参数数据包
497        params["secure.key"] = this.getSk();
498        const blob = new Blob([JSON.stringify(params)], {
499            type: 'application/json'
500        });
501        formData.append('params', blob, "params");        // 开始进行请求发送
502        axios.defaults.withCredentials = true;
503        axios(
504            {
505                method: 'post',
506                url: this.diskMirrorUrl + this.getController() + '/transferDepositStatus',
507                data: formData,
508                headers: {
509                    'Content-Type': 'multipart/form-data'
510                }
511            }
512        ).then(function (res) {
513            // 处理成功
514            if (okFun !== undefined) {
515                okFun(res.data);
516            } else {
517                console.info(res.data);
518            }
519        }).catch(function (err) {
520            // 处理错误
521            if (errorFun !== undefined) {
522                errorFun(err);
523            } else {
524                console.error(err);
525            }
526        });
527    }
528
529    /**
530     * 获取指定空间的最大容量 单位是 字节
531     *
532     * 需要确保远程的 diskMirror 服务器是在 2024年 2 月 17 日 以及之后发布的!!
533     *
534     * @param userId {int} 需要被检索的空间id
535     * @param okFun {function} 操作成功之后的回调函数 输入是被创建的文件目录的json对象
536     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
537     */
538    getSpaceMaxSize(userId, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) {
539        // 开始进行请求发送
540        axios.defaults.withCredentials = true;
541        axios(
542            {
543                method: 'post',
544                url: this.diskMirrorUrl + this.getController() + '/getSpaceSize',
545                params: {
546                    spaceId: userId.toString()
547                }
548            }
549        ).then(function (res) {
550            const data = res.data;
551            if (isNaN(data['res'])) {
552                if (errorFun !== undefined) {
553                    errorFun(data['res'] + " is NAN!!!");
554                }
555                return;
556            }
557            if (okFun !== undefined) {
558                okFun(data['res']);
559            } else {
560                console.info(data['res']);
561            }
562        }).catch(function (err) {
563            if (errorFun !== undefined) {
564                errorFun(err);
565            } else {
566                console.error(err);
567            }
568        });
569    }
570
571    /**
572     * 获取后端中的盘镜内核的版本
573     *
574     * 需要确保远程的 diskMirror 服务器是在 2024年 2 月 17 日 以及之后发布的!!
575     *
576     * @param okFun {function} 操作成功之后的回调函数 输入是被创建的文件目录的json对象
577     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
578     */
579    getVersion(okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) {
580        // 开始进行请求发送
581        axios.defaults.withCredentials = true;
582        axios(
583            {
584                method: 'post',
585                url: this.diskMirrorUrl + this.getController() + '/getVersion',
586            }
587        ).then(function (res) {
588            if (okFun !== undefined) {
589                okFun(res.data);
590            } else {
591                console.info(res.data);
592            }
593        }).catch(function (err) {
594            if (errorFun !== undefined) {
595                errorFun(err);
596            } else {
597                console.error(err);
598            }
599        });
600    }
601
602    /**
603     * 获取指定空间的已使用容量 单位是 字节
604     * @param userId {int} 需要被检索的空间id
605     * @param type {'Binary'|'TEXT'} 需要被检索的文件类型
606     * @param okFun {function} 操作成功之后的回调函数 输入是计算出来的已使用容量
607     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
608     */
609    getUseSize(userId, type, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) {
610        if (userId === undefined || type == null || type === '') {
611            const err = "您必须要输入 userId 和 type 参数才可以进行使用数量的获取";
612            if (errorFun !== undefined) {
613                errorFun(err);
614            } else {
615                console.error(err);
616            }
617            return;
618        }
619        const formData = new FormData();
620        // 设置请求参数
621        const params = {
622            userId: userId,
623            type: type,
624            "secure.key": this.getSk()
625        };
626        const blob = new Blob([JSON.stringify(params)], {
627            type: 'application/json'
628        });
629        formData.append('params', blob, "params");
630
631        // 开始进行请求发送
632        axios.defaults.withCredentials = true;
633        axios(
634            {
635                method: 'post',
636                url: this.diskMirrorUrl + this.getController() + '/getUseSize',
637                data: formData,
638                headers: {
639                    'Content-Type': 'multipart/form-data'
640                }
641            }
642        ).then(function (res) {
643            if (okFun !== undefined) {
644                okFun(res.data);
645            } else {
646                console.info(res.data);
647            }
648        }).catch(function (err) {
649            if (errorFun !== undefined) {
650                errorFun(err);
651            } else {
652                console.error(err);
653            }
654        });
655    }
656
657    /**
658     * 在一些操作中,我们可能需要将 sk 包含在 cookie 中,因此可能会需要使用这个函数,这个函数一般来说不需要用户手动调用!
659     *
660     * 因为在设置好 sk 的时候,它会自动被调用!请勿随意修改此函数带来的cookie,某些后端服务会使用到!
661     *
662     * @param domain {string} 需要被设置的cookie的域名 默认是当前域
663     */
664    setDiskMirrorXorSecureKey(domain) {
665        // 检查名为 diskMirror_xor_secure_key 的 cookie 是否存在
666        const cookieName = 'diskMirror_xor_secure_key';
667        // 如果存在就更新 cookie 的值
668        const encryptedValue = this.xorEncrypt(this.getSk());
669        if (this.isSetCookie && this.cookieValue === encryptedValue && this.cookieDoMain === domain) {
670            // 如果设置过 cookie 且 值 和 域 相同 则这里就不继续更新 cookie 了
671            return;
672        }
673        if (domain) {
674            document.cookie = `${cookieName}=${encryptedValue};path=/;domain=${domain}`;
675            return;
676        }
677        document.cookie = `${cookieName}=${encryptedValue};path=/`;
678        // 标记 cookie 信息
679        this.isSetCookie = true;
680        this.cookieValue = encryptedValue;
681        this.cookieDoMain = domain;
682    }
683
684    /**
685     * 获取指定空间的所有的进度条
686     * @param userId {int|string} 指定要获取到的文件进度数据对应的空间id
687     * @param okFun {function} 操作成功之后的回调函数 输入是被文件进度的json对象
688     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
689     * @param checkFun {function} 操作前的检查函数 输入是请求参数对象,如果返回的是一个false 则代表检查失败不继续操作
690     */
691    getAllProgressBar(userId, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) {
692        if (userId === undefined || okFun === undefined) {
693            const err = "您必须要输入 userId 和 okFun 参数才可以进行文件对象的获取!";
694            if (errorFun !== undefined) {
695                errorFun(err);
696            } else {
697                console.error(err);
698            }
699            return;
700        }
701        if (checkFun !== undefined && !checkFun(userId)) {
702            return;
703        }
704        axios.defaults.withCredentials = true;
705        // 开始获取
706        axios(
707            {
708                method: 'post',
709                url: this.diskMirrorUrl + this.getController() + '/getAllProgressBar',
710                params: {
711                    id: userId
712                }
713            }
714        ).then(function (res) {
715            // 处理成功
716            if (okFun !== undefined) {
717                okFun(res.data);
718            } else {
719                console.info(res.data);
720            }
721        }).catch(function (err) {
722            // 处理错误
723            if (errorFun !== undefined) {
724                errorFun(err);
725            } else {
726                console.error(err);
727            }
728        });
729    }
730
731    /**
732     * 将当前客户端连接的服务器关机(如果服务器端受支持的话,则会返回关机或有效信息)
733     *
734     * @param password {string} 关机操作的校验码,如果校验码不正确,则无法处理关机请求
735     * @param okFun {function} 操作成功之后的回调函数 输入是被文件进度的json对象
736     * @param errorFun {function} 操作失败之后的回调函数 输入是错误信息
737     */
738    shutdown(password, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) {
739        axios.defaults.withCredentials = true;
740        // 开始获取
741        axios(
742            {
743                method: 'post',
744                url: this.diskMirrorUrl + this.getController() + '/shutdown',
745                params: {
746                    password: password
747                }
748            }
749        ).then(function (res) {
750            // 处理成功
751            if (okFun !== undefined) {
752                okFun(res.data);
753            } else {
754                console.info(res.data);
755            }
756        }).catch(function (err) {
757            // 处理错误
758            if (errorFun !== undefined) {
759                errorFun(err);
760            } else {
761                console.error(err);
762            }
763        });
764    }
765
766}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.