mm_machine 1.4.9 → 1.5.2

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.
Files changed (2) hide show
  1. package/index.js +19 -2
  2. 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表示开启,0表示未开启
64
+ * 状态, 0表示未启用, 1表示启用
65
65
  */
66
66
  "state": 1
67
67
  };
@@ -78,7 +78,7 @@ class Item {
78
78
  * @param {Object} config 配置
79
79
  */
80
80
  Item.prototype.set_config = function(config){
81
- this.config = conf(Object.assign(this.config, config || {}));
81
+ this.config = conf(Object.assign({}, this.config, config || {}));
82
82
  }
83
83
 
84
84
  /**
@@ -109,15 +109,32 @@ 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 配置对象
115
123
  */
116
124
  Item.prototype.loadObj = function(config) {
125
+ if(!config){
126
+ config = this.config;
127
+ }
128
+ else {
129
+ config = Object.assign({}, config, this.config);
130
+ }
117
131
  var f = config.func_file;
118
132
  if (f) {
119
133
  var file = f.fullname(this.dir);
120
134
  if (file.hasFile()) {
135
+ if(!config.state){
136
+ return;
137
+ }
121
138
  this.remove_module(file);
122
139
  var cs = require(file);
123
140
  if (cs) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "1.4.9",
3
+ "version": "1.5.2",
4
4
  "description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
5
5
  "main": "index.js",
6
6
  "scripts": {