mm_machine 1.8.0 → 1.8.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.
- package/demo/test1/demo.json +12 -1
- package/index.js +16 -3
- package/package.json +3 -3
- package/test.js +6 -1
package/demo/test1/demo.json
CHANGED
package/index.js
CHANGED
|
@@ -12,6 +12,9 @@ $.mod = new Mod();
|
|
|
12
12
|
$.require = function(file, func) {
|
|
13
13
|
return $.mod.load(file, func);
|
|
14
14
|
}
|
|
15
|
+
$.loadJson = function(file, func) {
|
|
16
|
+
return $.mod.load(file, func);
|
|
17
|
+
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* 驱动基础类
|
|
@@ -359,7 +362,7 @@ Item.prototype.run = async function(method, ...params) {
|
|
|
359
362
|
* @param {Array} ...params 参数集合
|
|
360
363
|
*/
|
|
361
364
|
Item.prototype.run_cmd = async function(state, ...params) {
|
|
362
|
-
return
|
|
365
|
+
return this.run('cmd', state, ...param);
|
|
363
366
|
};
|
|
364
367
|
|
|
365
368
|
/**
|
|
@@ -368,7 +371,7 @@ Item.prototype.run_cmd = async function(state, ...params) {
|
|
|
368
371
|
* @param {Array} ...params 参数集合
|
|
369
372
|
*/
|
|
370
373
|
Item.prototype.cmd = function(state, ...params) {
|
|
371
|
-
return
|
|
374
|
+
return null;
|
|
372
375
|
}
|
|
373
376
|
|
|
374
377
|
/**
|
|
@@ -454,7 +457,17 @@ Index.prototype.load_list = function(list) {
|
|
|
454
457
|
list.map(function(file) {
|
|
455
458
|
var dir = file.dirname();
|
|
456
459
|
// 载入文件
|
|
457
|
-
var obj
|
|
460
|
+
var obj;
|
|
461
|
+
if (_this.mode) {
|
|
462
|
+
obj = $.loadJson(file, function(config) {
|
|
463
|
+
var plug = _this.get(config.name);
|
|
464
|
+
if (plug) {
|
|
465
|
+
plug.set_config(config);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
} else {
|
|
469
|
+
obj = file.loadJson(dir)
|
|
470
|
+
}
|
|
458
471
|
if (obj) {
|
|
459
472
|
if (obj.constructor == Array) {
|
|
460
473
|
obj.map(function(o) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"homepage": "https://github.com/qiuwenwu/mm_machine#readme",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"mm_config": "^1.1.3",
|
|
34
|
-
"mm_hot_reload": "^1.0.
|
|
34
|
+
"mm_hot_reload": "^1.0.4"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|
package/test.js
CHANGED
|
@@ -14,7 +14,7 @@ class Engine extends Index {
|
|
|
14
14
|
constructor(scope, dir_base) {
|
|
15
15
|
super(scope, dir_base);
|
|
16
16
|
// 模式 0生产模式;1开发模式,会重新加载脚本
|
|
17
|
-
this.mode =
|
|
17
|
+
this.mode = 2;
|
|
18
18
|
// 机制类型,必须填写,用于检索文件
|
|
19
19
|
this.type = "demo";
|
|
20
20
|
}
|
|
@@ -76,6 +76,11 @@ async function demo() {
|
|
|
76
76
|
// text = text.replace("1234567", "7654321");
|
|
77
77
|
// file.saveText(text);
|
|
78
78
|
// }, 26000)
|
|
79
|
+
|
|
80
|
+
setInterval(() => {
|
|
81
|
+
var plug = engine.get("demo1");
|
|
82
|
+
console.log("查看变化", plug);
|
|
83
|
+
}, 3000);
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
/* 调用示例 */
|