mm_os 1.3.4 → 1.3.6

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 (368) hide show
  1. package/README.en.md +36 -0
  2. package/README.md +25 -166
  3. package/conf.json +3 -0
  4. package/core/base/index.js +29 -0
  5. package/core/base/mqtt/index.js +268 -0
  6. package/core/base/mqtt/lib.js +40 -0
  7. package/core/base/web/index.js +110 -0
  8. package/core/com/api/com.json +4 -0
  9. package/{bin → core}/com/api/config.tpl.json +9 -7
  10. package/{bin → core}/com/api/drive.js +239 -64
  11. package/{bin → core}/com/api/index.js +8 -9
  12. package/{bin → core}/com/api/oauth.js +23 -14
  13. package/core/com/api/script.js +32 -0
  14. package/core/com/db/com.json +4 -0
  15. package/{bin → core}/com/db/drive.js +99 -65
  16. package/{bin → core}/com/db/index.js +2 -2
  17. package/core/com/event/com.json +4 -0
  18. package/{bin → core}/com/event/config.tpl.json +2 -2
  19. package/core/com/event/drive.js +125 -0
  20. package/{bin → core}/com/event/index.js +5 -10
  21. package/core/com/event/script.js +26 -0
  22. package/core/com/eventer/com.js +450 -0
  23. package/core/com/eventer/com.json +4 -0
  24. package/core/com/middleware/com.js +128 -0
  25. package/core/com/middleware/com.json +4 -0
  26. package/core/com/middleware/config.tpl.json +8 -0
  27. package/core/com/middleware/script.js +9 -0
  28. package/core/com/mqtt/com.json +4 -0
  29. package/core/com/mqtt/config.tpl.json +12 -0
  30. package/core/com/mqtt/drive.js +139 -0
  31. package/core/com/mqtt/index.js +138 -0
  32. package/core/com/mqtt/script.js +33 -0
  33. package/core/com/msg/com.js +296 -0
  34. package/core/com/msg/com.json +4 -0
  35. package/{bin → core}/com/nav/drive.js +42 -17
  36. package/{bin → core}/com/nav/index.js +4 -4
  37. package/core/com/nav/tpl/admin_pc/page_channel.vue +299 -0
  38. package/core/com/nav/tpl/admin_pc/page_config.vue +279 -0
  39. package/core/com/nav/tpl/admin_pc/page_config_form.vue +194 -0
  40. package/core/com/nav/tpl/admin_pc/page_default.vue +287 -0
  41. package/core/com/nav/tpl/admin_pc/page_form.vue +180 -0
  42. package/core/com/nav/tpl/admin_pc/page_lang.vue +265 -0
  43. package/core/com/nav/tpl/admin_pc/page_nav.vue +313 -0
  44. package/core/com/nav/tpl/admin_pc/page_table.vue +285 -0
  45. package/core/com/nav/tpl/admin_pc/page_type.vue +313 -0
  46. package/core/com/nav/tpl/dev_pc/page_channel.vue +253 -0
  47. package/core/com/nav/tpl/dev_pc/page_config.vue +253 -0
  48. package/core/com/nav/tpl/dev_pc/page_default.vue +247 -0
  49. package/core/com/nav/tpl/dev_pc/page_form.vue +162 -0
  50. package/core/com/nav/tpl/dev_pc/page_nav.vue +253 -0
  51. package/core/com/nav/tpl/dev_pc/page_table.vue +247 -0
  52. package/core/com/nav/tpl/dev_pc/page_type.vue +253 -0
  53. package/{bin/com/nav/tpl/home_phone → core/com/nav/tpl/home_pc}/page_channel.vue +231 -231
  54. package/{bin/com/nav/tpl/home_phone → core/com/nav/tpl/home_pc}/page_default.vue +231 -231
  55. package/{bin → core}/com/nav/tpl/home_pc/page_form.vue +9 -9
  56. package/{bin → core}/com/nav/tpl/home_pc/page_list.vue +231 -231
  57. package/{bin → core}/com/nav/tpl/home_pc/page_nav.vue +221 -221
  58. package/{bin/com/nav/tpl/home_phone → core/com/nav/tpl/home_pc}/page_type.vue +231 -231
  59. package/{bin → core}/com/nav/tpl/home_pc/page_view.vue +8 -8
  60. package/{bin/com/nav/tpl/home_pc → core/com/nav/tpl/home_phone}/page_channel.vue +231 -231
  61. package/{bin/com/nav/tpl/home_pc → core/com/nav/tpl/home_phone}/page_default.vue +231 -231
  62. package/{bin → core}/com/nav/tpl/home_phone/page_form.vue +9 -9
  63. package/{bin → core}/com/nav/tpl/home_phone/page_list.vue +231 -231
  64. package/{bin/com/nav/tpl/admin_pc → core/com/nav/tpl/home_phone}/page_nav.vue +236 -220
  65. package/{bin/com/nav/tpl/home_pc → core/com/nav/tpl/home_phone}/page_type.vue +231 -231
  66. package/{bin → core}/com/nav/tpl/home_phone/page_view.vue +8 -8
  67. package/core/com/nav/viewmodel.js +296 -0
  68. package/{bin → core}/com/param/config.tpl.json +24 -0
  69. package/{bin → core}/com/param/drive.js +47 -15
  70. package/core/com/plugin/com.json +4 -0
  71. package/core/com/plugin/config.tpl.json +20 -0
  72. package/{bin → core}/com/plugin/drive.js +5 -8
  73. package/{bin → core}/com/plugin/index.js +11 -56
  74. package/core/com/socket/README.md +47 -0
  75. package/core/com/socket/com.json +4 -0
  76. package/core/com/socket/config.tpl.json +14 -0
  77. package/{bin → core}/com/socket/drive.js +74 -51
  78. package/{bin → core}/com/socket/index.js +4 -2
  79. package/{bin → core}/com/socket/script.js +8 -6
  80. package/core/com/sql/config.tpl.json +70 -0
  81. package/{bin → core}/com/sql/drive.js +281 -58
  82. package/core/com/static/com.json +4 -0
  83. package/core/com/static/config.tpl.json +20 -0
  84. package/{bin → core}/com/static/drive.js +6 -4
  85. package/{bin → core}/com/static/index.js +5 -1
  86. package/core/com/task/com.json +4 -0
  87. package/core/com/task/config.tpl.json +24 -0
  88. package/core/com/task/drive.js +374 -0
  89. package/{bin → core}/com/task/index.js +14 -20
  90. package/core/com/task/script.js +37 -0
  91. package/core/com/timer/com.js +217 -0
  92. package/core/com/timer/com.json +4 -0
  93. package/core/com/tpl/com.js +19 -0
  94. package/core/com/tpl/com.json +4 -0
  95. package/index.js +161 -740
  96. package/lib/actions.js +50 -0
  97. package/lib/app.js +73 -0
  98. package/lib/base.js +355 -0
  99. package/lib/com.js +31 -0
  100. package/lib/game.js +31 -0
  101. package/lib/ref.js +121 -0
  102. package/middleware/cors/index.js +57 -0
  103. package/middleware/cors/middleware.json +7 -0
  104. package/middleware/mqtt_base/index.js +10 -0
  105. package/middleware/mqtt_base/middleware.json +8 -0
  106. package/{waf.js → middleware/waf/index.js} +12 -2
  107. package/middleware/waf/middleware.json +9 -0
  108. package/middleware/web_base/index.js +67 -0
  109. package/middleware/web_base/middleware.json +9 -0
  110. package/middleware/web_event/index.js +411 -0
  111. package/middleware/web_event/middleware.json +10 -0
  112. package/middleware/web_proxy/index.js +24 -0
  113. package/middleware/web_proxy/middleware.json +9 -0
  114. package/middleware/web_router/index.js +33 -0
  115. package/middleware/web_router/middleware.json +10 -0
  116. package/middleware/web_socket/index.js +21 -0
  117. package/middleware/web_socket/middleware.json +9 -0
  118. package/middleware/web_static/index.js +26 -0
  119. package/middleware/web_static/middleware.json +9 -0
  120. package/nodemon.json +12 -2
  121. package/package.json +56 -66
  122. package/.gitattributes +0 -5
  123. package/bin/com/README.md +0 -2
  124. package/bin/com/api/script.js +0 -14
  125. package/bin/com/cmd/README.md +0 -3
  126. package/bin/com/cmd/config.tpl.json +0 -41
  127. package/bin/com/cmd/drive.js +0 -512
  128. package/bin/com/cmd/index.js +0 -213
  129. package/bin/com/cmd/old/5w2h.js +0 -54
  130. package/bin/com/cmd/old/drive.js +0 -423
  131. package/bin/com/cmd/script.js +0 -11
  132. package/bin/com/event/drive.js +0 -69
  133. package/bin/com/event/script.js +0 -12
  134. package/bin/com/nav/tpl/admin_pc/page_channel.vue +0 -234
  135. package/bin/com/nav/tpl/admin_pc/page_default.vue +0 -236
  136. package/bin/com/nav/tpl/admin_pc/page_form.vue +0 -152
  137. package/bin/com/nav/tpl/admin_pc/page_table.vue +0 -236
  138. package/bin/com/nav/tpl/admin_pc/page_type.vue +0 -234
  139. package/bin/com/nav/tpl/home_phone/page_nav.vue +0 -221
  140. package/bin/com/nav/viewmodel.js +0 -161
  141. package/bin/com/plugin/config.tpl.json +0 -11
  142. package/bin/com/socket/config.tpl.json +0 -8
  143. package/bin/com/sql/config.tpl.json +0 -34
  144. package/bin/com/static/config.tpl.json +0 -11
  145. package/bin/com/task/config.tpl.json +0 -13
  146. package/bin/com/task/drive.js +0 -288
  147. package/bin/com/task/script.js +0 -38
  148. package/bin/com.js +0 -74
  149. package/bin/mm.conf +0 -48
  150. package/bin/static/404.html +0 -52
  151. package/bin/static/README.md +0 -1
  152. package/bin/static/css/font-awesome.min.css +0 -7
  153. package/bin/static/css/mm_base.css +0 -220
  154. package/bin/static/css/mm_common.css +0 -518
  155. package/bin/static/css/mm_component.css +0 -307
  156. package/bin/static/css/mm_expand.css +0 -634
  157. package/bin/static/css/mm_theme.css +0 -291
  158. package/bin/static/css/new_file.css +0 -79
  159. package/bin/static/css/swiper.min.css +0 -12
  160. package/bin/static/favicon.ico +0 -0
  161. package/bin/static/font/FontAwesome.otf +0 -0
  162. package/bin/static/font/HelveticaNeue.eot +0 -0
  163. package/bin/static/font/HelveticaNeue.otf +0 -0
  164. package/bin/static/font/HelveticaNeue.svg +0 -1273
  165. package/bin/static/font/HelveticaNeue.woff +0 -0
  166. package/bin/static/font/HelveticaNeue.woff2 +0 -0
  167. package/bin/static/font/fontawesome-webfont.eot +0 -0
  168. package/bin/static/font/fontawesome-webfont.svg +0 -2671
  169. package/bin/static/font/fontawesome-webfont.ttf +0 -0
  170. package/bin/static/font/fontawesome-webfont.woff +0 -0
  171. package/bin/static/font/fontawesome-webfont.woff2 +0 -0
  172. package/bin/static/h5.html +0 -325
  173. package/bin/static/highlight/highlight.pack.js +0 -2
  174. package/bin/static/highlight/styles/a11y-dark.css +0 -99
  175. package/bin/static/highlight/styles/a11y-light.css +0 -99
  176. package/bin/static/highlight/styles/agate.css +0 -108
  177. package/bin/static/highlight/styles/an-old-hope.css +0 -89
  178. package/bin/static/highlight/styles/androidstudio.css +0 -66
  179. package/bin/static/highlight/styles/arduino-light.css +0 -88
  180. package/bin/static/highlight/styles/arta.css +0 -73
  181. package/bin/static/highlight/styles/ascetic.css +0 -45
  182. package/bin/static/highlight/styles/atelier-cave-dark.css +0 -83
  183. package/bin/static/highlight/styles/atelier-cave-light.css +0 -85
  184. package/bin/static/highlight/styles/atelier-dune-dark.css +0 -69
  185. package/bin/static/highlight/styles/atelier-dune-light.css +0 -69
  186. package/bin/static/highlight/styles/atelier-estuary-dark.css +0 -84
  187. package/bin/static/highlight/styles/atelier-estuary-light.css +0 -84
  188. package/bin/static/highlight/styles/atelier-forest-dark.css +0 -69
  189. package/bin/static/highlight/styles/atelier-forest-light.css +0 -69
  190. package/bin/static/highlight/styles/atelier-heath-dark.css +0 -69
  191. package/bin/static/highlight/styles/atelier-heath-light.css +0 -69
  192. package/bin/static/highlight/styles/atelier-lakeside-dark.css +0 -69
  193. package/bin/static/highlight/styles/atelier-lakeside-light.css +0 -69
  194. package/bin/static/highlight/styles/atelier-plateau-dark.css +0 -84
  195. package/bin/static/highlight/styles/atelier-plateau-light.css +0 -84
  196. package/bin/static/highlight/styles/atelier-savanna-dark.css +0 -84
  197. package/bin/static/highlight/styles/atelier-savanna-light.css +0 -84
  198. package/bin/static/highlight/styles/atelier-seaside-dark.css +0 -69
  199. package/bin/static/highlight/styles/atelier-seaside-light.css +0 -69
  200. package/bin/static/highlight/styles/atelier-sulphurpool-dark.css +0 -69
  201. package/bin/static/highlight/styles/atelier-sulphurpool-light.css +0 -69
  202. package/bin/static/highlight/styles/atom-one-dark-reasonable.css +0 -77
  203. package/bin/static/highlight/styles/atom-one-dark.css +0 -96
  204. package/bin/static/highlight/styles/atom-one-light.css +0 -96
  205. package/bin/static/highlight/styles/brown-paper.css +0 -64
  206. package/bin/static/highlight/styles/brown-papersq.png +0 -0
  207. package/bin/static/highlight/styles/codepen-embed.css +0 -60
  208. package/bin/static/highlight/styles/color-brewer.css +0 -71
  209. package/bin/static/highlight/styles/darcula.css +0 -77
  210. package/bin/static/highlight/styles/dark.css +0 -63
  211. package/bin/static/highlight/styles/darkula.css +0 -6
  212. package/bin/static/highlight/styles/default.css +0 -99
  213. package/bin/static/highlight/styles/docco.css +0 -97
  214. package/bin/static/highlight/styles/dracula.css +0 -76
  215. package/bin/static/highlight/styles/far.css +0 -71
  216. package/bin/static/highlight/styles/foundation.css +0 -88
  217. package/bin/static/highlight/styles/github-gist.css +0 -79
  218. package/bin/static/highlight/styles/github.css +0 -99
  219. package/bin/static/highlight/styles/gml.css +0 -78
  220. package/bin/static/highlight/styles/googlecode.css +0 -89
  221. package/bin/static/highlight/styles/grayscale.css +0 -101
  222. package/bin/static/highlight/styles/gruvbox-dark.css +0 -108
  223. package/bin/static/highlight/styles/gruvbox-light.css +0 -108
  224. package/bin/static/highlight/styles/hopscotch.css +0 -83
  225. package/bin/static/highlight/styles/hybrid.css +0 -102
  226. package/bin/static/highlight/styles/idea.css +0 -97
  227. package/bin/static/highlight/styles/ir-black.css +0 -73
  228. package/bin/static/highlight/styles/isbl-editor-dark.css +0 -112
  229. package/bin/static/highlight/styles/isbl-editor-light.css +0 -112
  230. package/bin/static/highlight/styles/kimbie.dark.css +0 -74
  231. package/bin/static/highlight/styles/kimbie.light.css +0 -74
  232. package/bin/static/highlight/styles/lightfair.css +0 -87
  233. package/bin/static/highlight/styles/magula.css +0 -70
  234. package/bin/static/highlight/styles/mono-blue.css +0 -59
  235. package/bin/static/highlight/styles/monokai-sublime.css +0 -83
  236. package/bin/static/highlight/styles/monokai.css +0 -70
  237. package/bin/static/highlight/styles/nord.css +0 -309
  238. package/bin/static/highlight/styles/obsidian.css +0 -88
  239. package/bin/static/highlight/styles/ocean.css +0 -74
  240. package/bin/static/highlight/styles/paraiso-dark.css +0 -72
  241. package/bin/static/highlight/styles/paraiso-light.css +0 -72
  242. package/bin/static/highlight/styles/pojoaque.css +0 -83
  243. package/bin/static/highlight/styles/pojoaque.jpg +0 -0
  244. package/bin/static/highlight/styles/purebasic.css +0 -96
  245. package/bin/static/highlight/styles/qtcreator_dark.css +0 -83
  246. package/bin/static/highlight/styles/qtcreator_light.css +0 -83
  247. package/bin/static/highlight/styles/railscasts.css +0 -106
  248. package/bin/static/highlight/styles/rainbow.css +0 -85
  249. package/bin/static/highlight/styles/routeros.css +0 -108
  250. package/bin/static/highlight/styles/school-book.css +0 -69
  251. package/bin/static/highlight/styles/school-book.png +0 -0
  252. package/bin/static/highlight/styles/shades-of-purple.css +0 -97
  253. package/bin/static/highlight/styles/solarized-dark.css +0 -84
  254. package/bin/static/highlight/styles/solarized-light.css +0 -84
  255. package/bin/static/highlight/styles/sunburst.css +0 -102
  256. package/bin/static/highlight/styles/tomorrow-night-blue.css +0 -75
  257. package/bin/static/highlight/styles/tomorrow-night-bright.css +0 -74
  258. package/bin/static/highlight/styles/tomorrow-night-eighties.css +0 -74
  259. package/bin/static/highlight/styles/tomorrow-night.css +0 -75
  260. package/bin/static/highlight/styles/tomorrow.css +0 -72
  261. package/bin/static/highlight/styles/vs.css +0 -68
  262. package/bin/static/highlight/styles/vs2015.css +0 -115
  263. package/bin/static/highlight/styles/xcode.css +0 -104
  264. package/bin/static/highlight/styles/xt256.css +0 -92
  265. package/bin/static/highlight/styles/zenburn.css +0 -80
  266. package/bin/static/highlight/vue-highlight.js +0 -29
  267. package/bin/static/ifame.html +0 -24
  268. package/bin/static/img/add.png +0 -0
  269. package/bin/static/img/avatar.png +0 -0
  270. package/bin/static/img/banner_2.png +0 -0
  271. package/bin/static/img/default.png +0 -0
  272. package/bin/static/img/loading.svg +0 -1
  273. package/bin/static/img/logo.png +0 -0
  274. package/bin/static/img/logo1.png +0 -0
  275. package/bin/static/img/logo_gray.png +0 -0
  276. package/bin/static/img/logo_round.png +0 -0
  277. package/bin/static/img/mm.ico +0 -0
  278. package/bin/static/img/mm.jpg +0 -0
  279. package/bin/static/img/select.png +0 -0
  280. package/bin/static/img/web.png +0 -0
  281. package/bin/static/index.html +0 -12
  282. package/bin/static/js/clipboard.min.js +0 -257
  283. package/bin/static/js/css.min.js +0 -1
  284. package/bin/static/js/echarts.js +0 -22
  285. package/bin/static/js/html5.min.js +0 -1
  286. package/bin/static/js/jquery.lazyload.min.js +0 -2
  287. package/bin/static/js/jquery.min.js +0 -4189
  288. package/bin/static/js/jquery.scrollstop.min.js +0 -2
  289. package/bin/static/js/mm-requirejs-vue.js +0 -283
  290. package/bin/static/js/mm_check.js +0 -490
  291. package/bin/static/js/mm_flexble.js +0 -112
  292. package/bin/static/js/mm_picker.js +0 -1417
  293. package/bin/static/js/mm_pinyinlite.js +0 -873
  294. package/bin/static/js/mm_sdk.js +0 -2841
  295. package/bin/static/js/mm_ui_expand.js +0 -468
  296. package/bin/static/js/mm_vue.js +0 -376
  297. package/bin/static/js/mm_vue_ui.js +0 -2375
  298. package/bin/static/js/mm_websocket.js +0 -145
  299. package/bin/static/js/require.js +0 -5
  300. package/bin/static/js/sortable.min.js +0 -3
  301. package/bin/static/js/swiper.min.js +0 -13
  302. package/bin/static/js/text.min.js +0 -1
  303. package/bin/static/js/vue-router.min.js +0 -6
  304. package/bin/static/js/vue.js +0 -12338
  305. package/bin/static/js/vuedraggable.min.js +0 -2
  306. package/bin/static/js/vuex.min.js +0 -6
  307. package/bin/static/src/components/bar/mm_action.vue +0 -19
  308. package/bin/static/src/components/bar/mm_buy.vue +0 -19
  309. package/bin/static/src/components/bar/mm_chat.vue +0 -18
  310. package/bin/static/src/components/bar/mm_count.vue +0 -18
  311. package/bin/static/src/components/bar/mm_filter.vue +0 -18
  312. package/bin/static/src/components/bar/mm_search.vue +0 -18
  313. package/bin/static/src/components/bar/mm_sort.vue +0 -18
  314. package/bin/static/src/components/bar/mm_tag.vue +0 -18
  315. package/bin/static/src/components/bar/mm_title.vue +0 -19
  316. package/bin/static/src/components/content/mm_pre.vue +0 -70
  317. package/bin/static/src/components/expand/mm_drag.vue +0 -39
  318. package/bin/static/src/components/item/mm_article.vue +0 -115
  319. package/bin/static/src/components/item/mm_base.vue +0 -26
  320. package/bin/static/src/components/item/mm_contact.vue +0 -25
  321. package/bin/static/src/components/item/mm_goods.vue +0 -23
  322. package/bin/static/src/components/item/mm_img.vue +0 -21
  323. package/bin/static/src/components/item/mm_media.vue +0 -18
  324. package/bin/static/src/components/item/mm_message.vue +0 -18
  325. package/bin/static/src/components/item/mm_music.vue +0 -95
  326. package/bin/static/src/components/item/mm_news.vue +0 -22
  327. package/bin/static/src/components/item/mm_number.vue +0 -26
  328. package/bin/static/src/components/item/mm_question.vue +0 -35
  329. package/bin/static/src/components/item/mm_user.vue +0 -22
  330. package/bin/static/src/components/item/mm_video.vue +0 -95
  331. package/bin/static/src/components/slide/mm_slide_card.vue +0 -64
  332. package/bin/static/src/components/slide/mm_slide_img.vue +0 -47
  333. package/bin/static/src/components/slide/mm_slide_page.vue +0 -8
  334. package/bin/static/src/components/slide/mm_slide_text.vue +0 -54
  335. package/bin/static/src/main.js +0 -84
  336. package/bin/static/src/mixins/form.js +0 -223
  337. package/bin/static/src/mixins/item.js +0 -242
  338. package/bin/static/src/mixins/list.js +0 -244
  339. package/bin/static/src/mixins/page.js +0 -1011
  340. package/bin/static/src/mm_component.js +0 -74
  341. package/bin/static/src/router.js +0 -72
  342. package/bin/static/src/store/user.js +0 -75
  343. package/bin/static/src/store/web.js +0 -50
  344. package/bin/static/user/1/number_info.xlsx +0 -0
  345. package/bin/static/w3c.html +0 -94
  346. package/init.js +0 -55
  347. package/update.md +0 -1
  348. /package/{bin → core}/com/api/README.md +0 -0
  349. /package/{bin → core}/com/api/rpc.js +0 -0
  350. /package/{bin → core}/com/db/README.md +0 -0
  351. /package/{bin → core}/com/event/README.md +0 -0
  352. /package/{bin/com/socket → core/com/mqtt}/README.md +0 -0
  353. /package/{bin → core}/com/nav/README.md +0 -0
  354. /package/{bin → core}/com/nav/config.tpl.json +0 -0
  355. /package/{bin → core}/com/param/README.md +0 -0
  356. /package/{bin → core}/com/param/index.js +0 -0
  357. /package/{bin → core}/com/param/script.js +0 -0
  358. /package/{bin → core}/com/param/test.js +0 -0
  359. /package/{bin → core}/com/plugin/README.md +0 -0
  360. /package/{bin → core}/com/plugin/script.js +0 -0
  361. /package/{bin → core}/com/sql/README.md +0 -0
  362. /package/{bin → core}/com/sql/index.js +0 -0
  363. /package/{bin → core}/com/sql/script.js +0 -0
  364. /package/{bin → core}/com/static/README.md +0 -0
  365. /package/{bin → core}/com/static/script.js +0 -0
  366. /package/{bin → core}/com/task/README.md +0 -0
  367. /package/{bin/rps.bat → rps.bat} +0 -0
  368. /package/{bin/tps.bat → tps.bat} +0 -0
@@ -0,0 +1,139 @@
1
+ const Item = require('mm_machine').Item;
2
+
3
+ /**
4
+ * mqtt驱动类
5
+ * @extends {Item}
6
+ * @class
7
+ */
8
+ class Drive extends Item {
9
+ /**
10
+ * 构造函数
11
+ * @param {String} dir 当前目录
12
+ * @constructor
13
+ */
14
+ constructor(dir) {
15
+ super(dir, __dirname);
16
+ this.default_file = "./mqtt.json";
17
+
18
+ /* 通用项 */
19
+ /**
20
+ * 配置参数
21
+ */
22
+ this.config = {
23
+ // 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
24
+ "name": "",
25
+ // 状态 0未启用,1启用
26
+ "state": 1,
27
+ // 订阅的主题
28
+ "topic": "",
29
+ // mqtt 服务标题
30
+ "title": "",
31
+ // mqtt 服务介绍
32
+ "description": "",
33
+ // 调用的脚本
34
+ "func_file": "./index.js"
35
+ };
36
+
37
+ // 开放给前端调用的函数
38
+ this.methods = Object.assign({}, $.methods);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * 新建脚本
44
+ * @param {String} 文件
45
+ */
46
+ Drive.prototype.new_script = function(file) {
47
+ var fl = __dirname + "/script.js";
48
+ if (fl.hasFile()) {
49
+ var text = fl.loadText();
50
+ if (text) {
51
+ var l = $.slash;
52
+ if (file.indexOf('mqtt' + l) !== -1) {
53
+ var name = file.between('mqtt' + l, l);
54
+ text = text.replaceAll("{0}", name);
55
+ }
56
+ file.saveText(text);
57
+ }
58
+ }
59
+ };
60
+
61
+ /**
62
+ * 配置示例
63
+ * @param {String} 文件
64
+ */
65
+ Drive.prototype.model = function() {
66
+ // 单层匹配订阅,用于订阅所有客户端要接收的数据 格式:$SYS/<代理服务器>/service/业务/+
67
+ // "topic": "$SYS/mm/service/user/+"
68
+ // 通配方式订阅,用于订阅仅该设备或该客户端要订阅的数据 格式:$SYS/<代理服务器>/service/appid/#
69
+ // "topic": "$SYS/mm/service/idd6877e1561/#"
70
+ // 完全匹配订阅,用于特定的业务订阅,业务压力最小,建议尽可能使用完全匹配
71
+ // "topic": "$SYS/mm/service/state"
72
+ return {
73
+ // 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
74
+ "name": "demo",
75
+ // 状态 0未启用,1启用
76
+ "state": 1,
77
+ // 订阅的主题
78
+ "topic": "$SYS/mm/service/user/state",
79
+ // mqtt 服务标题
80
+ "title": "用户状态",
81
+ // mqtt 服务介绍
82
+ "description": "用于用户登录状态改变时,如1登录、2隐身、3高调、4离线",
83
+ // 调用的脚本
84
+ "func_file": "./index.js"
85
+ }
86
+ }
87
+
88
+ /**
89
+ * 新建配置
90
+ * @param {String} 文件
91
+ */
92
+ Drive.prototype.new_config = function(file) {
93
+ var fl = __dirname + "/config.tpl.json";
94
+ if (fl.hasFile()) {
95
+ var text = fl.loadText();
96
+ if (text) {
97
+ var l = $.slash;
98
+ if (file.indexOf('mqtt' + l) !== -1) {
99
+ var name = file.between('mqtt' + l, l);
100
+ text = text.replaceAll("{0}", name);
101
+ }
102
+ file.saveText(text);
103
+ }
104
+ }
105
+ };
106
+
107
+ /**
108
+ * 发送消息 —— 会发送给所有目标
109
+ * @param {String} topic 推送的主题
110
+ * @param {Object} msg 消息正文
111
+ */
112
+ Drive.prototype.send = async function(topic, msg) {
113
+
114
+ };
115
+
116
+ /**
117
+ * 接收订阅消息
118
+ * @param {String} topic 推送的主题
119
+ * @param {Object} msg 消息正文
120
+ */
121
+ Drive.prototype.main = async function(topic, msg) {
122
+ return null;
123
+ };
124
+
125
+ /**
126
+ * 初始化函数, 用于定义开放给前端的函数
127
+ */
128
+ Drive.prototype.init = async function init() {
129
+
130
+ };
131
+
132
+ /**
133
+ * 加载完成时
134
+ */
135
+ Drive.prototype.load_after = function() {
136
+ this.init();
137
+ };
138
+
139
+ module.exports = Drive;
@@ -0,0 +1,138 @@
1
+ const Index = require('mm_machine').Index;
2
+ const Drive = require('./drive');
3
+
4
+ /**
5
+ * MQTT通讯类
6
+ * @extends {Index}
7
+ * @class
8
+ */
9
+ class MQTT extends Index {
10
+ /**
11
+ * 构造函数
12
+ * @param {Object} scope 作用域
13
+ * @param {String} title 标题
14
+ * @constructor
15
+ */
16
+ constructor(scope, title) {
17
+ super(scope, __dirname);
18
+ this.Drive = Drive;
19
+ this.type = "mqtt";
20
+ this.dict = {};
21
+ this.title = title;
22
+
23
+ this.config = {
24
+ host: "127.0.0.1",
25
+ port: "1883",
26
+ protocol: "mqtt",
27
+ clientId: "test123",
28
+ username: "admin",
29
+ password: "asd123",
30
+ clean: false
31
+ }
32
+ this.client = null;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * 主题匹配
38
+ * @param {String} topic 接收到的主题
39
+ * @param {String} top 匹配用的主题
40
+ * @@return {Boolean} 返回匹配结果,正确返回true,错误返回false
41
+ */
42
+ MQTT.prototype.match = function(topic, top) {
43
+ if (topic === top) {
44
+ return true;
45
+ }
46
+ var str = "^" + top.replace("#", ".*").replace("+", "~~~").replace("~~~", "[a-zA-Z0-9_]+").replace("$", "~~~")
47
+ .replace("~~~", "\\$");
48
+ var s = str.substring(str.length - 1, str.length);
49
+ if (s !== "#") {
50
+ str += "$";
51
+ }
52
+ var mh = new RegExp(str);
53
+ return mh.test(topic);
54
+ }
55
+
56
+ /**
57
+ * 初始化
58
+ */
59
+ MQTT.prototype.init_after = function() {
60
+ this.client.on("message", (topic, msg) => {
61
+ var db = $.sql.db();
62
+ var list = this.list;
63
+ for (var i = 0, o; o = list[i++];) {
64
+ if (this.match(topic, o.config.topic)) {
65
+ o.run(topic, msg);
66
+ }
67
+ }
68
+ });
69
+ }
70
+
71
+ /**
72
+ * 处理mqtt请求
73
+ * @param {Object} conn 通讯连接器
74
+ */
75
+ MQTT.prototype.run = async function(conn) {
76
+ var list = this.list;
77
+ for (var i = 0, o; o = list[i++];) {
78
+ client.subscribe(o.config.topic);
79
+ }
80
+ };
81
+
82
+ /**
83
+ * 加载插件
84
+ * @param {String} path 检索路径
85
+ * @param {Boolean} isApp 是否APP
86
+ */
87
+ MQTT.prototype.load = function(path) {
88
+ if (!path) {
89
+ path = "/mqtt/";
90
+ }
91
+ // 获取所有应用路径
92
+ var list_scope = $.dir.getAll(path, "mqtt");
93
+
94
+ // 遍历目录路径
95
+ var _this = this;
96
+ list_scope.map(async function(f) {
97
+ var list_file = $.file.getAll(f, "*" + _this.type + ".json");
98
+ list_file.map(async (file) => {
99
+ var dir = file.dirname();
100
+ if (file.hasFile()) {
101
+ var obj = new Drive(dir);
102
+ obj.load(file);
103
+ if (obj.config.name) {
104
+ _this.list.push(obj);
105
+ }
106
+ }
107
+ });
108
+ });
109
+ }
110
+
111
+ module.exports = MQTT;
112
+
113
+
114
+ /**
115
+ * 创建全局管理器
116
+ */
117
+ if (!$.pool.mqtt) {
118
+ $.pool.mqtt = {};
119
+ }
120
+
121
+ /**
122
+ * mqtt管理器, 用于管理插件
123
+ * @param {string} scope 作用域
124
+ * @param {string} title 标题
125
+ * @return {Object} 返回一个缓存类
126
+ */
127
+ $.mqtt_admin = function (scope, title) {
128
+ if (!scope) {
129
+ scope = $.val.scope + '';
130
+ }
131
+ var obj = $.pool.mqtt[scope];
132
+ if (!obj) {
133
+ $.pool.mqtt[scope] = new MQTT(scope, title);
134
+ obj = $.pool.mqtt[scope];
135
+ }
136
+ return obj;
137
+ }
138
+
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 主函数, 用于处理订阅内容
3
+ * @param {String} topic 订阅的主题
4
+ * @param {Object} msg 消息
5
+ * @return {Object} 返回执行结果
6
+ */
7
+ exports.main = async function(topic, msg) {
8
+ $.log.debug('收到消息'topic, msg);
9
+ };
10
+
11
+ /**
12
+ * 初始化函数, 用于定义开放给前端的函数
13
+ */
14
+ exports.init = async function() {
15
+ var m = this.methods;
16
+
17
+ /**
18
+ * 获取所有方法
19
+ * @param {Object} params 参数
20
+ * @param {Object} ws Websocket服务
21
+ */
22
+ m.get_method = function(params, ws) {
23
+ return Object.keys(m);
24
+ };
25
+
26
+ /**
27
+ * @param {Object} params 参数
28
+ * @param {Object} ws Websocket服务
29
+ */
30
+ m.test = function(params, ws) {
31
+ return "你好"
32
+ };
33
+ };
@@ -0,0 +1,296 @@
1
+ class Msger {
2
+ /**
3
+ * 构造函数
4
+ * @param {Object} config 配置参数
5
+ */
6
+ constructor(config) {
7
+ this.dict = {};
8
+ this.list_add = [];
9
+ this.list_del = [];
10
+ this.autoId = 1;
11
+ }
12
+ }
13
+
14
+ /**
15
+ * 模型
16
+ */
17
+ Msger.prototype.model = function() {
18
+ return {
19
+ // 定时器ID
20
+ id: 0,
21
+ // 消息类型
22
+ type,
23
+ // 总执行次数 -1为无限次
24
+ count: 0,
25
+ // 执行次数
26
+ num: 0,
27
+ // 状态 1启用,2暂停,0结束
28
+ state: 1,
29
+ // 参数
30
+ param: {},
31
+ // 回调函数
32
+ func: function() {}
33
+ }
34
+ }
35
+
36
+ /**
37
+ * 监听
38
+ * @param {String} type
39
+ * @param {Function} func
40
+ * @param {Object} param
41
+ * @param {Number} count
42
+ */
43
+ Msger.prototype.on = function(type, func, param, count = -1) {
44
+ var id = this.autoId;
45
+ var info = {
46
+ id,
47
+ type,
48
+ num: 0,
49
+ state: 1,
50
+ count,
51
+ param,
52
+ func
53
+ };
54
+ this.list_add.push(info);
55
+ this.autoId++;
56
+ return id;
57
+ }
58
+
59
+ /**
60
+ * 执行消息监听前
61
+ */
62
+ Msger.prototype.do_before = function() {
63
+ var list = this.list_add;
64
+ for (var i = 0; i < list.length; i++) {
65
+ var o = list[i];
66
+ var lt = this.dict[o.type];
67
+ if (!lt) {
68
+ this.dict[o.type] = [];
69
+ lt = this.dict[o.type];
70
+ }
71
+ lt.add(o);
72
+ }
73
+ this.list_add.clear();
74
+
75
+ var list = this.list_del;
76
+ for (var i = 0; i < list.length; i++) {
77
+ var o = list[i];
78
+ var lt = this.dict[o.type];
79
+ if (lt) {
80
+ lt.del({
81
+ id: o.id
82
+ });
83
+ if (lt.length === 0) {
84
+ delete this.dict[o.type];
85
+ }
86
+ }
87
+ }
88
+ this.list_del.clear();
89
+ }
90
+
91
+ /**
92
+ * 执行消息监听后
93
+ */
94
+ Msger.prototype.do_after = function() {
95
+
96
+ }
97
+
98
+ /**
99
+ * 执行消息监听
100
+ */
101
+ Msger.prototype.doing = async function(o, msg) {
102
+ o.num++;
103
+ try {
104
+ await o.func(msg, o.param, o.num);
105
+ } catch (err) {
106
+ console.error(err);
107
+ }
108
+ if (o.num === o.count) {
109
+ this.list_del.push(o.id);
110
+ }
111
+ }
112
+
113
+ /**
114
+ * 发送消息
115
+ * @param {String} type 类型
116
+ * @param {Object} msg 消息主体
117
+ */
118
+ Msger.prototype.send = async function(type, msg) {
119
+ this.do_before();
120
+ var list = this.dict[type];
121
+ if (list) {
122
+ for (var i = 0; i < list.length; i++) {
123
+ var o = list[i];
124
+ // 判断是否启用状态
125
+ if (o.state == 1) {
126
+ // 判断是否还需要执行
127
+ if (o.count < 0 || o.num < o.count) {
128
+ await this.doing(o, msg);
129
+ }
130
+ } else if (!o.state) {
131
+ this.list_del.push({
132
+ id: o.id,
133
+ type: o.type
134
+ });
135
+ }
136
+ }
137
+ this.do_after();
138
+ }
139
+ }
140
+
141
+ /**
142
+ * 设置消息监听状态
143
+ * @param {Number} id 类型
144
+ * @param {String} type 类型
145
+ * @param {Number} state 状态
146
+ */
147
+ Msger.prototype.setState = function(id, type, state) {
148
+ if (type) {
149
+ var lt = this.dict[type];
150
+ var obj;
151
+ if (lt) {
152
+ if (id) {
153
+ obj = lt.getObj({
154
+ id
155
+ });
156
+ if (obj) {
157
+ obj.state = state;
158
+ }
159
+ } else {
160
+ for (var i = 0; i < lt.length; i++) {
161
+ var o = lt[i];
162
+ o.state = state;
163
+ }
164
+ }
165
+ }
166
+ if (!obj) {
167
+ if (id) {
168
+ obj = this.list_add.getObj({
169
+ id
170
+ });
171
+ if (obj) {
172
+ obj.state = state;
173
+ }
174
+ } else {
175
+ var lt = this.list_add.get({
176
+ type
177
+ });
178
+ if (lt) {
179
+ for (var i = 0; i < lt.length; i++) {
180
+ var o = lt[i];
181
+ o.state = state;
182
+ }
183
+ }
184
+ }
185
+ }
186
+ } else {
187
+ var obj;
188
+ for (var k in this.dict) {
189
+ var lt = this.dict[k];
190
+ if (lt) {
191
+ obj = lt.getObj({
192
+ id
193
+ });
194
+ if (obj) {
195
+ obj.state = state;
196
+ break;
197
+ }
198
+ }
199
+ }
200
+ obj = this.list_add.getObj({
201
+ id
202
+ });
203
+ if (obj) {
204
+ obj.state = state;
205
+ }
206
+ }
207
+ }
208
+
209
+ /**
210
+ * 开启监听
211
+ * @param {Number|String} id 名称或ID
212
+ * @param {String} type 消息类型
213
+ */
214
+ Msger.prototype.start = function(id, type) {
215
+ this.setState(id, type, 1);
216
+ }
217
+
218
+ /**
219
+ * 暂停监听
220
+ * @param {Number|String} id 名称或ID
221
+ * @param {String} type 消息类型
222
+ */
223
+ Msger.prototype.stop = function(id, type) {
224
+ this.setState(id, type, 2);
225
+ }
226
+
227
+ /**
228
+ * 结束监听
229
+ * @param {Number|String} id 名称或ID
230
+ * @param {String} type 消息类型
231
+ */
232
+ Msger.prototype.end = function(id, type) {
233
+ this.setState(id, type, 0);
234
+ }
235
+
236
+ /**
237
+ * 移除监听
238
+ * @param {Number|String} id 名称或ID
239
+ * @param {String} type 消息类型
240
+ */
241
+ Msger.prototype.remove = function(id, type) {
242
+ if (type) {
243
+ if (id) {
244
+ this.list_del.push({
245
+ id,
246
+ type
247
+ });
248
+ } else {
249
+ var lt = this.dict[type];
250
+ if (lt) {
251
+ for (var i = 0; i < lt.length; i++) {
252
+ var o = lt[i];
253
+ this.list_del.push({
254
+ id: o.id,
255
+ type: o.type
256
+ })
257
+ }
258
+ } else {
259
+ this.list_add.del({
260
+ type
261
+ });
262
+ }
263
+ }
264
+ } else if (id) {
265
+ var obj;
266
+ for (var k in this.dict) {
267
+ var lt = this.dict[k];
268
+ if (lt) {
269
+ obj = lt.getObj({
270
+ id
271
+ });
272
+ if (obj) {
273
+ break
274
+ }
275
+ }
276
+ }
277
+ if (obj) {
278
+ obj.state = 0;
279
+ this.list_del.push({
280
+ id: obj.id,
281
+ type: obj.type
282
+ });
283
+ } else {
284
+ this.list_add.del({
285
+ id
286
+ });
287
+ }
288
+ }
289
+ }
290
+
291
+
292
+ if (!$.msger || !$.msger.dict) {
293
+ $.msger = new Msger();
294
+ }
295
+
296
+ module.exports = Msger;
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "消息处理器",
3
+ "script": "./com.js"
4
+ }