mm_machine 2.7.6 → 2.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/drive.js +716 -699
- package/index.js +1006 -1000
- package/package.json +7 -7
package/drive.js
CHANGED
|
@@ -1,699 +1,716 @@
|
|
|
1
|
-
const prettier = require('@prettier/sync');
|
|
2
|
-
require('mm_tpl');
|
|
3
|
-
let {
|
|
4
|
-
|
|
5
|
-
} = require('
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
else if (this.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
let
|
|
243
|
-
if (!
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
this._setMainMethod(cs);
|
|
336
|
-
return cs;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
*
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
*
|
|
428
|
-
* @
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
*
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
file.
|
|
446
|
-
return
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
*
|
|
451
|
-
* @
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
"
|
|
473
|
-
|
|
474
|
-
"
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
let
|
|
499
|
-
let
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
return
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
*
|
|
521
|
-
* @
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
*
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
*
|
|
552
|
-
*/
|
|
553
|
-
Drive.prototype.
|
|
554
|
-
let
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return null;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
1
|
+
const prettier = require('@prettier/sync');
|
|
2
|
+
require('mm_tpl');
|
|
3
|
+
let { conf } = require('mm_config');
|
|
4
|
+
// const { Word } = require('./ulits/word.js');
|
|
5
|
+
const { Mod } = require('./mod');
|
|
6
|
+
|
|
7
|
+
if (!$.prettyCode) {
|
|
8
|
+
$.prettyCode = function (code, options) {
|
|
9
|
+
return prettier.format(code, options);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 驱动基础类
|
|
15
|
+
* @class
|
|
16
|
+
*/
|
|
17
|
+
class Drive extends Mod {
|
|
18
|
+
// 配置项
|
|
19
|
+
static config = {
|
|
20
|
+
// 名称, 由中英文和下"_"组成, 用于卸载接口 例如: demo
|
|
21
|
+
name: '',
|
|
22
|
+
// 标题, 介绍作用
|
|
23
|
+
title: '',
|
|
24
|
+
// 描述, 用于描述该有什么用的
|
|
25
|
+
description: '',
|
|
26
|
+
// 文件路径, 当调用函数不存在时,会先从文件中加载
|
|
27
|
+
main: './index.js',
|
|
28
|
+
// 回调函数名 用于决定调用脚本的哪个函数
|
|
29
|
+
func_name: 'main',
|
|
30
|
+
// 作用域(同时作为检索的后缀名)
|
|
31
|
+
scope: $.val && $.val.scope ? $.val.scope : 'server',
|
|
32
|
+
// 排序
|
|
33
|
+
sort: 10,
|
|
34
|
+
// 状态, 0表示未启用, 1表示启用
|
|
35
|
+
state: 1,
|
|
36
|
+
// 显示, 0表示不显示, 1表示显示
|
|
37
|
+
show: 0,
|
|
38
|
+
// 是否结束,可选,默认false
|
|
39
|
+
end: false
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 构造函数
|
|
44
|
+
* @param {object} config 配置项
|
|
45
|
+
* @param {object} parent 父项
|
|
46
|
+
* @class
|
|
47
|
+
*/
|
|
48
|
+
constructor(config, parent) {
|
|
49
|
+
super({ ...Drive.config, ...config }, parent);
|
|
50
|
+
// 当前配置文件路径
|
|
51
|
+
this.config_file = '';
|
|
52
|
+
|
|
53
|
+
// 当前脚本文件路径
|
|
54
|
+
this.script_file = '';
|
|
55
|
+
|
|
56
|
+
// 模式: 1.生产模式 2.热更新模式 3.热重载模式 4.热更新+重载模式 5.重载模式
|
|
57
|
+
this.mode = 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 获取事件触发器
|
|
63
|
+
* @returns {object} 事件触发器
|
|
64
|
+
*/
|
|
65
|
+
Drive.prototype.getEventer = function () {
|
|
66
|
+
return $.eventer;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 配置驱动
|
|
71
|
+
*/
|
|
72
|
+
Drive.prototype._preset = function () {
|
|
73
|
+
let file = this.config.main;
|
|
74
|
+
if (file) {
|
|
75
|
+
this.script_file = file.fullname(this.getDir());
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 获取配置
|
|
81
|
+
* @param {string} file 配置文件路径
|
|
82
|
+
* @returns {object} 配置项
|
|
83
|
+
*/
|
|
84
|
+
Drive.prototype._loadConfig = function (file) {
|
|
85
|
+
if (file) {
|
|
86
|
+
this.config_file = file;
|
|
87
|
+
}
|
|
88
|
+
// 加载配置
|
|
89
|
+
let config = $.loadJson(this.config_file, (cg) => {
|
|
90
|
+
this.setConfig(cg);
|
|
91
|
+
return cg;
|
|
92
|
+
});
|
|
93
|
+
if (!config) {
|
|
94
|
+
this.newConfig(this.config_file);
|
|
95
|
+
config = $.loadJson(this.config_file, (cg) => {
|
|
96
|
+
this.setConfig(cg);
|
|
97
|
+
return cg;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
this.setConfig(config);
|
|
101
|
+
return config;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 加载配置
|
|
106
|
+
* @param {string} file 配置文件路径
|
|
107
|
+
*/
|
|
108
|
+
Drive.prototype.loadConfig = function (file) {
|
|
109
|
+
this._loadConfig(file);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 设置配置
|
|
114
|
+
* @param {object} config 配置对象
|
|
115
|
+
* @returns {object} 配置项
|
|
116
|
+
*/
|
|
117
|
+
Drive.prototype.setConfig = function (config) {
|
|
118
|
+
if (config) {
|
|
119
|
+
// 如果main改变,重置加载状态
|
|
120
|
+
if (config.main !== this.config.main) {
|
|
121
|
+
this.is_loaded = false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this.config_file) {
|
|
125
|
+
// 合并配置并应用配置处理
|
|
126
|
+
this.config = conf(
|
|
127
|
+
{
|
|
128
|
+
...this.config,
|
|
129
|
+
...config
|
|
130
|
+
},
|
|
131
|
+
this.config_file
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
Object.assign(this.config, config);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this._preset();
|
|
138
|
+
return this.config;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* 获取配置
|
|
143
|
+
* @returns {object} 配置项
|
|
144
|
+
*/
|
|
145
|
+
Drive.prototype.getConfig = function () {
|
|
146
|
+
return this.config;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 获取当前文件
|
|
151
|
+
* @returns {object} 当前文件对象
|
|
152
|
+
*/
|
|
153
|
+
Drive.prototype.getDir = function () {
|
|
154
|
+
let dir = this._dir;
|
|
155
|
+
if (!dir) {
|
|
156
|
+
if (this.script_file) {
|
|
157
|
+
dir = this.script_file.dirname();
|
|
158
|
+
this._dir = dir;
|
|
159
|
+
} else if (this.config_file) {
|
|
160
|
+
dir = this.config_file.dirname();
|
|
161
|
+
this._dir = dir;
|
|
162
|
+
} else if (this.getParent) {
|
|
163
|
+
let parent_dir = this.getParent()?.getDir() || '';
|
|
164
|
+
if (parent_dir) {
|
|
165
|
+
dir = this.config.name.fullname(parent_dir);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return dir;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 获取模板目录
|
|
174
|
+
* @returns {string} 模板目录
|
|
175
|
+
*/
|
|
176
|
+
Drive.prototype._getTplDir = function () {
|
|
177
|
+
return this.getParent()?.getTplDir() || '';
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 移除加载的脚本模块
|
|
182
|
+
*/
|
|
183
|
+
Drive.prototype._remove = function () {
|
|
184
|
+
let file = this._getScriptFile();
|
|
185
|
+
if (!file) return;
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
if (this.mode === 3 || this.mode === 4) {
|
|
189
|
+
// 移除模块和监听
|
|
190
|
+
$.mod.unload(file);
|
|
191
|
+
} else {
|
|
192
|
+
// 移除模块缓存
|
|
193
|
+
let filename = require.resolve(file);
|
|
194
|
+
if (require.cache[filename]) {
|
|
195
|
+
require.cache[filename] = null;
|
|
196
|
+
delete require.cache[filename];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
} catch (err) {
|
|
200
|
+
this.log('error', `移除加载的脚本模块失败: `, err);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 卸载脚本
|
|
206
|
+
*/
|
|
207
|
+
Drive.prototype.unloadScript = function () {
|
|
208
|
+
this._remove();
|
|
209
|
+
this._script_keys = null;
|
|
210
|
+
this.is_loaded = false;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 重新加载脚本
|
|
215
|
+
* @returns {object | null} 返回加载的模块对象
|
|
216
|
+
*/
|
|
217
|
+
Drive.prototype.reloadScript = function () {
|
|
218
|
+
this.unloadScript();
|
|
219
|
+
return this.loadScript();
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 卸载之后处理
|
|
224
|
+
* @param {boolean} remove 是否删除文件
|
|
225
|
+
*/
|
|
226
|
+
Drive.prototype.unloadCore = async function (remove) {
|
|
227
|
+
// 删除脚本
|
|
228
|
+
this.unloadScript();
|
|
229
|
+
if (remove) {
|
|
230
|
+
this.delFile();
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* 获取脚本文件路径
|
|
236
|
+
* @returns {string | null} 完整文件路径
|
|
237
|
+
*/
|
|
238
|
+
Drive.prototype._getScriptFile = function () {
|
|
239
|
+
let main = this.config.main || '';
|
|
240
|
+
if (!main) return null;
|
|
241
|
+
|
|
242
|
+
let filename = main.fullname(this.getDir());
|
|
243
|
+
if (!filename.hasFile()) {
|
|
244
|
+
this.newScript(filename);
|
|
245
|
+
}
|
|
246
|
+
return filename;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 新建脚本文件
|
|
251
|
+
* @param {string} file 目标文件路径
|
|
252
|
+
*/
|
|
253
|
+
Drive.prototype.newScript = function (file) {
|
|
254
|
+
this._createScriptFile(file);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 创建脚本
|
|
259
|
+
* @param {string} file 文件路径
|
|
260
|
+
* @returns {boolean} 创建是否成功
|
|
261
|
+
*/
|
|
262
|
+
Drive.prototype._createScriptFile = function (file) {
|
|
263
|
+
var tpl = this._getScriptTpl();
|
|
264
|
+
var content = $.tpl.render(tpl, this.getModel('script'));
|
|
265
|
+
if (!content) {
|
|
266
|
+
return '';
|
|
267
|
+
}
|
|
268
|
+
let code = this.prettyCode(content, 'js');
|
|
269
|
+
file.saveText(code);
|
|
270
|
+
return file;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 获取脚本模板
|
|
275
|
+
* @returns {string} 脚本模板内容
|
|
276
|
+
*/
|
|
277
|
+
Drive.prototype._getScriptTpl = function () {
|
|
278
|
+
var f = './script.tpl.js'.fullname(this._getTplDir());
|
|
279
|
+
if (f.hasFile()) {
|
|
280
|
+
return f.loadText();
|
|
281
|
+
} else {
|
|
282
|
+
return `module.exports = {
|
|
283
|
+
/**
|
|
284
|
+
* 初始化
|
|
285
|
+
*/
|
|
286
|
+
async _init() {
|
|
287
|
+
this.log('debug', \`初始化!\`);
|
|
288
|
+
},
|
|
289
|
+
/**
|
|
290
|
+
* 启动
|
|
291
|
+
*/
|
|
292
|
+
async _start() {
|
|
293
|
+
this.log('debug', \`启动!\`);
|
|
294
|
+
},
|
|
295
|
+
/**
|
|
296
|
+
* 停止
|
|
297
|
+
*/
|
|
298
|
+
async _stop() {
|
|
299
|
+
this.log('debug', \`停止!\`);
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* 销毁
|
|
303
|
+
*/
|
|
304
|
+
async _destroy(...args) {
|
|
305
|
+
this.log('debug', \`销毁!\`);
|
|
306
|
+
},
|
|
307
|
+
/**
|
|
308
|
+
* 主要逻辑
|
|
309
|
+
*/
|
|
310
|
+
async main(...args) {
|
|
311
|
+
// 主要代码写在这
|
|
312
|
+
}
|
|
313
|
+
}`;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 加载脚本文件,支持热重载模式
|
|
319
|
+
* 在开发模式(mode=3或4)下使用 $.require 进行热重载
|
|
320
|
+
* 在生产模式下使用标准的 require 加载
|
|
321
|
+
* @returns {object | null} 加载的模块对象
|
|
322
|
+
*/
|
|
323
|
+
Drive.prototype.loadScript = function () {
|
|
324
|
+
let file = this._getScriptFile();
|
|
325
|
+
if (!file) return null;
|
|
326
|
+
if (this.mode === 3 || this.mode === 4) {
|
|
327
|
+
// 开发模式:使用 $.require 进行热重载,绑定热更新回调
|
|
328
|
+
var cs = $.require(file, (mod) => {
|
|
329
|
+
this._setMainMethod(mod);
|
|
330
|
+
});
|
|
331
|
+
this._setMainMethod(cs);
|
|
332
|
+
return cs;
|
|
333
|
+
} else {
|
|
334
|
+
var cs = require(file);
|
|
335
|
+
this._setMainMethod(cs);
|
|
336
|
+
return cs;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 设置主方法
|
|
342
|
+
* @param {object} mod 模块对象
|
|
343
|
+
*/
|
|
344
|
+
Drive.prototype._setMainMethod = function (mod) {
|
|
345
|
+
if (!mod) return;
|
|
346
|
+
var name = this.config.func_name || 'main';
|
|
347
|
+
if (name && mod[name]) {
|
|
348
|
+
this.main = mod[name];
|
|
349
|
+
}
|
|
350
|
+
var new_keys = Object.keys(mod);
|
|
351
|
+
// 热重载时如果脚本未变化则跳过重建
|
|
352
|
+
if (this._script_keys && this._script_keys.length === new_keys.length) {
|
|
353
|
+
var same = true;
|
|
354
|
+
for (var i = 0; i < new_keys.length; i++) {
|
|
355
|
+
if (this._script_keys[i] !== new_keys[i]) {
|
|
356
|
+
same = false;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (same) {
|
|
361
|
+
this.is_loaded = true;
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
this._script_keys = new_keys;
|
|
366
|
+
for (var key in mod) {
|
|
367
|
+
var obj = mod[key];
|
|
368
|
+
if (typeof obj === 'function') {
|
|
369
|
+
this.setMethod(key, obj);
|
|
370
|
+
} else {
|
|
371
|
+
this.setData(key, obj);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
this.is_loaded = true;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* 获取配置文件作用域
|
|
379
|
+
* @param {object} file 文件对象
|
|
380
|
+
* @returns {string} 配置文件作用域
|
|
381
|
+
*/
|
|
382
|
+
Drive.prototype._getScope = function (file) {
|
|
383
|
+
return file.replace(/\\/g, '/').between('app/', '/');
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* 新建配置文件
|
|
388
|
+
* @param {string} file 目标文件路径
|
|
389
|
+
*/
|
|
390
|
+
Drive.prototype.newConfig = function (file) {
|
|
391
|
+
if (!this.config.name) {
|
|
392
|
+
this.config.name = this._getName(file);
|
|
393
|
+
this.config.scope = this._getScope(file);
|
|
394
|
+
}
|
|
395
|
+
this._createConfigFile(file);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* 预试代码
|
|
400
|
+
* @param {string} code 要预试的代码
|
|
401
|
+
* @param {string} type 预试类型,可选"json"或"js"
|
|
402
|
+
* @returns {string} 预试后的代码字符串
|
|
403
|
+
*/
|
|
404
|
+
Drive.prototype.prettyCode = function (code, type = 'json5') {
|
|
405
|
+
let options = {
|
|
406
|
+
tabWidth: 2
|
|
407
|
+
};
|
|
408
|
+
switch (type) {
|
|
409
|
+
case 'json5':
|
|
410
|
+
options.parser = 'json5';
|
|
411
|
+
break;
|
|
412
|
+
case 'js':
|
|
413
|
+
case 'javascript':
|
|
414
|
+
options.parser = 'babel';
|
|
415
|
+
options.semi = true; // 在语句末尾添加分号
|
|
416
|
+
options.singleQuote = true; // 使用单引号
|
|
417
|
+
break;
|
|
418
|
+
default:
|
|
419
|
+
options.parser = 'json';
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
let new_code = $.prettyCode(code, options);
|
|
423
|
+
return new_code;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 获取模块模型
|
|
428
|
+
* @param {string} type 模型类型,可选"config"或"script"
|
|
429
|
+
* @returns {object} 模块模型
|
|
430
|
+
*/
|
|
431
|
+
Drive.prototype.getModel = function (type) {
|
|
432
|
+
return this.config;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* 创建配置文件
|
|
437
|
+
* @param {string} file 目标文件路径
|
|
438
|
+
* @param {object} model 模块模型
|
|
439
|
+
* @returns {string} 配置文件内容
|
|
440
|
+
*/
|
|
441
|
+
Drive.prototype._createConfigFile = function (file, model) {
|
|
442
|
+
var tpl = this._getConfigTpl();
|
|
443
|
+
var content = $.tpl.render(tpl, model || this.getModel('config'));
|
|
444
|
+
let code = this.prettyCode(content, 'json');
|
|
445
|
+
file.saveText(code);
|
|
446
|
+
return file;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* 创建配置文件
|
|
451
|
+
* @param {string} file 目标文件路径
|
|
452
|
+
* @param {object} model 模块模型
|
|
453
|
+
* @returns {string} 配置文件内容
|
|
454
|
+
*/
|
|
455
|
+
Drive.prototype.createConfigFile = function (file, model) {
|
|
456
|
+
file.addDir();
|
|
457
|
+
return this._createConfigFile(file, model);
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* 获取配置模板
|
|
462
|
+
* @returns {string} 配置模板内容
|
|
463
|
+
*/
|
|
464
|
+
Drive.prototype._getConfigTpl = function () {
|
|
465
|
+
var f = './config.tpl.json'.fullname(this._getTplDir());
|
|
466
|
+
if (f.hasFile()) {
|
|
467
|
+
return f.loadText();
|
|
468
|
+
} else {
|
|
469
|
+
return `{
|
|
470
|
+
// 模块名称,必填
|
|
471
|
+
"name": "\${name}",
|
|
472
|
+
// 模块标题,可选,默认"示例标题"
|
|
473
|
+
"title": "\${title || '示例标题'}",
|
|
474
|
+
// 模块描述,可选,默认"示例描述"
|
|
475
|
+
"description": "\${description || '示例描述'}",
|
|
476
|
+
// 主脚本文件路径,可选,默认"./index.js"
|
|
477
|
+
"main": "\${main || './index.js'}",
|
|
478
|
+
// 模块作用域,可选,默认"server"
|
|
479
|
+
"scope": "\${scope || 'server'}",
|
|
480
|
+
// 模块状态,可选,默认1
|
|
481
|
+
"state": \${state || 1},
|
|
482
|
+
// 模块排序,可选,默认100
|
|
483
|
+
"sort": \${sort || 100},
|
|
484
|
+
// 是否结束,可选,默认false
|
|
485
|
+
"end": \${end || false}
|
|
486
|
+
}`;
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* 加载配置文件
|
|
492
|
+
* @param {string} file 文件路径
|
|
493
|
+
* @param {string} name 配置项名称
|
|
494
|
+
* @returns {object | null} 配置对象
|
|
495
|
+
*/
|
|
496
|
+
Drive.prototype.loadFile = function (file, name) {
|
|
497
|
+
try {
|
|
498
|
+
let filename = file.fullname(this.getDir());
|
|
499
|
+
let text = filename.loadText();
|
|
500
|
+
|
|
501
|
+
// 如果文件不存在,创建新的配置文件
|
|
502
|
+
if (!text) {
|
|
503
|
+
this.newConfig(filename);
|
|
504
|
+
text = filename.loadText();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (!text) return null;
|
|
508
|
+
|
|
509
|
+
let config = this._loadHotReload(filename);
|
|
510
|
+
let final_config = this._findConfigByName(config, name);
|
|
511
|
+
return final_config;
|
|
512
|
+
} catch (err) {
|
|
513
|
+
this.log('error', `加载配置文件失败: `, err);
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* 根据模式加载配置(支持热更新)
|
|
520
|
+
* @param {string} file 完整文件路径
|
|
521
|
+
* @returns {object | Array | null} 配置对象
|
|
522
|
+
*/
|
|
523
|
+
Drive.prototype._loadHotReload = function (file) {
|
|
524
|
+
if (this.mode === 2 || this.mode === 3 || this.mode === 4) {
|
|
525
|
+
return $.loadJson(file, this._handleHotReload.bind(this));
|
|
526
|
+
}
|
|
527
|
+
return file.loadJson();
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* 根据名称在配置数组中查找配置项
|
|
532
|
+
* @param {object | Array} config 配置对象或数组
|
|
533
|
+
* @param {string} name 配置项名称
|
|
534
|
+
* @returns {object | null} 匹配的配置项
|
|
535
|
+
*/
|
|
536
|
+
Drive.prototype._findConfigByName = function (config, name) {
|
|
537
|
+
if (!name || !Array.isArray(config)) return config;
|
|
538
|
+
return config.find((Drive) => Drive.name === name) || null;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* 根据模式决定是否重新加载脚本
|
|
543
|
+
*/
|
|
544
|
+
Drive.prototype._reloadIfNeeded = function () {
|
|
545
|
+
if (this.mode === 3 || this.mode === 4) {
|
|
546
|
+
this.reloadScript();
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* 删除目录
|
|
552
|
+
*/
|
|
553
|
+
Drive.prototype.delDir = function () {
|
|
554
|
+
let main = this.config.main;
|
|
555
|
+
if (main && $.dir && $.dir.del) {
|
|
556
|
+
$.dir.del(this.dir);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* 删除配置和脚本文件
|
|
562
|
+
* @returns {string | null} 错误消息,如果没有错误则返回null
|
|
563
|
+
*/
|
|
564
|
+
Drive.prototype.delFile = function () {
|
|
565
|
+
let name = this.config.name;
|
|
566
|
+
let file = this.script_file;
|
|
567
|
+
|
|
568
|
+
let error_message = null;
|
|
569
|
+
try {
|
|
570
|
+
if (!file || !file.hasFile) return null;
|
|
571
|
+
|
|
572
|
+
if (!file.hasFile()) {
|
|
573
|
+
return '配置文件不存在';
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
error_message = this._delConfigFile(file, name);
|
|
577
|
+
} catch (err) {
|
|
578
|
+
this.log('error', `删除文件失败: `, err);
|
|
579
|
+
error_message = `删除失败: ${err.message}`;
|
|
580
|
+
}
|
|
581
|
+
return error_message;
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* 删除配置文件
|
|
586
|
+
* @param {object} file 文件对象
|
|
587
|
+
* @param {string} name 配置名称
|
|
588
|
+
* @returns {string | null} 错误消息
|
|
589
|
+
*/
|
|
590
|
+
Drive.prototype._delConfigFile = function (file, name) {
|
|
591
|
+
let text = file.loadText();
|
|
592
|
+
if (!text) {
|
|
593
|
+
this.delDir();
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
let config = text.toJson();
|
|
598
|
+
if (Array.isArray(config)) {
|
|
599
|
+
return this._delArray(file, config, name);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
this.delDir();
|
|
603
|
+
return null;
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* 从数组配置中删除指定项
|
|
608
|
+
* @param {object} file 文件对象
|
|
609
|
+
* @param {Array} config 配置数组
|
|
610
|
+
* @param {string} name 配置名称
|
|
611
|
+
* @returns {string | null} 错误消息
|
|
612
|
+
*/
|
|
613
|
+
Drive.prototype._delArray = function (file, config, name) {
|
|
614
|
+
let index = config.findIndex((Drive) => Drive.name === name);
|
|
615
|
+
if (index === -1) return null;
|
|
616
|
+
|
|
617
|
+
this.delDir();
|
|
618
|
+
config.splice(index, 1);
|
|
619
|
+
|
|
620
|
+
if (config.length > 0) {
|
|
621
|
+
file.saveText(JSON.stringify(config, null, 4));
|
|
622
|
+
} else if (file.delFile) {
|
|
623
|
+
file.delFile();
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
return null;
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* 获取配置文件名称
|
|
631
|
+
* @param {object} file 文件对象
|
|
632
|
+
* @returns {string} 配置文件名称
|
|
633
|
+
*/
|
|
634
|
+
Drive.prototype._getName = function (file) {
|
|
635
|
+
let name = file.dirname().basename();
|
|
636
|
+
return name;
|
|
637
|
+
// // 提取文件名作为模块名
|
|
638
|
+
// var word = new Word();
|
|
639
|
+
// // 将文件名改为驼峰命名法
|
|
640
|
+
// return word.toCamelCase(name);
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* 加载前处理
|
|
645
|
+
*/
|
|
646
|
+
Drive.prototype.loadBefore = function () {
|
|
647
|
+
try {
|
|
648
|
+
let module = this.loadScript();
|
|
649
|
+
if (module) {
|
|
650
|
+
this.is_loaded = true;
|
|
651
|
+
}
|
|
652
|
+
} catch (err) {
|
|
653
|
+
this.log('error', `加载前处理失败: `, err);
|
|
654
|
+
this.is_loaded = false;
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* 加载处理
|
|
660
|
+
*/
|
|
661
|
+
Drive.prototype._loadCore = function () {
|
|
662
|
+
// this.loadConfig();
|
|
663
|
+
// this.loadScript();
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* 保存配置
|
|
668
|
+
*/
|
|
669
|
+
Drive.prototype.save = function () {
|
|
670
|
+
try {
|
|
671
|
+
if (!this.script_file) return;
|
|
672
|
+
|
|
673
|
+
let file = this.script_file.fullname(this.getDir());
|
|
674
|
+
let text = file.loadText();
|
|
675
|
+
|
|
676
|
+
if (text && text.trim().startsWith('[')) {
|
|
677
|
+
// 数组格式配置
|
|
678
|
+
let config = text.toJson();
|
|
679
|
+
if (Array.isArray(config)) {
|
|
680
|
+
// 查找并更新现有配置项
|
|
681
|
+
let index = config.findIndex((Drive) => Drive.name === this.config.name);
|
|
682
|
+
if (index !== -1) {
|
|
683
|
+
config[index] = this.config;
|
|
684
|
+
} else {
|
|
685
|
+
// 如果不存在,添加新配置项
|
|
686
|
+
config.push(this.config);
|
|
687
|
+
}
|
|
688
|
+
file.saveText(JSON.stringify(config, null, 2));
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// 单对象格式配置,直接保存
|
|
694
|
+
file.saveText(JSON.stringify(this.config, null, 2));
|
|
695
|
+
} catch (err) {
|
|
696
|
+
this.log('error', `保存配置失败: `, err);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* 删除项目
|
|
702
|
+
*/
|
|
703
|
+
Drive.prototype.remove = function () {
|
|
704
|
+
let dir = this.getDir();
|
|
705
|
+
if (dir) {
|
|
706
|
+
dir.delDir();
|
|
707
|
+
}
|
|
708
|
+
return dir;
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* @module 导出Drive类
|
|
713
|
+
*/
|
|
714
|
+
module.exports = {
|
|
715
|
+
Drive
|
|
716
|
+
};
|