mm_machine 1.8.1 → 1.8.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.
Files changed (3) hide show
  1. package/index.js +14 -1
  2. package/package.json +3 -3
  3. package/test.js +6 -1
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
  * 驱动基础类
@@ -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 = file.loadJson(dir);
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.1",
3
+ "version": "1.8.3",
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.1"
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 = 0;
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
  /* 调用示例 */