mm_machine 1.6.8 → 1.7.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.
- package/demo/test1/index.js +11 -2
- package/demo/test2/index.js +1 -1
- package/demo2/test1/index.js +11 -2
- package/index.js +16 -3
- package/package.json +1 -1
package/demo/test1/index.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
|
|
2
2
|
var i = 0;
|
|
3
3
|
function test() {
|
|
4
|
-
console.log("你好
|
|
4
|
+
console.log("你好7654321", i++)
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function main() {
|
|
8
8
|
test();
|
|
9
|
+
return i;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
exports.main = main;
|
|
12
|
+
exports.main = main;
|
|
13
|
+
|
|
14
|
+
exports.main_before = function(){
|
|
15
|
+
console.log("请求前")
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.main_after = function(ret){
|
|
19
|
+
console.log("请求后", ret)
|
|
20
|
+
}
|
package/demo/test2/index.js
CHANGED
package/demo2/test1/index.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
2
1
|
var i = 0;
|
|
2
|
+
|
|
3
3
|
function test() {
|
|
4
4
|
console.log("你好123", i++)
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
function main() {
|
|
8
8
|
test();
|
|
9
|
+
return i;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.main = main;
|
|
13
|
+
|
|
14
|
+
exports.main_before = function() {
|
|
15
|
+
console.log("请求前")
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
exports.
|
|
18
|
+
exports.main_after = async function(ret) {
|
|
19
|
+
console.log("请求后", ret)
|
|
20
|
+
}
|
package/index.js
CHANGED
|
@@ -314,7 +314,7 @@ Item.prototype.save = function() {
|
|
|
314
314
|
* @param {Object} param1 参数一
|
|
315
315
|
* @param {Object} param2 参数二
|
|
316
316
|
*/
|
|
317
|
-
Item.prototype.main = function(
|
|
317
|
+
Item.prototype.main = async function(...params) {
|
|
318
318
|
return null;
|
|
319
319
|
};
|
|
320
320
|
|
|
@@ -324,9 +324,22 @@ Item.prototype.main = function(param1, param2) {
|
|
|
324
324
|
* @param {Object} params 参数集合
|
|
325
325
|
* @return {Object} 执行结果
|
|
326
326
|
*/
|
|
327
|
-
Item.prototype.run = function(method, ...params) {
|
|
327
|
+
Item.prototype.run = async function(method, ...params) {
|
|
328
328
|
if (this.config.state && this[method]) {
|
|
329
|
-
|
|
329
|
+
if (this[method + "_before"]) {
|
|
330
|
+
this[method + "_before"](...params);
|
|
331
|
+
}
|
|
332
|
+
var ret = this[method](...params);
|
|
333
|
+
if (util.types.isPromise(ret)) {
|
|
334
|
+
ret = await ret;
|
|
335
|
+
}
|
|
336
|
+
if (this[method + "_after"]) {
|
|
337
|
+
ret = this[method + "_after"](ret, ...params) || ret;
|
|
338
|
+
}
|
|
339
|
+
if (util.types.isPromise(ret)) {
|
|
340
|
+
ret = await ret;
|
|
341
|
+
}
|
|
342
|
+
return ret
|
|
330
343
|
}
|
|
331
344
|
};
|
|
332
345
|
|