ming_node 2.2.6 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,3 +17,6 @@ var app=M.server();
17
17
  app.listen(8888);
18
18
 
19
19
  app.use(mongoDbBaseRestApi);
20
+
21
+
22
+ console.log(M._globle_plugin)
@@ -0,0 +1,10 @@
1
+ var M=require("ming_node");
2
+
3
+ var app=M.server();
4
+ app.listen(8888);
5
+
6
+ app.installPlugin("http://localhost:4444/OssWebApi.js",{
7
+ name:"我是插件构造方法参数"
8
+ },{
9
+ name:"我是插件构造方法附加参数"
10
+ });
package/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * By : Minglie
4
4
  * QQ: 934031452
5
5
  * Date :2021.12.01
6
- * version :2.2.6
6
+ * version :2.2.7
7
7
  */
8
8
  var http = require('http');
9
9
  var https = require('https');
@@ -42,6 +42,10 @@
42
42
  M._globle_cacheMap = {}
43
43
  //全局对象缓存
44
44
  M._globle_lib_cacheMap={}
45
+ //全局插件地址缓存
46
+ M._globle_plugin_url_cacheMap={};
47
+ //全局插件
48
+ M._globle_plugin=new Set();
45
49
  M._node_lib_path=process.env.NODE_PATH;
46
50
  //远程静态资源路径
47
51
  M.remoteStaticPath = "https://minglie.gitee.io/mingpage/static";
@@ -1732,6 +1736,7 @@ M.urlParse = function (url) {
1732
1736
  } else {
1733
1737
  plugin.install(app, args);
1734
1738
  }
1739
+ M._globle_plugin.add(plugin);
1735
1740
  plugin.installed = true;
1736
1741
  }else {
1737
1742
  if (Array.isArray(url)) {
@@ -1746,6 +1751,17 @@ M.urlParse = function (url) {
1746
1751
  }
1747
1752
  return app;
1748
1753
  }
1754
+
1755
+ app.installPlugin=async function (pluginUrl,constructorParams,pluginParams){
1756
+ if(M._globle_plugin_url_cacheMap[pluginUrl]){
1757
+ return
1758
+ }
1759
+ M._globle_plugin_url_cacheMap[pluginUrl]=pluginUrl;
1760
+ const Plugin= await M.require(pluginUrl);
1761
+ const plugin= new Plugin(constructorParams);
1762
+ app.use(plugin,pluginParams)
1763
+ }
1764
+
1749
1765
  /**
1750
1766
  * 注册get请求
1751
1767
  */
package/package.json CHANGED
@@ -46,5 +46,5 @@
46
46
  "scripts": {
47
47
  "test": "echo \"Error: no test specified\" && exit 1"
48
48
  },
49
- "version": "2.2.6"
49
+ "version": "2.2.7"
50
50
  }