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,374 @@
1
+ const Item = require('mm_machine').Item;
2
+
3
+ /**
4
+ * 延迟
5
+ * @param {Number} 毫秒
6
+ */
7
+ function sleep(milliSeconds) {
8
+ var endTime = new Date().getTime() + milliSeconds;
9
+ while (new Date().getTime() < endTime) {}
10
+ }
11
+
12
+ /**
13
+ * 计算时间差
14
+ * @param {String} startTime 开始时间
15
+ * @param {String} endTime 结束时间
16
+ * @return {Number} 返回间隔时长
17
+ */
18
+ function span(startTime, endTime) {
19
+ var stime = Date.parse(startTime);
20
+ var etime = Date.parse(endTime);
21
+ return etime - stime;
22
+ };
23
+
24
+ /**
25
+ * 转为时间
26
+ * @param {String} timeStr 时间字符串
27
+ * @return {Date} 时间类型
28
+ */
29
+ function toTime(timeStr) {
30
+ var str = timeStr.replace('T', ' ').replace('Z', '').replaceAll('.', '/').replaceAll('-', '/');
31
+ return new Date(str);
32
+ };
33
+
34
+ /**
35
+ * 定时器类函数
36
+ */
37
+ class Drive extends Item {
38
+ /**
39
+ * 构造函数
40
+ * @param {String} dir 当前目录
41
+ */
42
+ constructor(dir) {
43
+ super(dir, __dirname);
44
+ this.default_file = "./task.json";
45
+
46
+ /// 配置参数
47
+ this.config = {
48
+ // 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
49
+ "name": "demo",
50
+ // 状态 0未启用,1启用
51
+ "state": 1,
52
+ // 标题, 介绍事件作用
53
+ "title": "示例事件",
54
+ // 描述, 用于描述该事件有什么用的
55
+ "description": "描述事件使用方法",
56
+ // 文件路径, 当调用函数不存在时,会先从文件中加载
57
+ "func_file": "./index.js",
58
+ // 执行次数
59
+ "num": 10,
60
+ // 时间间隔(毫秒ms)
61
+ "interval": 1000,
62
+ // 等待时长(毫秒ms)
63
+ "wait": 0,
64
+ // 执行时间
65
+ "time": "",
66
+ // 执行开始日期
67
+ "date_start": "",
68
+ // 执行结束日期
69
+ "date_end": "",
70
+ // 执行顺序
71
+ "sort": 100
72
+ };
73
+
74
+ /// 状态
75
+ this.state = "start";
76
+ /// 等候器
77
+ this.timeout;
78
+ /// 定时执行器
79
+ this.interval;
80
+ /// 当前执行次数
81
+ this.num = 1;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * @description 设置等待执行
87
+ * @param {Function} func 回调函数
88
+ */
89
+ Drive.prototype.setTimeout = function(func) {
90
+ if (!func) {
91
+ func = function() {};
92
+ }
93
+ this.timeout = setTimeout(func, this.config.wait);
94
+ };
95
+
96
+ /**
97
+ * @description 设置间隔执行
98
+ * @param {Function} func 回调函数
99
+ */
100
+ Drive.prototype.setInterval = async function(func) {
101
+ if (!func) {
102
+ func = function() {};
103
+ }
104
+ sleep(this.config.wait);
105
+ this.interval = setInterval(func, this.config.interval);
106
+ };
107
+
108
+ /**
109
+ * @description 设置时期执行
110
+ * @param {Function} func 回调函数
111
+ */
112
+ Drive.prototype.setPeriod = function(func) {
113
+ var _this = this;
114
+ var cg = this.config;
115
+ var fn;
116
+ var time = cg.time;
117
+ if (time) {
118
+ if (time.indexOf(' ') !== -1) {
119
+ if (time.indexOf('-') !== -1) {
120
+ var arr = time.split('-');
121
+ if (arr.length > 2) {
122
+ fn = function() {
123
+ if (new Date().toStr('yyyy-MM-dd hh:mm:ss') === time) {
124
+ func();
125
+ }
126
+ };
127
+ } else {
128
+ fn = function() {
129
+ if (new Date().toStr('MM-dd hh:mm:ss') === time) {
130
+ func();
131
+ }
132
+ };
133
+ }
134
+ } else {
135
+ var arr = time.split(':');
136
+ if (arr.length == 3) {
137
+ fn = function() {
138
+ if (new Date().toStr('dd hh:mm:ss') === time) {
139
+ func();
140
+ }
141
+ };
142
+ }
143
+ else if (arr.length == 2) {
144
+ fn = function() {
145
+ if (new Date().toStr('dd hh:mm') === time) {
146
+ func();
147
+ }
148
+ };
149
+ }
150
+ else {
151
+ fn = function() {
152
+ if (new Date().toStr('dd hh') === time) {
153
+ func();
154
+ }
155
+ };
156
+ }
157
+ }
158
+ } else {
159
+ var arr = time.split(':');
160
+ if (arr.length == 3) {
161
+ fn = function() {
162
+ if (new Date().toStr('hh:mm:ss') === time) {
163
+ func();
164
+ }
165
+ };
166
+ } else if (arr.length == 2) {
167
+ fn = function() {
168
+ if (new Date().toStr('hh:mm') === time) {
169
+ func();
170
+ }
171
+ };
172
+ } else {
173
+ fn = function() {
174
+ if (new Date().toStr('mm') === time) {
175
+ func();
176
+ }
177
+ };
178
+ }
179
+ }
180
+ } else {
181
+ fn = func;
182
+ }
183
+ if (cg.date_start) {
184
+ var start = toTime(cg.date_start);
185
+ if (cg.date_end) {
186
+ var end = toTime(cg.date_end);
187
+ return function() {
188
+ var now = new Date();
189
+ if (span(now, end) >= 0) {
190
+ if (span(now, start) <= 0) {
191
+ fn();
192
+ }
193
+ } else {
194
+ _this.clear_sub();
195
+ _this.notify(_this.config.name, 'time_end');
196
+ }
197
+ };
198
+ } else {
199
+ return function() {
200
+ var now = new Date();
201
+ if (span(now, start) <= 0) {
202
+ fn();
203
+ }
204
+ };
205
+ }
206
+ } else if (cg.date_end) {
207
+ var end = toTime(cg.date_end);
208
+ return function() {
209
+ var now = new Date();
210
+ if (span(now, end) >= 0) {
211
+ fn();
212
+ } else {
213
+ _this.clear_sub();
214
+ _this.notify(_this.config.name, 'time_end');
215
+ }
216
+ };
217
+ } else {
218
+ return fn;
219
+ }
220
+ };
221
+
222
+ /**
223
+ * @description 设置按次数执行
224
+ * @param {Function} func 回调函数
225
+ */
226
+ Drive.prototype.setNum = function(func) {
227
+ var _this = this;
228
+ return function() {
229
+ if (_this.state === 'start') {
230
+ if (_this.config.num < 1) {
231
+ func();
232
+ } else if (_this.num < _this.config.num) {
233
+ func();
234
+ _this.num += 1;
235
+ } else {
236
+ func();
237
+ _this.clear();
238
+ _this.notify(_this.config.name, 'completed');
239
+ }
240
+ }
241
+ };
242
+ };
243
+
244
+ /**
245
+ * @description 结束定时器
246
+ */
247
+ Drive.prototype.end = function() {
248
+ // 当前状态为结束
249
+ this.state = "end";
250
+ this.notify(this.config.name, 'suspend');
251
+ this.clear();
252
+ };
253
+
254
+ /**
255
+ * @description 清除定时器(子函数)
256
+ */
257
+ Drive.prototype.clear_sub = function() {
258
+ if (this.interval) {
259
+ clearInterval(this.interval);
260
+ }
261
+ if (this.timeout) {
262
+ clearTimeout(this.timeout);
263
+ }
264
+ };
265
+
266
+ /**
267
+ * @description 清除定时器
268
+ * @param {Number} millisecond 时间间隔, 单位: 毫秒
269
+ */
270
+ Drive.prototype.clear = function(millisecond) {
271
+ if (millisecond) {
272
+ var _this = this;
273
+ setTimeout(function() {
274
+ _this.clear_sub();
275
+ }, millisecond);
276
+ } else {
277
+ this.clear_sub();
278
+ }
279
+ };
280
+
281
+ /**
282
+ * @description 执行线程
283
+ * @param {Function} func 回调函数
284
+ * @return {Object} 当前类
285
+ */
286
+ Drive.prototype.main = async function() {
287
+ $.log.debug('定时任务(默认), 执行中...');
288
+ };
289
+
290
+ /**
291
+ * @description 执行线程
292
+ * @param {Function} func 回调函数
293
+ * @return {Object} 当前类
294
+ */
295
+ Drive.prototype.run = async function(func) {
296
+ this.init();
297
+ if (func) {
298
+ await this.setInterval(this.setPeriod(this.setNum(func)));
299
+ } else {
300
+ await this.setInterval(this.setPeriod(this.setNum(this.main)));
301
+ }
302
+ return this;
303
+ };
304
+
305
+ /**
306
+ * @description 初始化定时器
307
+ */
308
+ Drive.prototype.init = function() {
309
+ // 当前执行次数
310
+ this.num = 1;
311
+ // 当前状态为开启
312
+ this.state = "start";
313
+ this.notify(this.config.name, 'init');
314
+ };
315
+
316
+ /**
317
+ * @description 启动定时器
318
+ */
319
+ Drive.prototype.start = function() {
320
+ // 当前状态为开启
321
+ this.state = "start";
322
+ this.notify(this.config.name, 'start');
323
+ };
324
+
325
+ /**
326
+ * @description 暂停定时器
327
+ */
328
+ Drive.prototype.stop = function() {
329
+ // 当前状态为开启
330
+ this.state = "stop";
331
+ this.notify(this.config.name, 'stop');
332
+ };
333
+
334
+ /**
335
+ * @description 通知函数, 当定时器执行完最后一次时, 会调用通知函数
336
+ * @param {String} name 名称
337
+ * @param {String} state 状态
338
+ */
339
+ Drive.prototype.notify = function(name, state) {
340
+ // switch (state) {
341
+ // case "init":
342
+ // $.log.debug('初始化');
343
+ // break;
344
+ // case "start":
345
+ // $.log.debug('开始执行');
346
+ // break;
347
+ // case "stop":
348
+ // $.log.debug('已暂停');
349
+ // break;
350
+ // case "suspend":
351
+ // // 主动中断
352
+ // $.log.debug('已中断');
353
+ // break;
354
+ // case "time_end":
355
+ // $.log.debug('已到期');
356
+ // break;
357
+ // case "completed":
358
+ // $.log.debug('已完成');
359
+ // break;
360
+ // default:
361
+ // break;
362
+ // }
363
+ };
364
+
365
+ /**
366
+ * @description 销毁资源
367
+ */
368
+ Drive.prototype.dispose = function() {
369
+ this.clear_sub();
370
+ this.interval = undefined;
371
+ this.timeout = undefined;
372
+ };
373
+
374
+ module.exports = Drive;
@@ -1,23 +1,6 @@
1
1
  const Index = require('mm_machine').Index;
2
2
  const Drive = require('./drive');
3
3
 
4
- if ($.timer) {
5
- $.timer.add({
6
- /**
7
- * 缓存
8
- */
9
- name: "task_timer",
10
- /**
11
- * 执行函数
12
- */
13
- async run() {
14
- var dt = $.pool.task;
15
- for (var k in dt) {
16
- dt[k].run();
17
- }
18
- }
19
- });
20
- }
21
4
 
22
5
  /**
23
6
  * 任务类
@@ -41,11 +24,22 @@ class Task extends Index {
41
24
 
42
25
  /**
43
26
  * 执行任务
27
+ * @param {String} name 要执行的名称
44
28
  */
45
- Task.prototype.run = async function() {
29
+ Task.prototype.run = async function(name) {
46
30
  var lt = this.list;
47
- for (var i = 0, o; o = lt[i++];) {
48
- o.run();
31
+ if(name){
32
+ for (var i = 0, o; o = lt[i++];) {
33
+ if(o.name === name){
34
+ o.run();
35
+ break;
36
+ }
37
+ }
38
+ }
39
+ else {
40
+ for (var i = 0, o; o = lt[i++];) {
41
+ o.run();
42
+ }
49
43
  }
50
44
  };
51
45
 
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 定时任务函数
3
+ */
4
+ exports.main = async function main() {
5
+ $.log.debug('定时任务, 执行中...');
6
+ };
7
+
8
+ /**
9
+ * 执行结果通知
10
+ * @param {String} name 任务名称
11
+ * @param {String} state 状态
12
+ */
13
+ exports.notify = async function(name, state) {
14
+ switch (state) {
15
+ case "init":
16
+ $.log.debug('初始化');
17
+ break;
18
+ case "start":
19
+ $.log.debug('开始执行');
20
+ break;
21
+ case "stop":
22
+ $.log.debug('已暂停');
23
+ break;
24
+ case "suspend":
25
+ // 主动中断
26
+ $.log.debug('已中断');
27
+ break;
28
+ case "time_end":
29
+ $.log.debug('已到期');
30
+ break;
31
+ case "completed":
32
+ $.log.debug('已完成');
33
+ break;
34
+ default:
35
+ break;
36
+ }
37
+ };
@@ -0,0 +1,217 @@
1
+ /**
2
+ * 计时器
3
+ */
4
+ class Timer {
5
+ /**
6
+ * 构造函数
7
+ * @param {Object} config 配置参数
8
+ */
9
+ constructor(config) {
10
+ this.list = [];
11
+ this.list_add = [];
12
+ this.list_del = [];
13
+ this.autoId = 1;
14
+ }
15
+ }
16
+
17
+ /**
18
+ * 模型
19
+ */
20
+ Timer.prototype.model = function() {
21
+ return {
22
+ // 定时器ID
23
+ id: 0,
24
+ // 总执行次数 -1为无限次
25
+ count: 0,
26
+ // 执行次数
27
+ num: 0,
28
+ // 执行间隔时长
29
+ interval: 1000,
30
+ // 等待执行事件
31
+ wait: 1000,
32
+ // 经过的时间
33
+ passedTime: 0,
34
+ // 状态 1启用,2暂停,0结束
35
+ state: 1,
36
+ // 参数
37
+ param: {},
38
+ // 回调函数
39
+ func: function() {}
40
+ }
41
+ }
42
+
43
+ /**
44
+ * 添加定时器
45
+ * @param {Function} func 回调函数
46
+ * @param {Object} param 参数
47
+ * @param {Function} interval 每次执行间隔时长
48
+ * @param {Function} count 执行次数 -1为不限次数
49
+ * @param {Function} wait 延迟执行
50
+ */
51
+ Timer.prototype.add = function(func, param = {}, interval = 1000, count = -1, wait = 0) {
52
+ var id = this.autoId;
53
+ var info = {
54
+ id,
55
+ count,
56
+ num: 0,
57
+ state: 1,
58
+ interval,
59
+ wait,
60
+ passedTime: 0,
61
+ param,
62
+ func
63
+ };
64
+ this.list_add.push(info);
65
+ this.autoId++;
66
+ return id;
67
+ }
68
+
69
+ /**
70
+ * 删除定时器
71
+ * @param {Number|String} id 名称或ID
72
+ */
73
+ Timer.prototype.del = function(id) {
74
+ this.list_del.push(id);
75
+ }
76
+
77
+ /**
78
+ * 删除定时器
79
+ * @param {Object} query 查询条件
80
+ */
81
+ Timer.prototype.delOf = function(query) {
82
+ if (typeof(query) == "name") {
83
+ query = {
84
+ name: query
85
+ }
86
+ }
87
+ var lt = [];
88
+ var list = this.list;
89
+ for (var i = 0; i < list.length; i++) {
90
+ var o = list[i];
91
+ if (o.param && $.as(o.param, query)) {
92
+ lt.push(o.id);
93
+ }
94
+ }
95
+ this.list_del.addList(lt);
96
+ }
97
+
98
+ /**
99
+ * 执行定时器后
100
+ */
101
+ Timer.prototype.do_after = function() {
102
+ var list = this.list_del;
103
+ for (var i = 0; i < list.length; i++) {
104
+ var id = list[i];
105
+ this.list.del({
106
+ id
107
+ });
108
+ }
109
+
110
+ this.list_del.clear();
111
+ this.list.addList(this.list_add);
112
+ this.list_add.clear();
113
+ }
114
+
115
+
116
+ /**
117
+ * 执行定时器
118
+ */
119
+ Timer.prototype.doing = async function(o) {
120
+ o.passedTime = 0;
121
+ o.num++;
122
+ try {
123
+ await o.func(o.param, o.num);
124
+ } catch (err) {
125
+ console.error(err);
126
+ }
127
+ if (o.num === o.count) {
128
+ this.list_del.push(o.id);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * 执行定时器
134
+ */
135
+ Timer.prototype.do = async function(millisecond) {
136
+ var list = this.list;
137
+ for (var i = 0; i < list.length; i++) {
138
+ var o = list[i];
139
+ // 判断是否启用状态
140
+ if (o.state == 1) {
141
+ // 判断是否还需要执行
142
+ if (o.count < 0 || o.num < o.count) {
143
+ o.passedTime += millisecond;
144
+ // 判断是否有延迟,消除延迟
145
+ if (o.wait) {
146
+ // 判断是否到了要执行的时候
147
+ if (o.passedTime % o.wait === 0) {
148
+ o.wait = 0;
149
+ this.doing(o);
150
+ }
151
+ } else {
152
+ // 判断是否到了要执行的时候
153
+ if (o.passedTime % o.interval === 0) {
154
+ this.doing(o);
155
+ }
156
+ }
157
+ }
158
+ } else if (!o.state) {
159
+ this.list_del.push(o.id);
160
+ }
161
+ }
162
+ this.do_after();
163
+ }
164
+
165
+ /**
166
+ * 执行定时器
167
+ */
168
+ Timer.prototype.run = async function(millisecond = 10) {
169
+ this.timer = setInterval(() => {
170
+ this.do(millisecond);
171
+ }, millisecond);
172
+ }
173
+
174
+ /**
175
+ * 开启
176
+ * @param {Number|String} id 名称或ID
177
+ */
178
+ Timer.prototype.start = function(id) {
179
+ var obj = this.list.getObj({
180
+ id
181
+ });
182
+ if (obj) {
183
+ obj.state = 1;
184
+ }
185
+ }
186
+
187
+ /**
188
+ * 暂停
189
+ * @param {Number|String} id 名称或ID
190
+ */
191
+ Timer.prototype.stop = function(id) {
192
+ var obj = this.list.getObj({
193
+ id
194
+ });
195
+ if (obj) {
196
+ obj.state = 2;
197
+ }
198
+ }
199
+
200
+ /**
201
+ * 结束
202
+ * @param {Number|String} id 名称或ID
203
+ */
204
+ Timer.prototype.end = function(id) {
205
+ var obj = this.list.getObj({
206
+ id
207
+ });
208
+ if (obj) {
209
+ obj.state = 0;
210
+ }
211
+ }
212
+
213
+ if (!$.timer || !$.timer.list) {
214
+ $.timer = new Timer();
215
+ }
216
+
217
+ module.exports = Timer;
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "定时器",
3
+ "script": "./com.js"
4
+ }
@@ -0,0 +1,19 @@
1
+ const Base = require("../../../lib/base.js");
2
+
3
+ /**
4
+ * 控制器
5
+ */
6
+ class Controller extends Base {
7
+ constructor() {
8
+ super();
9
+
10
+ // 检索的文件路径
11
+ this.path = "/apps/controller".fullname();
12
+ // 文件拓展名
13
+ this.extension = "controller.json";
14
+ // 文件存放目录
15
+ this.dir = "/apps";
16
+ }
17
+ }
18
+
19
+ module.exports = new Controller()
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "控制器",
3
+ "script": "./com.js"
4
+ }