mm_machine 1.5.0 → 1.5.3
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/index.js +16 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -61,7 +61,7 @@ class Item {
|
|
|
61
61
|
*/
|
|
62
62
|
"sort": 10,
|
|
63
63
|
/**
|
|
64
|
-
* 状态, 1
|
|
64
|
+
* 状态, 0表示未启用, 1表示启用
|
|
65
65
|
*/
|
|
66
66
|
"state": 1
|
|
67
67
|
};
|
|
@@ -109,6 +109,14 @@ Item.prototype.remove_module = function(module) {
|
|
|
109
109
|
// require.cache[path] = null;
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @description 卸载对象
|
|
114
|
+
* @param {String} file 文件
|
|
115
|
+
*/
|
|
116
|
+
Item.prototype.unloadObj = function(file){
|
|
117
|
+
this.remove_module(file || this.filename);
|
|
118
|
+
}
|
|
119
|
+
|
|
112
120
|
/**
|
|
113
121
|
* @description 加载配置对象
|
|
114
122
|
* @param {Object} obj 配置对象
|
|
@@ -118,12 +126,16 @@ Item.prototype.loadObj = function(config) {
|
|
|
118
126
|
config = this.config;
|
|
119
127
|
}
|
|
120
128
|
else {
|
|
121
|
-
|
|
129
|
+
this.set_config(config);
|
|
130
|
+
config = this.config;
|
|
122
131
|
}
|
|
123
132
|
var f = config.func_file;
|
|
124
133
|
if (f) {
|
|
125
134
|
var file = f.fullname(this.dir);
|
|
126
135
|
if (file.hasFile()) {
|
|
136
|
+
if(!config.state){
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
127
139
|
this.remove_module(file);
|
|
128
140
|
var cs = require(file);
|
|
129
141
|
if (cs) {
|
|
@@ -234,8 +246,7 @@ Item.prototype.load = function(cg) {
|
|
|
234
246
|
} else {
|
|
235
247
|
config = cg;
|
|
236
248
|
}
|
|
237
|
-
this.
|
|
238
|
-
this.loadObj(this.config);
|
|
249
|
+
this.loadObj(config);
|
|
239
250
|
};
|
|
240
251
|
|
|
241
252
|
/**
|
|
@@ -352,8 +363,8 @@ Index.prototype.Drive = Item;
|
|
|
352
363
|
*/
|
|
353
364
|
Index.prototype.load_item = function(dir, cg, file) {
|
|
354
365
|
var drive = new this.Drive(dir);
|
|
355
|
-
drive.loadObj(cg);
|
|
356
366
|
drive.filename = file;
|
|
367
|
+
drive.loadObj(cg);
|
|
357
368
|
this.list.push(drive);
|
|
358
369
|
};
|
|
359
370
|
|