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
@@ -0,0 +1,118 @@
1
+ const {
2
+ join
3
+ } = require("path");
4
+
5
+ const copy = require("./copy.js");
6
+
7
+ /**
8
+ * @description 复制框架
9
+ * @param {Object} model 数据模型
10
+ * @return {Object} 输出框架
11
+ */
12
+ async function copy_framework(model) {
13
+ $.log.info("******** 开始复制框架 ********");
14
+
15
+ // 取出模型数据
16
+ var {
17
+ order,
18
+ filter,
19
+ to,
20
+ from_fk
21
+ } = model;
22
+
23
+ // 获取UI,获取模式,服务端样式,客户端样式
24
+ var {
25
+ tpl_home,
26
+ tpl_admin,
27
+ mode,
28
+ ui,
29
+ fk_server,
30
+ fk_client
31
+ } = order;
32
+
33
+ // 判断渲染对象模式类型
34
+ if (mode == "MVC") {
35
+ // 选择服务端框架
36
+ fk_server = order.framework;
37
+ } else if (mode == "MVVM") {
38
+ // 获取订单语言
39
+ var lang = order.lang;
40
+
41
+ // 选择服务端框架 注:在MVVM模式 服务端根据语言获取
42
+ fk_server = await get_framework(lang);
43
+
44
+ // 选择客户端框架 注:在MVVM模式 框架用于获取客户端
45
+ switch (order.framework) {
46
+ case "vue_cli":
47
+ fk_client = "vue_cli";
48
+ break;
49
+
50
+ case "uni_app":
51
+ fk_client = "uni_app";
52
+ break;
53
+
54
+ case "mini_app":
55
+ fk_client = "mini_app";
56
+ break;
57
+ }
58
+ }
59
+
60
+ // 初始化服务端路径
61
+ var _from = from_fk + fk_server;
62
+ await copy(_from, to, filter);
63
+
64
+ // MVVM客户端后台
65
+ if (mode === "MVVM") {
66
+ if(fk_client && tpl_admin){
67
+ // 获取客户端路径vue_cli
68
+ _from = join(from_fk, "vue_cli/client_admin/");
69
+ _from = _from.fullname();
70
+ await copy(_from, to + "/client_admin/", filter);
71
+
72
+ // 存在 客户端 并且存在 前端模板
73
+ if (fk_client && tpl_home) {
74
+ // 获取客户端路径
75
+ _from = from_fk + fk_client + "/client_home/";
76
+ _from = _from.fullname();
77
+ await copy(_from, to + "/client_home/", filter);
78
+ }
79
+ }
80
+ }
81
+
82
+ $.log.info("******** 结束复制框架 ********");
83
+ // 输出
84
+ return {
85
+ fk_server,
86
+ fk_client
87
+ };
88
+ }
89
+
90
+ /**
91
+ * @description 获取框架
92
+ * @param {Object} lang 语言
93
+ */
94
+ async function get_framework(lang) {
95
+ var fk = "";
96
+ // 判断渲染语言框架
97
+ switch (lang) {
98
+ case "python":
99
+ fk = "django";
100
+ break;
101
+ case "nodejs":
102
+ fk = "koa_art";
103
+ break;
104
+ case "asp.net":
105
+ case "csharp":
106
+ fk = "razor";
107
+ break;
108
+ case "php":
109
+ fk = "thinkphp";
110
+ break;
111
+ case "java":
112
+ fk = "springboot";
113
+ break;
114
+ }
115
+ return fk;
116
+ }
117
+
118
+ module.exports = copy_framework;
@@ -0,0 +1,78 @@
1
+ const {
2
+ join
3
+ } = require("path");
4
+
5
+ const copy = require("./copy.js");
6
+
7
+ /**
8
+ * @description 复制模板
9
+ * @param {Object} model 数据模型
10
+ * @return {Object} 输出模板
11
+ */
12
+ async function copy_template(model) {
13
+ $.log.info("******** 开始复制模板 ********");
14
+
15
+ // 取出模型数据
16
+ var {
17
+ order,
18
+ filter,
19
+ to,
20
+ from_te
21
+ } = model;
22
+
23
+ // 前台模板,后台模板,模式,UI,程序框架
24
+ var {
25
+ tpl_home,
26
+ tpl_admin,
27
+ mode,
28
+ ui,
29
+ framework
30
+ } = order;
31
+
32
+ // 判断后台模板是否需要
33
+ if (tpl_admin) {
34
+ var _from = "";
35
+ var _to = "";
36
+ if (mode == "MVVM" || framework == "vue_cli") {
37
+ // 后台模板路径
38
+ _from = from_te + "vue_cli/admin/" + tpl_admin + "/default";
39
+ // 传出路径
40
+ _to = to + "/client_admin";
41
+ } else {
42
+ // 后台模板路径
43
+ _from = from_te + framework + "/admin/" + tpl_admin + "/default";
44
+ // 传出路径
45
+ _to = to + "/server";
46
+ }
47
+ _from = _from.fullname();
48
+ _to = _to.fullname();
49
+ _to.addDir(__dirname);
50
+ await copy(_from, _to, filter);
51
+ }
52
+
53
+ // 判断前台模板是否需要
54
+ if (tpl_home) {
55
+ // 前台模板路径
56
+ var _from = from_te + framework + "/home/" + tpl_home + "/default";
57
+ var _to = "";
58
+ // 确认模式
59
+ if (mode == "MVVM") {
60
+ _to = to + "/client_home";
61
+
62
+ } else {
63
+ _to = to + "/server";
64
+ }
65
+ _from = _from.fullname();
66
+ _to = _to.fullname();
67
+ _to.addDir(__dirname);
68
+ await copy(_from, _to, filter);
69
+ }
70
+
71
+ $.log.info("******** 结束复制模板 ********");
72
+ return {
73
+ tpl_home,
74
+ tpl_admin
75
+ };
76
+ }
77
+
78
+ module.exports = copy_template;
@@ -0,0 +1,97 @@
1
+ // 加载复制框架
2
+ const copy_framework = require("./copy/copy_framework.js");
3
+
4
+ // 加载复制模板
5
+ const copy_template = require("./copy/copy_template.js");
6
+
7
+ // 项目存放根
8
+ var to = "../project/";
9
+
10
+ // 模板来源根
11
+ const from_te = "../template/";
12
+
13
+ // 框架来源根
14
+ const from_fk = "../framework/";
15
+
16
+ // 初始化过滤
17
+ const filter = [".git", "node_modules", ".gitattributes", ".gitignore", "README.en.md", "README.md"];
18
+
19
+ /**
20
+ * 第二步,复制文件
21
+ * @param {Object} db 数据库管理
22
+ * @param {Object} model 模型
23
+ */
24
+ async function copy_file(db, model) {
25
+ $.log.info("******** 开始复制 ********");
26
+
27
+ // 附加过滤
28
+ var _filter = [...model.filter_admin];
29
+ _filter.addList(filter);
30
+
31
+ // 取出订单
32
+ var order = model.order;
33
+
34
+ // 生成项目地址
35
+ var _to = to + order.order_number;
36
+ _to.addDir(__dirname);
37
+
38
+ // 建立框架模型
39
+ var vm_fk = Object.assign({}, {
40
+ order,
41
+ "filter": _filter,
42
+ from_fk,
43
+ "to": _to
44
+ })
45
+
46
+ // 执行复制框架
47
+ var obj = await copy_framework(vm_fk);
48
+
49
+ // 取出服务端和客户端
50
+ var {
51
+ fk_server,
52
+ fk_client
53
+ } = obj;
54
+
55
+ // 获取框架
56
+ model.fk_server = obj.fk_server;
57
+ model.fk_client = obj.fk_client;
58
+
59
+ // 建立模板模型
60
+ var vm_te = Object.assign({}, {
61
+ order,
62
+ "filter": _filter,
63
+ from_te,
64
+ "to": _to
65
+ })
66
+
67
+ // 执行复制模板
68
+ await copy_template(vm_te);
69
+
70
+ $.log.info("******** 结束复制 ********");
71
+ }
72
+
73
+ /**
74
+ * 克隆数组
75
+ * @param {Array} 数组
76
+ * @param {Array} 数组集
77
+ * return {Array}
78
+ */
79
+ function arrClone(arr = [], ...arrs) {
80
+ // 序列化 反序列化
81
+ var ar = JSON.parse(JSON.stringify(arr));
82
+
83
+ // 判断数组集是否存在
84
+ if (arrs) {
85
+ for (var i = 0; i < arrs.length; i++) {
86
+ var arr2 = arrs[i];
87
+ // 序列化 反序列化
88
+ var ar2 = JSON.parse(JSON.stringify(arr2));
89
+ // 加入数组
90
+ ar.push(...ar2);
91
+ }
92
+ }
93
+
94
+ return ar;
95
+ }
96
+
97
+ module.exports = copy_file;
@@ -0,0 +1,198 @@
1
+ const {
2
+ tpl_dir,
3
+ tpl_file,
4
+ isExist,
5
+ get_vm
6
+ } = require("./helper.js");
7
+
8
+ class Common {
9
+ /**
10
+ * 构造函数
11
+ * @param {Object} config 配置参数
12
+ */
13
+ constructor(config) {
14
+ /**
15
+ * 配置参数
16
+ */
17
+ this.config = Object.assign({
18
+ // 模板路径
19
+ dir_form: "",
20
+ // 生成文件路径
21
+ dir_to: "",
22
+ // 模式
23
+ mode: "MVVM"
24
+ }, config);
25
+ }
26
+ }
27
+
28
+ Common.prototype.tpl_dir = tpl_dir;
29
+ Common.prototype.tpl_file = tpl_file;
30
+ Common.prototype.isExist = isExist;
31
+ Common.prototype.get_vm = get_vm;
32
+
33
+ /**
34
+ * 渲染页面,用于遍历时
35
+ * @param {Object} model 数据模型
36
+ * @param {String} form 来源模板地址
37
+ * @param {String} to 生成存放地址
38
+ * @return {String} 成功返回null, 失败模板地址
39
+ */
40
+ Common.prototype.render_sub = function(model, form, to) {
41
+ var ret = "";
42
+
43
+ // 渲染模板路径
44
+ form = form.fullname();
45
+
46
+ // 保存文件路径
47
+ to = to.fullname();
48
+
49
+ // 渲染模型
50
+ var html = tpl.view(form, model);
51
+
52
+ // 结果判断
53
+ if (!html) {
54
+ console.error("模板渲染错误", form, tpl.error);
55
+ return;
56
+ }
57
+
58
+ // 生成文件目录
59
+ to.addDir();
60
+
61
+ // 生成页面
62
+ to.saveText(html);
63
+
64
+ return null;
65
+ };
66
+
67
+ /**
68
+ * 渲染
69
+ * @param {Object} model 数据模型
70
+ * @return {Object} 成功返回null, 失败返回错误信息
71
+ */
72
+ Common.prototype.render = function(model) {
73
+ var error;
74
+
75
+ // 从 模型 中取出 订单 表集
76
+ var {
77
+ tables
78
+ } = model;
79
+
80
+ // 渲染页面集
81
+ if (tables) {
82
+ for (var i = 0; i < tables.length; i++) {
83
+ error = this.render_sub(model, tables[i]);
84
+ if (error) {
85
+ break
86
+ }
87
+ }
88
+ }
89
+
90
+ // 渲染模板模型
91
+ var {
92
+ dir_form,
93
+ dir_to
94
+ } = this.config;
95
+ this.tpl_dir(model, dir_form, dir_to);
96
+ return error;
97
+ }
98
+
99
+ /**
100
+ * 转换字段
101
+ * @param {Object} model 模型
102
+ * @param {Object} table 表模型
103
+ * @param {Object} field 字段模型
104
+ * @return {Object} 成功返回null, 失败返回错误信息
105
+ */
106
+ Common.prototype.change_field = function(model, table, field) {
107
+ var exp = field.compute;
108
+ var list = table.fields_sort;
109
+ for(var i = 0; i < list.length; i++){
110
+ exp = exp.replaceAll(list[i].title, "form['" + list[i].name + "']");
111
+ }
112
+ field.exp = exp;
113
+ };
114
+
115
+ /**
116
+ * 转换表
117
+ * @param {Object} model 模型
118
+ * @param {Object} table 表模型
119
+ * @return {Object} 成功返回null, 失败返回错误信息
120
+ */
121
+ Common.prototype.change_table = function(model, table) {
122
+ var {
123
+ fields
124
+ } = table;
125
+
126
+ // 转换字段
127
+ for (var i = 0; i < fields.length; i++) {
128
+ this.change_field(model, table, fields[i]);
129
+ }
130
+ };
131
+
132
+ /**
133
+ * 转换
134
+ * @param {Object} model 模型
135
+ * @return {Object} 成功返回null, 失败返回错误信息
136
+ */
137
+ Common.prototype.change = function(model) {
138
+ var {
139
+ tables
140
+ } = model;
141
+
142
+ // 转换表
143
+ for (var i = 0; i < tables.length; i++) {
144
+ this.change_table(model, tables[i]);
145
+ }
146
+ };
147
+
148
+ /**
149
+ * 过滤
150
+ * @param {Object} model 模型
151
+ * @return {Object} 成功返回null, 失败返回错误信息
152
+ */
153
+ Common.prototype.filter = function(model) {
154
+
155
+ };
156
+
157
+ /**
158
+ * 执行创建主函数
159
+ * @param {Object} model 模型
160
+ * @return {Object} 成功返回null, 失败返回错误信息
161
+ */
162
+ Common.prototype.main = function(model) {
163
+ var error;
164
+ // 1.过滤
165
+ error = this.filter(model);
166
+ if (error) {
167
+ return error;
168
+ }
169
+
170
+ // 2.转换
171
+ error = this.change(model);
172
+ if (error) {
173
+ return error;
174
+ }
175
+
176
+ // 3.渲染
177
+ error = this.render(model);
178
+ if (error) {
179
+ return error;
180
+ }
181
+ };
182
+
183
+
184
+ /**
185
+ * 执行创建 (封装函数时调用该函数)
186
+ * @param {Object} model 模型
187
+ * @return {Object} 成功返回null, 失败返回错误信息
188
+ */
189
+ Common.prototype.run = function(model) {
190
+ var error = this.main(model);
191
+ if (error) {
192
+ return error
193
+ } else {
194
+ return $.ret.bl(true, "渲染成功!");
195
+ }
196
+ };
197
+
198
+ module.exports = Common;
@@ -0,0 +1,104 @@
1
+ var tpl = new $.Tpl();
2
+
3
+ //
4
+ tpl.config.root = "";
5
+
6
+ /**
7
+ * @description 创建koa_art模板
8
+ * @param {Objact} model 模型
9
+ */
10
+ async function create_django(model) {
11
+ $.log.info("***** 开始刷Django服务端 *****");
12
+
13
+ // 从 模型 中取出 订单 表集
14
+ var {
15
+ order,
16
+ tables
17
+ } = model;
18
+
19
+ // 取出订单号 注:用于保存
20
+ var order_number = order.order_number;
21
+
22
+ // 模板路径
23
+ var dir_server = "../template/django/server/app/";
24
+
25
+ // 存放路径
26
+ var dir_save = "../project/" + order_number + "/server/app/";
27
+
28
+ // 存放服务路径
29
+ var dir_service = dir_server + "services/service.py";
30
+
31
+ // 存放控制器路径
32
+ var dir_controller = dir_server + "views/controller.py";
33
+
34
+ // 循环表集
35
+ for (var i = 0; i < tables.length; i++) {
36
+ // 取出表
37
+ var table = tables[i];
38
+
39
+ // 取出表名和表标题
40
+ var {name, title, formula} = table;
41
+
42
+ // 判断是否存在
43
+ if (name && title) {
44
+ // 服务名
45
+ var cs = name.charAt(0).toUpperCase() + name.slice(1);
46
+
47
+ // 模型
48
+ var vm = {
49
+ table,
50
+ title,
51
+ name,
52
+ formula,
53
+ cs
54
+ };
55
+
56
+ // 渲染服务
57
+ tpl_file(vm, dir_service, dir_save + "services/" + name + ".py");
58
+
59
+ // 渲染控制器
60
+ tpl_file(vm, dir_controller, dir_save + "views/" + name + ".py");
61
+ }
62
+ }
63
+
64
+ // 渲染数据库绑定
65
+ tpl_file({
66
+ order_number
67
+ }, dir_server + "settings.py", dir_save + "settings.py");
68
+
69
+ $.log.info("***** 结束刷Django服务端 *****")
70
+ }
71
+
72
+ /**
73
+ * @description 渲染模板
74
+ * @param {Object} model 数据模型
75
+ * @param {String} _from 模板路径
76
+ * @param {String} _to 存储路径
77
+ */
78
+ function tpl_file(model, _from, _to) {
79
+ var ret = "";
80
+ // 渲染模板路径
81
+ _from = _from.fullname();
82
+
83
+ // 保存文件路径
84
+ _to = _to.fullname();
85
+
86
+ // 渲染模型
87
+ var html = tpl.view(_from, model);
88
+
89
+ // 结果判断
90
+ if (!html) {
91
+ console.error("模板渲染错误", _to, tpl.error);
92
+ return ret;
93
+ }
94
+
95
+ // 生成文件目录
96
+ _to.addDir();
97
+
98
+ // 生成页面
99
+ _to.saveText(html);
100
+
101
+ return _to;
102
+ }
103
+
104
+ module.exports = create_django;