mm_machine 1.6.8 → 1.6.9

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.
@@ -1,11 +1,20 @@
1
1
 
2
2
  var i = 0;
3
3
  function test() {
4
- console.log("你好123", i++)
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
+ }
@@ -3,7 +3,7 @@ class Demo {
3
3
  }
4
4
  var i = 0;
5
5
  Demo.prototype.main = function() {
6
- console.log("我很好123", i++);
6
+ console.log("我很好7654321", i++);
7
7
  }
8
8
 
9
9
  module.exports = new Demo();
@@ -6,6 +6,15 @@ function test() {
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/index.js CHANGED
@@ -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
- return this[method](...params);
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
4
4
  "description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
5
5
  "main": "index.js",
6
6
  "scripts": {