mm_os 2.9.1 → 2.9.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 (241) hide show
  1. package/cache/route/main/config.json +1 -0
  2. package/cache/sys/app_admin/config.json +1 -0
  3. package/cache/sys/mqtt_engine/config.json +1 -0
  4. package/cache/sys/user/config.json +1 -0
  5. package/core/com/api/drive.js +9 -89
  6. package/core/com/api/index.js +3 -31
  7. package/core/com/cmd/drive.js +10 -1
  8. package/core/com/cmd/index.js +15 -1
  9. package/core/com/component/drive.js +1 -1
  10. package/core/com/component/index.js +16 -12
  11. package/core/com/db/drive.js +1 -1
  12. package/core/com/db/index.js +15 -17
  13. package/core/com/event/drive.js +3 -1
  14. package/core/com/event/index.js +74 -61
  15. package/core/com/eventer/com.js +2 -2
  16. package/core/com/middleware/com.js +41 -16
  17. package/core/com/mqtt/drive.js +4 -3
  18. package/core/com/mqtt/index.js +10 -8
  19. package/core/com/nav/drive.js +1 -19
  20. package/core/com/nav/index.js +1 -1
  21. package/core/com/param/drive.js +1 -1
  22. package/core/com/param/index.js +1 -27
  23. package/core/com/plugin/drive.js +18 -19
  24. package/core/com/plugin/index.js +16 -21
  25. package/core/com/plugin/script.js +109 -58
  26. package/core/com/rpc/com.json +4 -0
  27. package/core/com/rpc/drive.js +160 -0
  28. package/core/com/rpc/index.js +87 -0
  29. package/core/com/socket/drive.js +0 -1
  30. package/core/com/socket/index.js +5 -15
  31. package/core/com/sql/drive.js +1 -1
  32. package/core/com/sql/index.js +4 -31
  33. package/core/com/static/drive.js +13 -54
  34. package/core/com/static/index.js +14 -6
  35. package/core/com/task/drive.js +7 -2
  36. package/core/com/task/index.js +16 -36
  37. package/core/com/tpl/com.js +2 -2
  38. package/demo/app/dev/event_api/manage/event.json +19 -0
  39. package/demo/app/dev/event_api/manage/main.js +26 -0
  40. package/demo/app/dev/plugin/doc/static/api_list.html +144 -0
  41. package/demo/app/dev/plugin/doc/static/api_view.html +692 -0
  42. package/demo/app/dev/plugin/doc/static/index.html +138 -0
  43. package/demo/app/dev/plugin/doc/static/request_test.html +311 -0
  44. package/demo/app/dev/plugin/doc/static/static.js +28 -0
  45. package/demo/app/dev/plugin/doc/static/static.json +20 -0
  46. package/demo/app/dev/plugin/main/api_dev_client/app/api.json +13 -0
  47. package/demo/app/dev/plugin/main/api_dev_client/app/index.js +13 -0
  48. package/demo/app/dev/plugin/main/api_dev_client/app/param.json +147 -0
  49. package/demo/app/dev/plugin/main/api_dev_client/app/sql.json +28 -0
  50. package/demo/app/dev/plugin/main/api_dev_client/auto/api.json +37 -0
  51. package/demo/app/dev/plugin/main/api_dev_client/auto/auto_db.js +70 -0
  52. package/demo/app/dev/plugin/main/api_dev_client/auto/auto_file.js +32 -0
  53. package/demo/app/dev/plugin/main/api_dev_client/auto/index.js +51 -0
  54. package/demo/app/dev/plugin/main/api_dev_client/auto/param.json +51 -0
  55. package/demo/app/dev/plugin/main/api_dev_client/db/api.json +10 -0
  56. package/demo/app/dev/plugin/main/api_dev_client/db/index.js +69 -0
  57. package/demo/app/dev/plugin/main/api_dev_client/db/param.json +31 -0
  58. package/demo/app/dev/plugin/main/api_dev_client/dict/api.json +10 -0
  59. package/demo/app/dev/plugin/main/api_dev_client/dict/index.js +49 -0
  60. package/demo/app/dev/plugin/main/api_dev_client/dict/param.json +29 -0
  61. package/demo/app/dev/plugin/main/api_dev_client/help/api.json +10 -0
  62. package/demo/app/dev/plugin/main/api_dev_client/help/index.js +14 -0
  63. package/demo/app/dev/plugin/main/api_dev_client/help/param.json +31 -0
  64. package/demo/app/dev/plugin/main/api_dev_client/nav/api.json +10 -0
  65. package/demo/app/dev/plugin/main/api_dev_client/nav/index.js +36 -0
  66. package/demo/app/dev/plugin/main/api_dev_client/nav/param.json +36 -0
  67. package/demo/app/dev/plugin/main/api_dev_client/plugin/api.json +10 -0
  68. package/demo/app/dev/plugin/main/api_dev_client/plugin/index.js +13 -0
  69. package/demo/app/dev/plugin/main/api_dev_client/plugin/param.json +31 -0
  70. package/demo/app/dev/plugin/main/api_dev_client/source/api.json +10 -0
  71. package/demo/app/dev/plugin/main/api_dev_client/source/index.js +14 -0
  72. package/demo/app/dev/plugin/main/api_dev_client/source/param.json +31 -0
  73. package/demo/app/dev/plugin/main/api_dev_client/sql/api.json +10 -0
  74. package/demo/app/dev/plugin/main/api_dev_client/sql/index.js +13 -0
  75. package/demo/app/dev/plugin/main/api_dev_client/sql/param.json +31 -0
  76. package/demo/app/dev/plugin/main/api_dev_client/task/api.json +16 -0
  77. package/demo/app/dev/plugin/main/api_dev_client/task/index.js +13 -0
  78. package/demo/app/dev/plugin/main/api_dev_client/task/param.json +31 -0
  79. package/demo/app/dev/plugin/main/api_dev_client/translate/api.json +39 -0
  80. package/demo/app/dev/plugin/main/api_dev_client/translate/index.js +43 -0
  81. package/demo/app/dev/plugin/main/api_dev_client/translate/param.json +130 -0
  82. package/demo/app/dev/plugin/main/api_dev_client/translate/sql.json +62 -0
  83. package/demo/app/dev/plugin/main/api_dev_client/ui/api.json +10 -0
  84. package/demo/app/dev/plugin/main/api_dev_client/ui/index.js +146 -0
  85. package/demo/app/dev/plugin/main/api_dev_client/ui/param.json +31 -0
  86. package/demo/app/dev/plugin/main/api_dev_client/view/api.json +10 -0
  87. package/demo/app/dev/plugin/main/api_dev_client/view/index.js +100 -0
  88. package/demo/app/dev/plugin/main/api_dev_client/view/param.json +29 -0
  89. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/nav.vue +12 -0
  90. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/obj.vue +12 -0
  91. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/post.vue +12 -0
  92. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/query.vue +12 -0
  93. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/edit.vue +39 -0
  94. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/list.vue +12 -0
  95. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/search.vue +12 -0
  96. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/table.vue +12 -0
  97. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/type.vue +12 -0
  98. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/view.vue +56 -0
  99. package/demo/app/dev/plugin/main/api_dev_client/view/tpl/view.json +48 -0
  100. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/api.json +37 -0
  101. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/auto_db.js +120 -0
  102. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy.js +101 -0
  103. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy_framework.js +118 -0
  104. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy_template.js +78 -0
  105. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy_file.js +97 -0
  106. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/common.js +198 -0
  107. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/django_server.js +104 -0
  108. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/helper.js +161 -0
  109. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/koa_art_server.js +102 -0
  110. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/mini_app_home.js +415 -0
  111. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/razor.js +0 -0
  112. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/springboot.js +0 -0
  113. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/thinkphp.js +0 -0
  114. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/uni_app_home.js +418 -0
  115. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/vue_cli_admin.js +78 -0
  116. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/vue_cli_home.js +112 -0
  117. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create_file.js +97 -0
  118. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/add_data.js +221 -0
  119. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/create_table.js +162 -0
  120. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/set_auth_table.js +86 -0
  121. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/index.js +524 -0
  122. package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/param.json +37 -0
  123. package/demo/app/route/app.js +131 -0
  124. package/demo/app/route/app.json +11 -0
  125. package/demo/app/route/event_api/client/event.json +10 -0
  126. package/demo/app/route/event_api/client/main.js +19 -0
  127. package/demo/app/route/event_api/manage/event.json +18 -0
  128. package/demo/app/route/event_api/manage/main.js +70 -0
  129. package/demo/app/route/plugin/main/api_route_client/pass/api.json +37 -0
  130. package/demo/app/route/plugin/main/api_route_client/pass/index.js +33 -0
  131. package/demo/app/route/plugin/main/api_route_client/pass/param.json +50 -0
  132. package/demo/app/route/plugin/main/index.js +144 -0
  133. package/demo/app/route/plugin/main/plugin.json +20 -0
  134. package/demo/app/sys/event_api/api/event.json +1 -1
  135. package/demo/app/sys/event_api/doc/event.json +18 -0
  136. package/demo/app/sys/event_api/doc/main.js +67 -0
  137. package/demo/app/sys/event_api/img/event.json +11 -0
  138. package/demo/app/sys/event_api/img/main.js +90 -0
  139. package/demo/app/sys/event_api/web/event.json +4 -4
  140. package/demo/app/sys/plugin/app_admin/index.js +127 -0
  141. package/demo/app/sys/plugin/app_admin/plugin.json +20 -0
  142. package/demo/app/sys/plugin/main/api_client/config/sql.json +70 -0
  143. package/demo/app/sys/plugin/main/api_client/lang/api.json +37 -0
  144. package/demo/app/sys/plugin/main/api_client/lang/index.js +27 -0
  145. package/demo/app/sys/plugin/main/api_client/lang/param.json +22 -0
  146. package/demo/app/sys/plugin/main/api_client/translate/api.json +39 -0
  147. package/demo/app/sys/plugin/main/api_client/translate/index.js +21 -0
  148. package/demo/app/sys/plugin/main/api_client/translate/param.json +130 -0
  149. package/demo/app/sys/plugin/main/api_client/translate/sql.json +62 -0
  150. package/demo/app/sys/plugin/main/static/static.json +1 -1
  151. package/demo/app/sys/plugin/main/task/task_demo/index.js +37 -0
  152. package/demo/app/sys/plugin/main/task/task_demo/task.json +24 -0
  153. package/demo/app/sys/plugin/mqtt_engine/LICENSE +201 -0
  154. package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/api.json +33 -0
  155. package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/index.js +31 -0
  156. package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/param.json +130 -0
  157. package/demo/app/sys/plugin/mqtt_engine/index.js +51 -0
  158. package/demo/app/sys/plugin/mqtt_engine/mqtt/df/index.js +509 -0
  159. package/demo/app/sys/plugin/mqtt_engine/mqtt/df/mqtt.json +24 -0
  160. package/demo/app/sys/plugin/mqtt_engine/mqtt/zs/index.js +622 -0
  161. package/demo/app/sys/plugin/mqtt_engine/mqtt/zs/mqtt.json +36 -0
  162. package/demo/app/sys/plugin/mqtt_engine/plugin.json +21 -0
  163. package/demo/app/sys/plugin/mqtt_engine/static/img/logo.png +0 -0
  164. package/demo/app/sys/plugin/mqtt_engine/static/img/logo1.png +0 -0
  165. package/demo/app/sys/plugin/mqtt_engine/static/static.json +18 -0
  166. package/demo/app/sys/plugin/user/index.js +127 -0
  167. package/demo/app/sys/plugin/user/plugin.json +20 -0
  168. package/demo/app/sys/plugin/user/static/img/logo.png +0 -0
  169. package/demo/app/sys/plugin/user/static/static.js +28 -0
  170. package/demo/app/sys/plugin/user/static/static.json +20 -0
  171. package/demo/app/sys/static/img/avatar_1674484608066.png +0 -0
  172. package/demo/app/sys/static/img/avatar_1674633778171.jpeg +0 -0
  173. package/demo/app/sys/static/img/avatar_1674962702334.jpeg +0 -0
  174. package/demo/app/sys/static/img/avatar_1675075431736.jpeg +0 -0
  175. package/demo/app/sys/static/img/avatar_1675497065533.jpeg +0 -0
  176. package/demo/app/sys/static/img/avatar_1685352550990.jpeg +0 -0
  177. package/demo/app/sys/static/img/avatar_1685353685992.jpeg +0 -0
  178. package/demo/app/sys/static/img/avatar_1685353956587.jpeg +0 -0
  179. package/demo/app/sys/static/img/avatar_1685353971148.jpeg +0 -0
  180. package/demo/app/sys/static/img/avatar_1685353983723.jpeg +0 -0
  181. package/demo/app/sys/static/img/avatar_1685354014745.jpeg +0 -0
  182. package/demo/app/sys/static/img/avatar_1685354122355.jpeg +0 -0
  183. package/demo/app/sys/static/img/avatar_1685357983520.jpeg +0 -0
  184. package/demo/app/sys/static/img/avatar_1685358453383.jpeg +0 -0
  185. package/demo/app/sys/static/img/avatar_1685416570438.jpeg +0 -0
  186. package/demo/app/sys/static/img/avatar_1685512675830.png +0 -0
  187. package/demo/app/sys/static/img/avatar_1685939425608.jpeg +0 -0
  188. package/demo/app/sys/static/img/avatar_1685939886560.jpeg +0 -0
  189. package/demo/app/sys/static/img/avatar_1686106313194.png +0 -0
  190. package/demo/app/sys/static/img/avatar_1686371876175.png +0 -0
  191. package/demo/app/sys/static/img/avatar_1686372033596.png +0 -0
  192. package/demo/app/sys/static/img/avatar_1688215220669.png +0 -0
  193. package/demo/app/sys/static/img/avatar_1688531184690.png +0 -0
  194. package/demo/app/sys/static/img/avatar_1688531233080.png +0 -0
  195. package/demo/app/sys/static/img/avatar_1688548526909.png +0 -0
  196. package/demo/app/sys/static/img/avatar_1688549213411.png +0 -0
  197. package/demo/app/sys/static/img/avatar_1688549511977.png +0 -0
  198. package/demo/app/sys/static/img/avatar_1688549685464.png +0 -0
  199. package/demo/app/sys/static/img/avatar_1688608623049.png +0 -0
  200. package/demo/app/sys/static/img/avatar_1688638500476.png +0 -0
  201. package/demo/app/sys/static/img/avatar_1688638515195.png +0 -0
  202. package/demo/app/sys/static/img/avatar_1688638539928.png +0 -0
  203. package/demo/app/sys/static/img/avatar_1688638557960.png +0 -0
  204. package/demo/app/sys/static/img/avatar_1688638761798.png +0 -0
  205. package/demo/app/sys/static/img/avatar_1688638943140.png +0 -0
  206. package/demo/app/sys/static/img/avatar_1688639068330.png +0 -0
  207. package/demo/app/sys/static/img/image_1685357101273.jpeg +0 -0
  208. package/demo/app/sys/static/img/logo.png +0 -0
  209. package/demo/app/sys/static/static.js +28 -0
  210. package/demo/app/sys/static/static.json +20 -0
  211. package/demo/app/user/plugin/main/api_user_client/core/api.json +20 -0
  212. package/demo/app/user/plugin/main/api_user_client/core/forgot.js +14 -0
  213. package/demo/app/user/plugin/main/api_user_client/core/password.js +14 -0
  214. package/demo/app/user/plugin/main/api_user_client/core/sign_out.js +26 -0
  215. package/demo/app/user/plugin/main/api_user_client/core/state.js +21 -0
  216. package/demo/app/user/plugin/main/api_user_client/forgot/index - /345/211/257/346/234/254.jsbat" +41 -0
  217. package/demo/app/user/plugin/main/api_user_client/phone_code/index.js_ +230 -0
  218. package/demo/app/user/plugin/main/api_user_manage/account_base/api.json +37 -0
  219. package/demo/app/user/plugin/main/api_user_manage/account_base/index.js +40 -0
  220. package/demo/app/user/plugin/main/api_user_manage/account_base/param.json +130 -0
  221. package/demo/app/user/plugin/main/api_user_manage/invitation_code/api.json +37 -0
  222. package/demo/app/user/plugin/main/api_user_manage/invitation_code/index.js +106 -0
  223. package/demo/app/user/plugin/main/api_user_manage/invitation_code/param.json +130 -0
  224. package/demo/app/user/plugin/main/api_user_manage/update_team/api.json +35 -0
  225. package/demo/app/user/plugin/main/api_user_manage/update_team/index.js +218 -0
  226. package/demo/app/user/plugin/main/api_user_manage/update_team/param.json +130 -0
  227. package/demo/app/user/static/img/logo.png +0 -0
  228. package/demo/app/user/static/static.js +28 -0
  229. package/demo/app/user/static/static.json +20 -0
  230. package/demo/app/ws/app.js +122 -0
  231. package/demo/app/ws/app.json +11 -0
  232. package/demo/app/ws/event_api/client/event.json +10 -0
  233. package/demo/app/ws/event_api/client/main.js +17 -0
  234. package/demo/app/ws/socket/ws/index.js +43 -0
  235. package/demo/app/ws/socket/ws/socket.json +14 -0
  236. package/demo/config/face.sql +3824 -0
  237. package/demo/config/local.json +2 -2
  238. package/demo/config/test.json +2 -2
  239. package/index.js +2 -2
  240. package/package.json +2 -2
  241. /package/core/com/{api → rpc}/rpc.js +0 -0
@@ -1,7 +1,7 @@
1
- const Item = require('mm_machine').Item;
2
-
3
1
  const fs = require("fs");
4
2
  const send = require('koa-send');
3
+ const conf = require('mm_config');
4
+ const Item = require('mm_machine').Item;
5
5
 
6
6
  /**
7
7
  * Plugin插件驱动类
@@ -15,10 +15,11 @@ class Drive extends Item {
15
15
  * @param {Object} config 配置
16
16
  * @constructor
17
17
  */
18
- constructor(dir, config) {
18
+ constructor(dir) {
19
19
  super(dir, __dirname);
20
20
  this.default_file = "./static.json";
21
-
21
+ // 更新并重载
22
+ this.mode = 3;
22
23
  /* 通用项 */
23
24
  // 配置参数
24
25
  this.config = {
@@ -57,29 +58,6 @@ class Drive extends Item {
57
58
  // 是否将ES6转换AMD
58
59
  "convert_amd": true
59
60
  };
60
-
61
- this.init(config);
62
- }
63
- }
64
-
65
- Drive.prototype.init = function(config) {
66
- if (config) {
67
- $.push(this.config, config);
68
- this.dir = config.root.fullname();
69
- var f = this.default_file.fullname(this.dir);
70
- if (f.hasFile()) {
71
- var obj = f.loadJson();
72
- if (obj) {
73
- this.loadObj(obj);
74
- } else {
75
- var text = "./config.tpl.json".loadText(__dirname);
76
- text = text.replace('"path": "/"', '"path": "' + config.path + '"');
77
- f.saveText(text);
78
- }
79
- }
80
- }
81
- if (this.config.convert_amd) {
82
- this.run_mode(true);
83
61
  }
84
62
  }
85
63
 
@@ -89,36 +67,17 @@ Drive.prototype.init = function(config) {
89
67
  Drive.prototype.send = send;
90
68
 
91
69
  /**
92
- * 加载配置对象
93
- * @param {Object} obj 配置对象
70
+ * 加载配置对象前
71
+ * @param {Object} config 配置对象
94
72
  */
95
- Drive.prototype.loadObj = function(obj) {
96
- if (obj.maxAge) {
97
- obj.maxAge *= 1000;
98
- }
99
- $.push(this.config, obj, true);
100
- var cg = this.config;
101
- if (cg.convert_amd) {
102
- this.run_mode(true);
103
- }
104
- var f = cg.func_file;
105
- if (f) {
106
- var file = f.fullname(this.dir);
107
- if (file.hasFile()) {
108
- var cs = require(file);
109
- if (cs) {
110
- var name = cg.func_name;
111
- if (name) {
112
- this.main = cs[name];
113
- } else {
114
- $.push(this, cs);
115
- }
116
- }
117
- } else {
118
- var fl = __dirname + "/script.js";
119
- fl.copyFile(file);
73
+ Drive.prototype.set_config = function(config) {
74
+ if (config) {
75
+ if (config.maxAge) {
76
+ config.maxAge *= 1000;
120
77
  }
121
78
  }
79
+ this.config = conf(Object.assign({}, this.config, config || {}), this.filename);
80
+ this.run_mode(this.config.convert_amd);
122
81
  };
123
82
 
124
83
  /**
@@ -21,6 +21,9 @@ class Static extends Index {
21
21
  constructor(scope, title) {
22
22
  super(scope, __dirname);
23
23
  this.Drive = Drive;
24
+
25
+ // 更新并重载
26
+ this.mode = 3;
24
27
  this.type = "static";
25
28
  this.title = title;
26
29
  var $this = this;
@@ -87,7 +90,7 @@ class Static extends Index {
87
90
  * @param {Object} dir 目录
88
91
  * @return {Drive} 静态文件驱动类
89
92
  */
90
- Static.prototype.getObj = function(dir) {
93
+ Static.prototype.getObj = async function(dir) {
91
94
  var d = join(dir).replace(process.cwd() + $.slash, '/');
92
95
  var app = d.between(join('app/'), join('/'));
93
96
  var plugin = d.between(join('/plugin/'), join('/'));
@@ -101,14 +104,18 @@ Static.prototype.getObj = function(dir) {
101
104
  root: d.substring(0, d.length - 1).fullname(),
102
105
  path: path
103
106
  };
104
- return new Drive(dir, obj);
107
+ var file = ("./" + this.type + ".json").fullname(obj.root);
108
+ var drive = new Drive(dir, obj);
109
+ await drive.exec('load_config', file);
110
+ await drive.exec('set_config', obj);
111
+ return drive
105
112
  };
106
113
 
107
114
  /**
108
115
  * 加载接口
109
116
  * @param {String} path 加载的路径
110
117
  */
111
- Static.prototype.load = function(path) {
118
+ Static.prototype.update_config_all = async function(path) {
112
119
  if (!path) {
113
120
  path = $.runPath + 'app' + $.slash;
114
121
  }
@@ -117,10 +124,11 @@ Static.prototype.load = function(path) {
117
124
  var list_scope = $.dir.getAll(path, search_dir);
118
125
  // 遍历目录路径
119
126
  var _this = this;
120
- list_scope.map(function(o) {
121
- var obj = _this.getObj(o);
127
+ for (var i = 0; i < list_scope.length; i++) {
128
+ var dir = list_scope[i];
129
+ var obj = await _this.getObj(dir);
122
130
  _this.list.push(obj);
123
- });
131
+ }
124
132
  };
125
133
 
126
134
  /**
@@ -42,7 +42,10 @@ class Drive extends Item {
42
42
  constructor(dir) {
43
43
  super(dir, __dirname);
44
44
  this.default_file = "./task.json";
45
-
45
+
46
+ // 更新配置并重载脚本
47
+ this.mode = 3;
48
+
46
49
  /// 配置参数
47
50
  this.config = {
48
51
  // 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
@@ -299,7 +302,9 @@ Drive.prototype.run = async function(func) {
299
302
  if (func) {
300
303
  await this.setInterval(this.setPeriod(this.setNum(func)));
301
304
  } else {
302
- await this.setInterval(this.setPeriod(this.setNum(this.main)));
305
+ await this.setInterval(this.setPeriod(this.setNum(() => {
306
+ this.main();
307
+ })));
303
308
  }
304
309
  return this;
305
310
  };
@@ -18,6 +18,8 @@ class Task extends Index {
18
18
  this.Drive = Drive;
19
19
  this.type = "task";
20
20
  this.title = title;
21
+ // 更新配置并重载脚本
22
+ this.mode = 3;
21
23
  }
22
24
  }
23
25
 
@@ -31,7 +33,7 @@ Task.prototype.run = async function(name) {
31
33
  for (var i = 0, o; o = lt[i++];) {
32
34
  if (o.config.state === 1 && o.config.name === name) {
33
35
  try {
34
- o.run();
36
+ await o.run();
35
37
  } catch (error) {
36
38
  $.log.error("定时任务错误", o.name, error);
37
39
  }
@@ -42,7 +44,7 @@ Task.prototype.run = async function(name) {
42
44
  for (var i = 0, o; o = lt[i++];) {
43
45
  if (o.config.state === 1) {
44
46
  try {
45
- o.run();
47
+ await o.run();
46
48
  } catch (error) {
47
49
  $.log.error("定时任务错误", o.name, error);
48
50
  }
@@ -57,44 +59,22 @@ Task.prototype.run = async function(name) {
57
59
  * @param {Object} cg 配置参数
58
60
  * @param {String} file 配置文件
59
61
  */
60
- Task.prototype.load_item = function(dir, cg, file) {
61
- var drive = new this.Drive(dir);
62
- drive.loadObj(cg);
63
- drive.filename = file;
62
+ Task.prototype.load_item = async function(dir, cg, file) {
64
63
  var _this = this;
64
+ var drive = new this.Drive(dir, this.dir_base.fullname());
65
+ drive.mode = this.mode;
66
+ if (cg) {
67
+ await drive.exec('load_config', file, cg.name);
68
+ await drive.exec('set_config', cg);
69
+ } else {
70
+ await drive.exec('load_config', file);
71
+ }
72
+
65
73
  drive.admin = function() {
66
- return this;
74
+ return _this;
67
75
  };
68
76
  this.list.push(drive);
69
- };
70
-
71
- /**
72
- * 加载列表
73
- * @param {Array} list 文件列表
74
- */
75
- Task.prototype.load_list = function(list) {
76
- var _this = this;
77
- // 遍历文件路径
78
- list.map(function(file) {
79
- var dir = file.dirname();
80
- // 载入文件
81
- var obj = file.loadJson(dir);
82
- if (obj) {
83
- if (obj.constructor == Array) {
84
- obj.map(function(o) {
85
- // 实例化一个驱动
86
- _this.load_item(dir, o, file);
87
- });
88
- } else {
89
- _this.load_item(dir, obj, file);
90
- }
91
- } else {
92
- var fl = _this.dir_base + "/config.tpl.json";
93
- if (fl.hasFile()) {
94
- fl.copyFile(file);
95
- }
96
- }
97
- });
77
+ return drive;
98
78
  };
99
79
 
100
80
  exports.Task = Task;
@@ -8,11 +8,11 @@ class Controller extends Base {
8
8
  super();
9
9
 
10
10
  // 检索的文件路径
11
- this.path = "./apps/controller".fullname();
11
+ this.path = "./app/controller".fullname();
12
12
  // 文件拓展名
13
13
  this.extension = "controller.json";
14
14
  // 文件存放目录
15
- this.dir = "./apps";
15
+ this.dir = "./app";
16
16
  }
17
17
  }
18
18
 
@@ -0,0 +1,19 @@
1
+ [{
2
+ // 目标对象
3
+ "target": "/apis/dev*",
4
+ // 事件名称, 用于动态增删改
5
+ "name": "dev_manage",
6
+ // 标题, 用于开发者查看事件
7
+ "title": "示例事件",
8
+ // 描述, 用于介绍该事件是做什么用的
9
+ "description": "描述事件使用方法",
10
+ // 阶段, 分执行前before、验证check、主要main、渲染render、执行后after阶段
11
+ "stage": "main",
12
+ "state": 1,
13
+ // 响应方法 GET请求、POST请求、ALL所有请求,如果非API事件可自定义
14
+ "method": "ALL",
15
+ // 函数文件, 当事件触发时执行指定的脚本
16
+ "func_file": "./main.js",
17
+ // 执行顺序, 数值越小越优先执行
18
+ "sort": 100
19
+ }]
@@ -0,0 +1,26 @@
1
+ // 使用api管理器
2
+ var api = $.api_admin('dev_manage', 'dev_manage');
3
+ // 首次启动更新api接口;
4
+ api.update();
5
+
6
+ // 使用mysql数据库管理器
7
+ var sql = $.mysql_admin('sys', __dirname);
8
+ // sql.setConfig($.config.mysql);
9
+ // sql.open();
10
+
11
+ /**
12
+ * @description 接口主函数
13
+ * @param {Object} ctx HTTP上下文
14
+ * @param {Object} db 数据管理器,如: { next: async function{}, ret: {} }
15
+ * @return {Object} 执行结果
16
+ */
17
+ async function main(ctx, db) {
18
+ // 使用模板引擎
19
+ db.tpl = new $.Tpl();
20
+
21
+ // 在这定义要访问的数据库 (分布式开发时设置不同的数据库名)
22
+ $.push(db, sql.db(), true);
23
+ return api.run(ctx, db);
24
+ };
25
+
26
+ exports.main = main;
@@ -0,0 +1,144 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
+ <meta http-equiv="x-dns-prefetch-control" content="on">
8
+ <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
9
+ <meta name="format-detection" content="telephone=no">
10
+ <meta name="apple-mobile-web-app-capable" content="yes">
11
+ <meta name="apple-mobile-web-app-status-bar-style" content="black">
12
+ <meta name="description" content="这是web API文档">
13
+ <meta name="keywords" content="开发文档">
14
+ <meta name="author" content="邱文武">
15
+
16
+ <!-- 加载CSS样式 -->
17
+ <link rel="stylesheet" href="/css/font-awesome.min.css" async />
18
+ <link rel="stylesheet" href="/css/mm_base.css" async />
19
+ <link rel="stylesheet" href="/css/mm_layout.css" async />
20
+ <link rel="stylesheet" href="/css/mm_common.css" async />
21
+ <link rel="stylesheet" href="/css/mm_component.css" async />
22
+ <link rel="stylesheet" href="/css/mm_theme.css" async />
23
+
24
+ <!-- 加载JS脚本 -->
25
+ <script src="/js/jquery.min.js"></script>
26
+ <script src="/js/clipboard.min.js" async></script>
27
+ <script src="/js/vue.js"></script>
28
+ <script src="/js/mm_sdk.js"></script>
29
+
30
+ <title>接口列表</title>
31
+ <style>
32
+ body {
33
+ background: #fff;
34
+ }
35
+
36
+ main {
37
+ padding: 2rem;
38
+ }
39
+
40
+ #app h4 {
41
+ padding-bottom: 0.5rem;
42
+ border-bottom: 1px solid rgba(125, 125, 125, 0.25);
43
+ margin-bottom: 1rem;
44
+ }
45
+
46
+ .scope_list {
47
+ padding-left: 2rem;
48
+ }
49
+
50
+ .desc {
51
+ margin-bottom: 2rem;
52
+ }
53
+
54
+ .mm_btn {
55
+ border: 1px solid var(--color_border);
56
+ }
57
+
58
+ h4 a {
59
+ font-size: 0.875rem;
60
+ padding-top: 0.5rem;
61
+ }
62
+ </style>
63
+ </head>
64
+ <body>
65
+ <div id="app">
66
+ <div class="mm_page">
67
+ <main>
68
+ <div class="mm_warp">
69
+ <h4>API接口文档 —— <span>列表</span> <a class="fr" href="./">选择域</a></h4>
70
+ <p class="desc">所有的API接口都作用在不同的域下,您可以点击以下域,访问该域下的接口列表</p>
71
+ <table class="mm_table table-hover" v-if="list.length">
72
+ <thead>
73
+ <tr>
74
+ <th>#</th>
75
+ <th width="200">名称</th>
76
+ <th width="200">标题</th>
77
+ <th>描述</th>
78
+ <th width="80">操作</th>
79
+ </tr>
80
+ </thead>
81
+ <tbody>
82
+ <tr v-for="(o, k) in list" :key="k">
83
+ <th>{{ k + 1 }}</th>
84
+ <td><a :href="'./api_view.html?scope=' + query.scope + '&name=' + o.name">{{ o.name }}</a></td>
85
+ <td>{{ o.title }}</td>
86
+ <td>{{ o.description }}</td>
87
+ <td><a class="mm_btn btn_info-x" :href="'./api_view.html?scope=' + query.scope + '&name=' + o.name">查看</a></td>
88
+ </tr>
89
+ </tbody>
90
+ </table>
91
+ <div v-else class="desc center">
92
+ 该域下没有定义API接口
93
+ </div>
94
+ </div>
95
+ </main>
96
+ </div>
97
+ </div>
98
+ <script>
99
+ var vue = new Vue({
100
+ el: '#app',
101
+ data() {
102
+ return {
103
+ url: "/api/dev_api?",
104
+ query: {
105
+ scope: "client"
106
+ },
107
+ list: []
108
+ }
109
+ },
110
+ methods: {
111
+ get_list() {
112
+ var _this = this;
113
+ $.http.get(this.url + $.toUrl(this.query), function(json, status) {
114
+ _this.get_list_after(json);
115
+ });
116
+ },
117
+ get_list_after(json) {
118
+ if (json.result) {
119
+ var list = this.list;
120
+ list.clear();
121
+ list.addList(json.result.list);
122
+ }
123
+ }
124
+ },
125
+ created() {
126
+ var arr = location.search.split("&");
127
+ var len = arr.length;
128
+ if (len > 0) {
129
+ for (var i = 0; i < len; i++) {
130
+ var o = arr[i];
131
+ if (o.indexOf('scope') !== -1) {
132
+ var ar = o.split("=");
133
+ if (ar.length > 1) {
134
+ this.query.scope = ar[1];
135
+ }
136
+ };
137
+ }
138
+ }
139
+ this.get_list();
140
+ }
141
+ });
142
+ </script>
143
+ </body>
144
+ </html>