mm_machine 1.4.3 → 1.4.6
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 +24 -16
- package/package.json +34 -34
package/index.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* @author <a href="http://qww.elins.cn">邱文武</a>
|
|
4
4
|
* @version 1.2
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
require('mm_expand');
|
|
6
|
+
var conf = require('mm_config');
|
|
8
7
|
|
|
9
8
|
const fs = require('fs');
|
|
10
9
|
|
|
@@ -62,9 +61,9 @@ class Item {
|
|
|
62
61
|
*/
|
|
63
62
|
"sort": 10,
|
|
64
63
|
/**
|
|
65
|
-
*
|
|
64
|
+
* 状态, 1表示开启,0表示未开启
|
|
66
65
|
*/
|
|
67
|
-
"
|
|
66
|
+
"state": 1
|
|
68
67
|
};
|
|
69
68
|
|
|
70
69
|
/**
|
|
@@ -74,6 +73,14 @@ class Item {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
|
76
|
+
/**
|
|
77
|
+
* 设置配置
|
|
78
|
+
* @param {Object} config 配置
|
|
79
|
+
*/
|
|
80
|
+
Item.prototype.set_config = function(config){
|
|
81
|
+
this.config = conf(Object.assign(this.config, config || {}));
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
/**
|
|
78
85
|
* @description 加载完成时
|
|
79
86
|
*/
|
|
@@ -106,16 +113,15 @@ Item.prototype.remove_module = function(module) {
|
|
|
106
113
|
* @description 加载配置对象
|
|
107
114
|
* @param {Object} obj 配置对象
|
|
108
115
|
*/
|
|
109
|
-
Item.prototype.loadObj = function(
|
|
110
|
-
|
|
111
|
-
var f = this.config.func_file;
|
|
116
|
+
Item.prototype.loadObj = function(config) {
|
|
117
|
+
var f = config.func_file;
|
|
112
118
|
if (f) {
|
|
113
119
|
var file = f.fullname(this.dir);
|
|
114
120
|
if (file.hasFile()) {
|
|
115
121
|
this.remove_module(file);
|
|
116
122
|
var cs = require(file);
|
|
117
123
|
if (cs) {
|
|
118
|
-
var name =
|
|
124
|
+
var name = config.func_name;
|
|
119
125
|
if (name) {
|
|
120
126
|
this.main = cs[name];
|
|
121
127
|
} else {
|
|
@@ -151,6 +157,10 @@ Item.prototype.loadFile = function(file) {
|
|
|
151
157
|
obj = text.toJson();
|
|
152
158
|
} else {
|
|
153
159
|
this.new_config(f);
|
|
160
|
+
var text = f.loadText();
|
|
161
|
+
if (text) {
|
|
162
|
+
obj = text.toJson();
|
|
163
|
+
}
|
|
154
164
|
}
|
|
155
165
|
this.filename = f;
|
|
156
166
|
return obj;
|
|
@@ -212,16 +222,14 @@ Item.prototype.removeFile = function() {
|
|
|
212
222
|
* @param {Object|String} cg 配置对象或配置路径
|
|
213
223
|
*/
|
|
214
224
|
Item.prototype.load = function(cg) {
|
|
215
|
-
var
|
|
216
|
-
if (!cg) {
|
|
217
|
-
cg = this.extensions;
|
|
218
|
-
}
|
|
225
|
+
var config;
|
|
219
226
|
if (typeof(cg) === "string") {
|
|
220
|
-
|
|
227
|
+
config = this.loadFile(cg);
|
|
221
228
|
} else {
|
|
222
|
-
|
|
229
|
+
config = cg;
|
|
223
230
|
}
|
|
224
|
-
this.
|
|
231
|
+
this.set_config(config);
|
|
232
|
+
this.loadObj(config);
|
|
225
233
|
};
|
|
226
234
|
|
|
227
235
|
/**
|
|
@@ -569,4 +577,4 @@ Index.prototype.load_file = function(file) {
|
|
|
569
577
|
/**
|
|
570
578
|
* @module 导出Index类
|
|
571
579
|
*/
|
|
572
|
-
exports.Index = Index;
|
|
580
|
+
exports.Index = Index;
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mm_machine",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test.js"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/qiuwenwu/mm_machine.git"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"common",
|
|
15
|
-
"com",
|
|
16
|
-
"run",
|
|
17
|
-
"cmd",
|
|
18
|
-
"load",
|
|
19
|
-
"save",
|
|
20
|
-
"get",
|
|
21
|
-
"set",
|
|
22
|
-
"add",
|
|
23
|
-
"del"
|
|
24
|
-
],
|
|
25
|
-
"author": "邱文武",
|
|
26
|
-
"license": "ISC",
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/qiuwenwu/mm_machine/issues"
|
|
29
|
-
},
|
|
30
|
-
"homepage": "https://github.com/qiuwenwu/mm_machine#readme",
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mm_machine",
|
|
3
|
+
"version": "1.4.6",
|
|
4
|
+
"description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/qiuwenwu/mm_machine.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"common",
|
|
15
|
+
"com",
|
|
16
|
+
"run",
|
|
17
|
+
"cmd",
|
|
18
|
+
"load",
|
|
19
|
+
"save",
|
|
20
|
+
"get",
|
|
21
|
+
"set",
|
|
22
|
+
"add",
|
|
23
|
+
"del"
|
|
24
|
+
],
|
|
25
|
+
"author": "邱文武",
|
|
26
|
+
"license": "ISC",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/qiuwenwu/mm_machine/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/qiuwenwu/mm_machine#readme",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"mm_config": "^1.0.2"
|
|
33
|
+
}
|
|
34
|
+
}
|