mm_machine 1.4.7 → 1.5.0

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 +40 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -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
  /**
@@ -114,6 +114,12 @@ Item.prototype.remove_module = function(module) {
114
114
  * @param {Object} obj 配置对象
115
115
  */
116
116
  Item.prototype.loadObj = function(config) {
117
+ if(!config){
118
+ config = this.config;
119
+ }
120
+ else {
121
+ config = Object.assign({}, config, this.config);
122
+ }
117
123
  var f = config.func_file;
118
124
  if (f) {
119
125
  var file = f.fullname(this.dir);
@@ -265,6 +271,25 @@ Item.prototype.main = function(param1, param2) {
265
271
  return null;
266
272
  };
267
273
 
274
+ /**
275
+ * 运行指令
276
+ * @param {Number} state 状态 0为不可以,1为可用
277
+ * @param {Array} ...params 参数集合
278
+ */
279
+ Item.prototype.run_cmd = function(state, ...params){
280
+ return null;
281
+ };
282
+
283
+ /**
284
+ * 下达指令
285
+ * @param {Number} state 状态 0为不可以,1为可用
286
+ * @param {Array} ...params 参数集合
287
+ */
288
+ Item.prototype.cmd = function(state, ...params){
289
+ this.config.state = state;
290
+ return this.run_cmd(state, ...param);
291
+ }
292
+
268
293
  /**
269
294
  * @module 导出Drive类
270
295
  */
@@ -435,6 +460,20 @@ Index.prototype.get = function(name) {
435
460
  return obj;
436
461
  };
437
462
 
463
+ /**
464
+ * 下达指令
465
+ * @param {String} name 名称
466
+ * @param {Number} state 状态
467
+ * @param {Array} ...params 参数集合
468
+ */
469
+ Index.prototype.cmd = async function(name, state, ...params){
470
+ var obj = this.get(name);
471
+ if(!obj){
472
+ return "error: program does not exist";
473
+ }
474
+ return await obj.cmd(name, ...params);
475
+ }
476
+
438
477
  /**
439
478
  * @description 查询配置项
440
479
  * @param {String} name 名称
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "1.4.7",
3
+ "version": "1.5.0",
4
4
  "description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
5
5
  "main": "index.js",
6
6
  "scripts": {