mm_os 1.3.4 → 1.3.5
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.
- package/README.en.md +36 -0
- package/README.md +25 -166
- package/conf.json +3 -0
- package/core/base/index.js +29 -0
- package/core/base/mqtt/index.js +268 -0
- package/core/base/mqtt/lib.js +40 -0
- package/core/base/web/index.js +110 -0
- package/core/com/api/com.json +4 -0
- package/{bin → core}/com/api/config.tpl.json +9 -7
- package/{bin → core}/com/api/drive.js +239 -64
- package/{bin → core}/com/api/index.js +8 -9
- package/{bin → core}/com/api/oauth.js +23 -14
- package/core/com/api/script.js +32 -0
- package/core/com/db/com.json +4 -0
- package/{bin → core}/com/db/drive.js +99 -65
- package/{bin → core}/com/db/index.js +2 -2
- package/core/com/event/com.json +4 -0
- package/{bin → core}/com/event/config.tpl.json +2 -2
- package/core/com/event/drive.js +125 -0
- package/{bin → core}/com/event/index.js +5 -10
- package/core/com/event/script.js +26 -0
- package/core/com/eventer/com.js +450 -0
- package/core/com/eventer/com.json +4 -0
- package/core/com/middleware/com.js +128 -0
- package/core/com/middleware/com.json +4 -0
- package/core/com/middleware/config.tpl.json +8 -0
- package/core/com/middleware/script.js +9 -0
- package/core/com/mqtt/com.json +4 -0
- package/core/com/mqtt/config.tpl.json +12 -0
- package/core/com/mqtt/drive.js +139 -0
- package/core/com/mqtt/index.js +138 -0
- package/core/com/mqtt/script.js +33 -0
- package/core/com/msg/com.js +296 -0
- package/core/com/msg/com.json +4 -0
- package/{bin → core}/com/nav/drive.js +42 -17
- package/{bin → core}/com/nav/index.js +4 -4
- package/core/com/nav/tpl/admin_pc/page_channel.vue +299 -0
- package/core/com/nav/tpl/admin_pc/page_config.vue +279 -0
- package/core/com/nav/tpl/admin_pc/page_config_form.vue +194 -0
- package/core/com/nav/tpl/admin_pc/page_default.vue +287 -0
- package/core/com/nav/tpl/admin_pc/page_form.vue +180 -0
- package/core/com/nav/tpl/admin_pc/page_lang.vue +265 -0
- package/core/com/nav/tpl/admin_pc/page_nav.vue +313 -0
- package/core/com/nav/tpl/admin_pc/page_table.vue +285 -0
- package/core/com/nav/tpl/admin_pc/page_type.vue +313 -0
- package/core/com/nav/tpl/dev_pc/page_channel.vue +253 -0
- package/core/com/nav/tpl/dev_pc/page_config.vue +253 -0
- package/core/com/nav/tpl/dev_pc/page_default.vue +247 -0
- package/core/com/nav/tpl/dev_pc/page_form.vue +162 -0
- package/core/com/nav/tpl/dev_pc/page_nav.vue +253 -0
- package/core/com/nav/tpl/dev_pc/page_table.vue +247 -0
- package/core/com/nav/tpl/dev_pc/page_type.vue +253 -0
- package/{bin/com/nav/tpl/home_phone → core/com/nav/tpl/home_pc}/page_channel.vue +231 -231
- package/{bin/com/nav/tpl/home_phone → core/com/nav/tpl/home_pc}/page_default.vue +231 -231
- package/{bin → core}/com/nav/tpl/home_pc/page_form.vue +9 -9
- package/{bin → core}/com/nav/tpl/home_pc/page_list.vue +231 -231
- package/{bin → core}/com/nav/tpl/home_pc/page_nav.vue +221 -221
- package/{bin/com/nav/tpl/home_phone → core/com/nav/tpl/home_pc}/page_type.vue +231 -231
- package/{bin → core}/com/nav/tpl/home_pc/page_view.vue +8 -8
- package/{bin/com/nav/tpl/home_pc → core/com/nav/tpl/home_phone}/page_channel.vue +231 -231
- package/{bin/com/nav/tpl/home_pc → core/com/nav/tpl/home_phone}/page_default.vue +231 -231
- package/{bin → core}/com/nav/tpl/home_phone/page_form.vue +9 -9
- package/{bin → core}/com/nav/tpl/home_phone/page_list.vue +231 -231
- package/{bin/com/nav/tpl/admin_pc → core/com/nav/tpl/home_phone}/page_nav.vue +236 -220
- package/{bin/com/nav/tpl/home_pc → core/com/nav/tpl/home_phone}/page_type.vue +231 -231
- package/{bin → core}/com/nav/tpl/home_phone/page_view.vue +8 -8
- package/core/com/nav/viewmodel.js +296 -0
- package/{bin → core}/com/param/config.tpl.json +24 -0
- package/{bin → core}/com/param/drive.js +47 -15
- package/core/com/plugin/com.json +4 -0
- package/core/com/plugin/config.tpl.json +20 -0
- package/{bin → core}/com/plugin/drive.js +5 -8
- package/{bin → core}/com/plugin/index.js +11 -56
- package/core/com/socket/README.md +47 -0
- package/core/com/socket/com.json +4 -0
- package/core/com/socket/config.tpl.json +14 -0
- package/{bin → core}/com/socket/drive.js +74 -51
- package/{bin → core}/com/socket/index.js +4 -2
- package/{bin → core}/com/socket/script.js +8 -6
- package/core/com/sql/config.tpl.json +70 -0
- package/{bin → core}/com/sql/drive.js +281 -58
- package/core/com/static/com.json +4 -0
- package/core/com/static/config.tpl.json +20 -0
- package/{bin → core}/com/static/drive.js +6 -4
- package/{bin → core}/com/static/index.js +5 -1
- package/core/com/task/com.json +4 -0
- package/core/com/task/config.tpl.json +24 -0
- package/core/com/task/drive.js +374 -0
- package/{bin → core}/com/task/index.js +14 -20
- package/core/com/task/script.js +37 -0
- package/core/com/timer/com.js +217 -0
- package/core/com/timer/com.json +4 -0
- package/core/com/tpl/com.js +19 -0
- package/core/com/tpl/com.json +4 -0
- package/index.js +161 -740
- package/lib/actions.js +50 -0
- package/lib/app.js +73 -0
- package/lib/base.js +355 -0
- package/lib/com.js +31 -0
- package/lib/game.js +31 -0
- package/lib/ref.js +121 -0
- package/middleware/cors/index.js +57 -0
- package/middleware/cors/middleware.json +7 -0
- package/middleware/mqtt_base/index.js +10 -0
- package/middleware/mqtt_base/middleware.json +8 -0
- package/{waf.js → middleware/waf/index.js} +12 -2
- package/middleware/waf/middleware.json +9 -0
- package/middleware/web_base/index.js +67 -0
- package/middleware/web_base/middleware.json +9 -0
- package/middleware/web_event/index.js +411 -0
- package/middleware/web_event/middleware.json +10 -0
- package/middleware/web_proxy/index.js +24 -0
- package/middleware/web_proxy/middleware.json +9 -0
- package/middleware/web_router/index.js +33 -0
- package/middleware/web_router/middleware.json +10 -0
- package/middleware/web_socket/index.js +21 -0
- package/middleware/web_socket/middleware.json +9 -0
- package/middleware/web_static/index.js +26 -0
- package/middleware/web_static/middleware.json +9 -0
- package/nodemon.json +12 -2
- package/package.json +56 -66
- package/.gitattributes +0 -5
- package/bin/com/README.md +0 -2
- package/bin/com/api/script.js +0 -14
- package/bin/com/cmd/README.md +0 -3
- package/bin/com/cmd/config.tpl.json +0 -41
- package/bin/com/cmd/drive.js +0 -512
- package/bin/com/cmd/index.js +0 -213
- package/bin/com/cmd/old/5w2h.js +0 -54
- package/bin/com/cmd/old/drive.js +0 -423
- package/bin/com/cmd/script.js +0 -11
- package/bin/com/event/drive.js +0 -69
- package/bin/com/event/script.js +0 -12
- package/bin/com/nav/tpl/admin_pc/page_channel.vue +0 -234
- package/bin/com/nav/tpl/admin_pc/page_default.vue +0 -236
- package/bin/com/nav/tpl/admin_pc/page_form.vue +0 -152
- package/bin/com/nav/tpl/admin_pc/page_table.vue +0 -236
- package/bin/com/nav/tpl/admin_pc/page_type.vue +0 -234
- package/bin/com/nav/tpl/home_phone/page_nav.vue +0 -221
- package/bin/com/nav/viewmodel.js +0 -161
- package/bin/com/plugin/config.tpl.json +0 -11
- package/bin/com/socket/config.tpl.json +0 -8
- package/bin/com/sql/config.tpl.json +0 -34
- package/bin/com/static/config.tpl.json +0 -11
- package/bin/com/task/config.tpl.json +0 -13
- package/bin/com/task/drive.js +0 -288
- package/bin/com/task/script.js +0 -38
- package/bin/com.js +0 -74
- package/bin/mm.conf +0 -48
- package/bin/static/404.html +0 -52
- package/bin/static/README.md +0 -1
- package/bin/static/css/font-awesome.min.css +0 -7
- package/bin/static/css/mm_base.css +0 -220
- package/bin/static/css/mm_common.css +0 -518
- package/bin/static/css/mm_component.css +0 -307
- package/bin/static/css/mm_expand.css +0 -634
- package/bin/static/css/mm_theme.css +0 -291
- package/bin/static/css/new_file.css +0 -79
- package/bin/static/css/swiper.min.css +0 -12
- package/bin/static/favicon.ico +0 -0
- package/bin/static/font/FontAwesome.otf +0 -0
- package/bin/static/font/HelveticaNeue.eot +0 -0
- package/bin/static/font/HelveticaNeue.otf +0 -0
- package/bin/static/font/HelveticaNeue.svg +0 -1273
- package/bin/static/font/HelveticaNeue.woff +0 -0
- package/bin/static/font/HelveticaNeue.woff2 +0 -0
- package/bin/static/font/fontawesome-webfont.eot +0 -0
- package/bin/static/font/fontawesome-webfont.svg +0 -2671
- package/bin/static/font/fontawesome-webfont.ttf +0 -0
- package/bin/static/font/fontawesome-webfont.woff +0 -0
- package/bin/static/font/fontawesome-webfont.woff2 +0 -0
- package/bin/static/h5.html +0 -325
- package/bin/static/highlight/highlight.pack.js +0 -2
- package/bin/static/highlight/styles/a11y-dark.css +0 -99
- package/bin/static/highlight/styles/a11y-light.css +0 -99
- package/bin/static/highlight/styles/agate.css +0 -108
- package/bin/static/highlight/styles/an-old-hope.css +0 -89
- package/bin/static/highlight/styles/androidstudio.css +0 -66
- package/bin/static/highlight/styles/arduino-light.css +0 -88
- package/bin/static/highlight/styles/arta.css +0 -73
- package/bin/static/highlight/styles/ascetic.css +0 -45
- package/bin/static/highlight/styles/atelier-cave-dark.css +0 -83
- package/bin/static/highlight/styles/atelier-cave-light.css +0 -85
- package/bin/static/highlight/styles/atelier-dune-dark.css +0 -69
- package/bin/static/highlight/styles/atelier-dune-light.css +0 -69
- package/bin/static/highlight/styles/atelier-estuary-dark.css +0 -84
- package/bin/static/highlight/styles/atelier-estuary-light.css +0 -84
- package/bin/static/highlight/styles/atelier-forest-dark.css +0 -69
- package/bin/static/highlight/styles/atelier-forest-light.css +0 -69
- package/bin/static/highlight/styles/atelier-heath-dark.css +0 -69
- package/bin/static/highlight/styles/atelier-heath-light.css +0 -69
- package/bin/static/highlight/styles/atelier-lakeside-dark.css +0 -69
- package/bin/static/highlight/styles/atelier-lakeside-light.css +0 -69
- package/bin/static/highlight/styles/atelier-plateau-dark.css +0 -84
- package/bin/static/highlight/styles/atelier-plateau-light.css +0 -84
- package/bin/static/highlight/styles/atelier-savanna-dark.css +0 -84
- package/bin/static/highlight/styles/atelier-savanna-light.css +0 -84
- package/bin/static/highlight/styles/atelier-seaside-dark.css +0 -69
- package/bin/static/highlight/styles/atelier-seaside-light.css +0 -69
- package/bin/static/highlight/styles/atelier-sulphurpool-dark.css +0 -69
- package/bin/static/highlight/styles/atelier-sulphurpool-light.css +0 -69
- package/bin/static/highlight/styles/atom-one-dark-reasonable.css +0 -77
- package/bin/static/highlight/styles/atom-one-dark.css +0 -96
- package/bin/static/highlight/styles/atom-one-light.css +0 -96
- package/bin/static/highlight/styles/brown-paper.css +0 -64
- package/bin/static/highlight/styles/brown-papersq.png +0 -0
- package/bin/static/highlight/styles/codepen-embed.css +0 -60
- package/bin/static/highlight/styles/color-brewer.css +0 -71
- package/bin/static/highlight/styles/darcula.css +0 -77
- package/bin/static/highlight/styles/dark.css +0 -63
- package/bin/static/highlight/styles/darkula.css +0 -6
- package/bin/static/highlight/styles/default.css +0 -99
- package/bin/static/highlight/styles/docco.css +0 -97
- package/bin/static/highlight/styles/dracula.css +0 -76
- package/bin/static/highlight/styles/far.css +0 -71
- package/bin/static/highlight/styles/foundation.css +0 -88
- package/bin/static/highlight/styles/github-gist.css +0 -79
- package/bin/static/highlight/styles/github.css +0 -99
- package/bin/static/highlight/styles/gml.css +0 -78
- package/bin/static/highlight/styles/googlecode.css +0 -89
- package/bin/static/highlight/styles/grayscale.css +0 -101
- package/bin/static/highlight/styles/gruvbox-dark.css +0 -108
- package/bin/static/highlight/styles/gruvbox-light.css +0 -108
- package/bin/static/highlight/styles/hopscotch.css +0 -83
- package/bin/static/highlight/styles/hybrid.css +0 -102
- package/bin/static/highlight/styles/idea.css +0 -97
- package/bin/static/highlight/styles/ir-black.css +0 -73
- package/bin/static/highlight/styles/isbl-editor-dark.css +0 -112
- package/bin/static/highlight/styles/isbl-editor-light.css +0 -112
- package/bin/static/highlight/styles/kimbie.dark.css +0 -74
- package/bin/static/highlight/styles/kimbie.light.css +0 -74
- package/bin/static/highlight/styles/lightfair.css +0 -87
- package/bin/static/highlight/styles/magula.css +0 -70
- package/bin/static/highlight/styles/mono-blue.css +0 -59
- package/bin/static/highlight/styles/monokai-sublime.css +0 -83
- package/bin/static/highlight/styles/monokai.css +0 -70
- package/bin/static/highlight/styles/nord.css +0 -309
- package/bin/static/highlight/styles/obsidian.css +0 -88
- package/bin/static/highlight/styles/ocean.css +0 -74
- package/bin/static/highlight/styles/paraiso-dark.css +0 -72
- package/bin/static/highlight/styles/paraiso-light.css +0 -72
- package/bin/static/highlight/styles/pojoaque.css +0 -83
- package/bin/static/highlight/styles/pojoaque.jpg +0 -0
- package/bin/static/highlight/styles/purebasic.css +0 -96
- package/bin/static/highlight/styles/qtcreator_dark.css +0 -83
- package/bin/static/highlight/styles/qtcreator_light.css +0 -83
- package/bin/static/highlight/styles/railscasts.css +0 -106
- package/bin/static/highlight/styles/rainbow.css +0 -85
- package/bin/static/highlight/styles/routeros.css +0 -108
- package/bin/static/highlight/styles/school-book.css +0 -69
- package/bin/static/highlight/styles/school-book.png +0 -0
- package/bin/static/highlight/styles/shades-of-purple.css +0 -97
- package/bin/static/highlight/styles/solarized-dark.css +0 -84
- package/bin/static/highlight/styles/solarized-light.css +0 -84
- package/bin/static/highlight/styles/sunburst.css +0 -102
- package/bin/static/highlight/styles/tomorrow-night-blue.css +0 -75
- package/bin/static/highlight/styles/tomorrow-night-bright.css +0 -74
- package/bin/static/highlight/styles/tomorrow-night-eighties.css +0 -74
- package/bin/static/highlight/styles/tomorrow-night.css +0 -75
- package/bin/static/highlight/styles/tomorrow.css +0 -72
- package/bin/static/highlight/styles/vs.css +0 -68
- package/bin/static/highlight/styles/vs2015.css +0 -115
- package/bin/static/highlight/styles/xcode.css +0 -104
- package/bin/static/highlight/styles/xt256.css +0 -92
- package/bin/static/highlight/styles/zenburn.css +0 -80
- package/bin/static/highlight/vue-highlight.js +0 -29
- package/bin/static/ifame.html +0 -24
- package/bin/static/img/add.png +0 -0
- package/bin/static/img/avatar.png +0 -0
- package/bin/static/img/banner_2.png +0 -0
- package/bin/static/img/default.png +0 -0
- package/bin/static/img/loading.svg +0 -1
- package/bin/static/img/logo.png +0 -0
- package/bin/static/img/logo1.png +0 -0
- package/bin/static/img/logo_gray.png +0 -0
- package/bin/static/img/logo_round.png +0 -0
- package/bin/static/img/mm.ico +0 -0
- package/bin/static/img/mm.jpg +0 -0
- package/bin/static/img/select.png +0 -0
- package/bin/static/img/web.png +0 -0
- package/bin/static/index.html +0 -12
- package/bin/static/js/clipboard.min.js +0 -257
- package/bin/static/js/css.min.js +0 -1
- package/bin/static/js/echarts.js +0 -22
- package/bin/static/js/html5.min.js +0 -1
- package/bin/static/js/jquery.lazyload.min.js +0 -2
- package/bin/static/js/jquery.min.js +0 -4189
- package/bin/static/js/jquery.scrollstop.min.js +0 -2
- package/bin/static/js/mm-requirejs-vue.js +0 -283
- package/bin/static/js/mm_check.js +0 -490
- package/bin/static/js/mm_flexble.js +0 -112
- package/bin/static/js/mm_picker.js +0 -1417
- package/bin/static/js/mm_pinyinlite.js +0 -873
- package/bin/static/js/mm_sdk.js +0 -2841
- package/bin/static/js/mm_ui_expand.js +0 -468
- package/bin/static/js/mm_vue.js +0 -376
- package/bin/static/js/mm_vue_ui.js +0 -2375
- package/bin/static/js/mm_websocket.js +0 -145
- package/bin/static/js/require.js +0 -5
- package/bin/static/js/sortable.min.js +0 -3
- package/bin/static/js/swiper.min.js +0 -13
- package/bin/static/js/text.min.js +0 -1
- package/bin/static/js/vue-router.min.js +0 -6
- package/bin/static/js/vue.js +0 -12338
- package/bin/static/js/vuedraggable.min.js +0 -2
- package/bin/static/js/vuex.min.js +0 -6
- package/bin/static/src/components/bar/mm_action.vue +0 -19
- package/bin/static/src/components/bar/mm_buy.vue +0 -19
- package/bin/static/src/components/bar/mm_chat.vue +0 -18
- package/bin/static/src/components/bar/mm_count.vue +0 -18
- package/bin/static/src/components/bar/mm_filter.vue +0 -18
- package/bin/static/src/components/bar/mm_search.vue +0 -18
- package/bin/static/src/components/bar/mm_sort.vue +0 -18
- package/bin/static/src/components/bar/mm_tag.vue +0 -18
- package/bin/static/src/components/bar/mm_title.vue +0 -19
- package/bin/static/src/components/content/mm_pre.vue +0 -70
- package/bin/static/src/components/expand/mm_drag.vue +0 -39
- package/bin/static/src/components/item/mm_article.vue +0 -115
- package/bin/static/src/components/item/mm_base.vue +0 -26
- package/bin/static/src/components/item/mm_contact.vue +0 -25
- package/bin/static/src/components/item/mm_goods.vue +0 -23
- package/bin/static/src/components/item/mm_img.vue +0 -21
- package/bin/static/src/components/item/mm_media.vue +0 -18
- package/bin/static/src/components/item/mm_message.vue +0 -18
- package/bin/static/src/components/item/mm_music.vue +0 -95
- package/bin/static/src/components/item/mm_news.vue +0 -22
- package/bin/static/src/components/item/mm_number.vue +0 -26
- package/bin/static/src/components/item/mm_question.vue +0 -35
- package/bin/static/src/components/item/mm_user.vue +0 -22
- package/bin/static/src/components/item/mm_video.vue +0 -95
- package/bin/static/src/components/slide/mm_slide_card.vue +0 -64
- package/bin/static/src/components/slide/mm_slide_img.vue +0 -47
- package/bin/static/src/components/slide/mm_slide_page.vue +0 -8
- package/bin/static/src/components/slide/mm_slide_text.vue +0 -54
- package/bin/static/src/main.js +0 -84
- package/bin/static/src/mixins/form.js +0 -223
- package/bin/static/src/mixins/item.js +0 -242
- package/bin/static/src/mixins/list.js +0 -244
- package/bin/static/src/mixins/page.js +0 -1011
- package/bin/static/src/mm_component.js +0 -74
- package/bin/static/src/router.js +0 -72
- package/bin/static/src/store/user.js +0 -75
- package/bin/static/src/store/web.js +0 -50
- package/bin/static/user/1/number_info.xlsx +0 -0
- package/bin/static/w3c.html +0 -94
- package/init.js +0 -55
- package/update.md +0 -1
- /package/{bin → core}/com/api/README.md +0 -0
- /package/{bin → core}/com/api/rpc.js +0 -0
- /package/{bin → core}/com/db/README.md +0 -0
- /package/{bin → core}/com/event/README.md +0 -0
- /package/{bin/com/socket → core/com/mqtt}/README.md +0 -0
- /package/{bin → core}/com/nav/README.md +0 -0
- /package/{bin → core}/com/nav/config.tpl.json +0 -0
- /package/{bin → core}/com/param/README.md +0 -0
- /package/{bin → core}/com/param/index.js +0 -0
- /package/{bin → core}/com/param/script.js +0 -0
- /package/{bin → core}/com/param/test.js +0 -0
- /package/{bin → core}/com/plugin/README.md +0 -0
- /package/{bin → core}/com/plugin/script.js +0 -0
- /package/{bin → core}/com/sql/README.md +0 -0
- /package/{bin → core}/com/sql/index.js +0 -0
- /package/{bin → core}/com/sql/script.js +0 -0
- /package/{bin → core}/com/static/README.md +0 -0
- /package/{bin → core}/com/static/script.js +0 -0
- /package/{bin → core}/com/task/README.md +0 -0
- /package/{bin/rps.bat → rps.bat} +0 -0
- /package/{bin/tps.bat → tps.bat} +0 -0
package/README.en.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# 服务端框架
|
|
2
|
+
|
|
3
|
+
#### Description
|
|
4
|
+
这是服务端框架,网站、游戏、小程序服务端可基于该框架进行二次开发
|
|
5
|
+
|
|
6
|
+
#### Software Architecture
|
|
7
|
+
Software architecture description
|
|
8
|
+
|
|
9
|
+
#### Installation
|
|
10
|
+
|
|
11
|
+
1. xxxx
|
|
12
|
+
2. xxxx
|
|
13
|
+
3. xxxx
|
|
14
|
+
|
|
15
|
+
#### Instructions
|
|
16
|
+
|
|
17
|
+
1. xxxx
|
|
18
|
+
2. xxxx
|
|
19
|
+
3. xxxx
|
|
20
|
+
|
|
21
|
+
#### Contribution
|
|
22
|
+
|
|
23
|
+
1. Fork the repository
|
|
24
|
+
2. Create Feat_xxx branch
|
|
25
|
+
3. Commit your code
|
|
26
|
+
4. Create Pull Request
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
#### Gitee Feature
|
|
30
|
+
|
|
31
|
+
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
|
32
|
+
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
|
33
|
+
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
|
34
|
+
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
|
35
|
+
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
|
36
|
+
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
package/README.md
CHANGED
|
@@ -1,178 +1,37 @@
|
|
|
1
|
-
#
|
|
2
|
-
这是超级美眉系统,用于开发web、rpc、websocket函数式编程服务。
|
|
1
|
+
# 服务端框架
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
目前主流、且好用的开源框架,如下↓
|
|
7
|
-
php语言:ThinkPHP、PhalApi、discuz、DedeCMS;
|
|
8
|
-
asp.net core语言:ZKEACMS、Orchard;
|
|
9
|
-
java语言:Sping、Struts2;
|
|
10
|
-
nodejs:egg、nuxt。
|
|
11
|
-
|
|
12
|
-
以上开源还算比较好用,但是目前还没有一个框架是结合它们的长处来使用的,更没有从中小企业的需求和团队协作方面去考虑而研发的。
|
|
13
|
-
在开发过程中,我们不能因为它们某个框架的特长而就使用某框架来开发,这样不仅学习成本高,而且后期拓展功能容易遇到问题。
|
|
14
|
-
为此,我们最好能有一个具有它们所有优点的一个框架来开发,这样不仅更有利于开发,也更有利于后期维护升级。
|
|
3
|
+
#### 介绍
|
|
4
|
+
这是服务端框架,网站、游戏、小程序服务端可基于该框架进行二次开发
|
|
15
5
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
具有我所知,ThinkPHP最大的优点是拓展机制,而PhalApi开创了服务端的ADM模式(api、domain、model),discuz则具有强大的分类信息功能和最容易上手的模板引擎,DedeCMS则让仅会html的的菜鸟程序员也能开发模板,完成cms。
|
|
19
|
-
而ZKEACMS则拥有强大的拖拽排版功能,Orchard则采用了插件化解决了动态类库引用耦合问题。
|
|
20
|
-
Sping则提供了API解决了上传、电子邮件等问题,Struts2则在数据拦截器和异常处理上做得比较好。
|
|
21
|
-
egg则设计了更灵活得插件机制,让功能拓展更加简便。nuxt则采用了MVVM模式让前端开发分工更加明确、简单。
|
|
22
|
-
当我们看到了这些,是否不由自主的在想,要是它们的长处都能结合起来使用就好了?但是问题来了,如何才能结合这些长处?结合这些长处之后,又如何能保证这个全新的东西更加好用,而不是不伦不类?
|
|
23
|
-
|
|
24
|
-
### 三、研发成果
|
|
25
|
-
在经过两年的时间,对各大主流的框架代码和运作模式进行研究和模仿,mm_os终于诞生了。
|
|
26
|
-
采用了koa做为web服务核心,再加上mm中间件,实现了Sping、Struts2具有的优点。
|
|
27
|
-
采用了应用+插件机制,实现了Orchard、egg具有的优点,同时以操作系统的角度考虑,实现零度耦合(可断、可连)。
|
|
28
|
-
然后在ADM模式基础上升级为ACDM模式(api、check、domain、model),实现了PhalApi的优点。
|
|
29
|
-
采用了art-template模板引擎进行改进,实现了类似discuz的模板语法。
|
|
30
|
-
采用懒加载com组件,实现了比ThinkPHP更方便的拓展机制。
|
|
31
|
-
除此之外,还参考了nuxt,给服务端设计了生命周期和事件机制,让拓展业务逻辑更加轻巧、简单。
|
|
32
|
-
|
|
33
|
-
### 四、全新优点
|
|
34
|
-
除了学习了各大主流框架的好外,mm_os还考虑了性能、负载、安全性等相关问题,为中小企业打造一个真正企业级的服务端系统。
|
|
35
|
-
更为广大开发者提供了很多便捷函数和可超10人以上同时协作开发的架构,这是其他框架没有考虑的问题。
|
|
36
|
-
再加上模型生成数据库、数据库生成模型,脚本自动生成脚本等理念设计,大大提高开发效率,为开发者升级和创造提升到另一个高度。
|
|
37
|
-
|
|
38
|
-
## 指南
|
|
39
|
-
### 一、安装与使用
|
|
40
|
-
1.创建目录
|
|
41
|
-
```
|
|
42
|
-
mkdir example
|
|
43
|
-
```
|
|
44
|
-
2.进入目录
|
|
45
|
-
```
|
|
46
|
-
cd example
|
|
47
|
-
```
|
|
48
|
-
3.初始化项目
|
|
49
|
-
```
|
|
50
|
-
npm init
|
|
51
|
-
```
|
|
52
|
-
4.安装mm_os
|
|
53
|
-
```
|
|
54
|
-
npm i mm_os
|
|
55
|
-
```
|
|
56
|
-
5.在package.json的"scripts"中加入两行代码
|
|
57
|
-
```
|
|
58
|
-
"dev": "./node_modules/.bin/cross-env NODE_ENV=development PORT=5000 nodemon server.js"
|
|
59
|
-
"start": "./node_modules/.bin/cross-env NODE_ENV=production PORT=5000 node server.js"
|
|
60
|
-
```
|
|
61
|
-
6.运行开发模式
|
|
62
|
-
```
|
|
63
|
-
npm run dev
|
|
64
|
-
```
|
|
65
|
-
7.运行生产模式
|
|
66
|
-
```
|
|
67
|
-
npm run start
|
|
68
|
-
```
|
|
6
|
+
#### 软件架构
|
|
7
|
+
软件架构说明
|
|
69
8
|
|
|
70
|
-
### 二、请求与响应
|
|
71
|
-
通过restful风格发送post、get请求加上json-rpc2.0作为默认响应数据格式来实现通讯过程。
|
|
72
|
-
请求的数据格式支持xml、form-data、json,接收到的数据会在request.query和request.body中。
|
|
73
|
-
响应支持xml、text、json、html,但建议使用json格式,由于mm_os采用函数式编程,所以可以直接return value来响应请求。
|
|
74
|
-
```javascript
|
|
75
|
-
async function main(ctx, db){
|
|
76
|
-
var query = ctx.request.query;
|
|
77
|
-
var body = ctx.request.body;
|
|
78
|
-
return "hello world"
|
|
79
|
-
}
|
|
80
|
-
module.exports = main;
|
|
81
|
-
```
|
|
82
9
|
|
|
83
|
-
|
|
84
|
-
mm_os将一个业务划分成两部分,一部分叫配置,一部分叫服务。
|
|
85
|
-
为了方便区分,保存配置的是json文件,保存服务程序的是js文件,一个业务就由一个json和一个js组成,如果js是常规通用的,那么就可能只有一个配置json,启动后动态继承js。
|
|
10
|
+
#### 安装教程
|
|
86
11
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
3.使用命令自动生成接口、脚本和开发文档
|
|
91
|
-
4.使用命令生成基本后台页面
|
|
92
|
-
5.修改页面完成后台功能
|
|
93
|
-
6.调整参数校验配置和SQL模板配置
|
|
94
|
-
7.调整API接口配置完成开发
|
|
95
|
-
|
|
96
|
-
## SDK
|
|
97
|
-
### 一、Mysql SQL数据库
|
|
98
|
-
1. 使用object对象进行增删改查
|
|
99
|
-
2. 使用sql语句进行增删改查
|
|
100
|
-
3. 使用sql模板语法进行增删改查
|
|
101
|
-
4. 使用共鸣model对数据库进行修改
|
|
12
|
+
1. xxxx
|
|
13
|
+
2. xxxx
|
|
14
|
+
3. xxxx
|
|
102
15
|
|
|
103
|
-
|
|
104
|
-
1. 使用增删改查函数
|
|
105
|
-
2. 修改缓存时长
|
|
106
|
-
3. 根据规律删除缓存
|
|
107
|
-
4. 使用消息订阅和通知功能
|
|
16
|
+
#### 使用说明
|
|
108
17
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
18
|
+
1. xxxx
|
|
19
|
+
2. xxxx
|
|
20
|
+
3. xxxx
|
|
112
21
|
|
|
113
|
-
|
|
114
|
-
1. 使用array原型函数
|
|
115
|
-
2. 使用string原型函数
|
|
116
|
-
3. 使用number原型函数
|
|
117
|
-
4. 使用date原型函数
|
|
118
|
-
5. 使用object便捷函数
|
|
22
|
+
#### 参与贡献
|
|
119
23
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
24
|
+
1. Fork 本仓库
|
|
25
|
+
2. 新建 Feat_xxx 分支
|
|
26
|
+
3. 提交代码
|
|
27
|
+
4. 新建 Pull Request
|
|
123
28
|
|
|
124
|
-
### 六、http.js 网络请求
|
|
125
|
-
1. 使用http帮助类做get请求
|
|
126
|
-
2. 使用http帮助类做post请求
|
|
127
|
-
3. 使用http上传文件
|
|
128
|
-
4. 使用http下载文件
|
|
129
29
|
|
|
130
|
-
|
|
131
|
-
1. 使用mathch格式匹配字符串
|
|
132
|
-
2. 使用正则加格式匹配字符串
|
|
133
|
-
3. 使用相似度匹配字符串
|
|
30
|
+
#### 特技
|
|
134
31
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
2. 使用mvc模式开发网站
|
|
142
|
-
|
|
143
|
-
## 机制
|
|
144
|
-
### 一、plugin 应用、插件机制
|
|
145
|
-
1. 给应用创建插件功能
|
|
146
|
-
3. 利用插件管理事件和API接口
|
|
147
|
-
2. 使用插件命令管理插件
|
|
148
|
-
|
|
149
|
-
### 二、event 事件、生命周期机制
|
|
150
|
-
|
|
151
|
-
### 三、api 路由请求机制
|
|
152
|
-
### 四、param 参数校验机制
|
|
153
|
-
### 五、sql 模板语法机制
|
|
154
|
-
### 六、task 定时任务机制
|
|
155
|
-
### 七、static 多静态文件管理机制
|
|
156
|
-
### 八、websocket 通讯管理机制
|
|
157
|
-
### 九、com 公共函数管理机制
|
|
158
|
-
|
|
159
|
-
## 教程
|
|
160
|
-
### 一、创建一个应用
|
|
161
|
-
### 二、创建一个插件
|
|
162
|
-
### 三、创建一个事件脚本
|
|
163
|
-
### 四、创建一个路由接口 helloWorld
|
|
164
|
-
### 五、使用mysql增删改查
|
|
165
|
-
### 六、使用SQL模板语法功能
|
|
166
|
-
### 七、使用参数校验功能
|
|
167
|
-
### 八、使用api接口缓存功能
|
|
168
|
-
### 九、使用自动生成脚本功能
|
|
169
|
-
|
|
170
|
-
## 愿景
|
|
171
|
-
### 应用愿景
|
|
172
|
-
期待mm_os能实现自动化、智能化、可视化开发
|
|
173
|
-
|
|
174
|
-
### 商业愿景
|
|
175
|
-
希望mm_os能帮助更多企业快速实现应用落地计划,提升中小企业创业成功率,抢占市场先机。
|
|
176
|
-
|
|
177
|
-
### 开发愿景
|
|
178
|
-
希望能帮助开发者提高开发效率,同时也希望更多的开发者能一起打造更出更好的mm_os来帮助企业成长。
|
|
32
|
+
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
|
33
|
+
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
|
34
|
+
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
|
35
|
+
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
|
36
|
+
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
|
37
|
+
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
package/conf.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var WEB = require("./web");
|
|
2
|
+
var MQTT = require("./mqtt");
|
|
3
|
+
|
|
4
|
+
module.exports = function(cg) {
|
|
5
|
+
var middleware = new $.Middleware();
|
|
6
|
+
middleware.init();
|
|
7
|
+
var mqtt, web;
|
|
8
|
+
if (cg.web && cg.web.state) {
|
|
9
|
+
web = new WEB(cg.web);
|
|
10
|
+
web.list = middleware.list.filter((o) => {
|
|
11
|
+
return !o.mode || o.mode == "web"
|
|
12
|
+
});
|
|
13
|
+
web.init();
|
|
14
|
+
}
|
|
15
|
+
if (cg.mqtt && cg.mqtt.state) {
|
|
16
|
+
mqtt = new MQTT(Object.assign(cg.mqtt, {
|
|
17
|
+
redis: cg.redis,
|
|
18
|
+
mongodb: cg.mongodb
|
|
19
|
+
}));
|
|
20
|
+
mqtt.list = middleware.list.filter((o) => {
|
|
21
|
+
return o.mode == "mqtt"
|
|
22
|
+
});
|
|
23
|
+
mqtt.init();
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
mqtt,
|
|
27
|
+
web
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
require('./lib.js');
|
|
2
|
+
const mosca = require('mosca');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* mqtt 物联网通讯类
|
|
6
|
+
*/
|
|
7
|
+
class MQTT {
|
|
8
|
+
/**
|
|
9
|
+
* 构造函数
|
|
10
|
+
* @param {Object} config 配置参数
|
|
11
|
+
*/
|
|
12
|
+
constructor(config) {
|
|
13
|
+
/**
|
|
14
|
+
* 配置参数
|
|
15
|
+
*/
|
|
16
|
+
this.config = Object.assign({
|
|
17
|
+
"state": true,
|
|
18
|
+
// mqtt访问端口号
|
|
19
|
+
"socket_port": 1883,
|
|
20
|
+
// 服务端
|
|
21
|
+
"http_host": "localhost",
|
|
22
|
+
// websocket 访问端口
|
|
23
|
+
"http_port": 8083,
|
|
24
|
+
// 缓存方式
|
|
25
|
+
"cache": "mongodb", // "mongodb",
|
|
26
|
+
redis: {
|
|
27
|
+
host: "localhost",
|
|
28
|
+
port: 6379,
|
|
29
|
+
password: "asd159357",
|
|
30
|
+
db: 12
|
|
31
|
+
},
|
|
32
|
+
mongodb: {
|
|
33
|
+
user: "",
|
|
34
|
+
password: "",
|
|
35
|
+
host: "localhost",
|
|
36
|
+
port: 27017,
|
|
37
|
+
database: "mqtt"
|
|
38
|
+
}
|
|
39
|
+
}, config);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* MQTT服务器
|
|
43
|
+
*/
|
|
44
|
+
this.server = null;
|
|
45
|
+
|
|
46
|
+
this.list = [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 客户端连接成功
|
|
52
|
+
* @param {Object} client 客户端信息
|
|
53
|
+
*/
|
|
54
|
+
MQTT.prototype.connected = async function(client) {
|
|
55
|
+
//监听连接
|
|
56
|
+
console.info('client connected', client.id);
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 初始化
|
|
62
|
+
* @param {Object} config
|
|
63
|
+
*/
|
|
64
|
+
MQTT.prototype.init = function(config) {
|
|
65
|
+
if (config) {
|
|
66
|
+
this.config = Object.assign(this.config, config);
|
|
67
|
+
}
|
|
68
|
+
var cg = Object.assign({}, this.config);
|
|
69
|
+
var {
|
|
70
|
+
redis,
|
|
71
|
+
mongodb
|
|
72
|
+
} = cg;
|
|
73
|
+
var conf = {
|
|
74
|
+
port: cg.socket_port,
|
|
75
|
+
http: {
|
|
76
|
+
host: cg.http_host || "localhost",
|
|
77
|
+
port: cg.http_port,
|
|
78
|
+
bundle: true,
|
|
79
|
+
static: './'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (cg.cache === 'redis') {
|
|
83
|
+
if (cg.redis) {
|
|
84
|
+
conf.backend = {
|
|
85
|
+
type: "redis",
|
|
86
|
+
redis: require('redis'),
|
|
87
|
+
host: redis.host || "localhost",
|
|
88
|
+
port: redis.port || 6379,
|
|
89
|
+
password: redis.password,
|
|
90
|
+
db: redis.db || 12,
|
|
91
|
+
return_buffers: true
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
conf.backend = {
|
|
95
|
+
type: "redis",
|
|
96
|
+
redis: require('redis'),
|
|
97
|
+
host: "localhost",
|
|
98
|
+
password: "asd159357",
|
|
99
|
+
port: 6379,
|
|
100
|
+
db: 12,
|
|
101
|
+
return_buffers: true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// 数据持久化参数设置
|
|
105
|
+
conf.persistence = Object.assign({
|
|
106
|
+
factory: mosca.persistence.Redis,
|
|
107
|
+
ttl: {
|
|
108
|
+
// TTL for subscriptions is 23 hour
|
|
109
|
+
subscriptions: 23 * 60 * 60 * 1000,
|
|
110
|
+
// TTL for packets is 23 hour
|
|
111
|
+
packets: 23 * 60 * 60 * 1000,
|
|
112
|
+
}
|
|
113
|
+
}, conf.backend);
|
|
114
|
+
} else if (cg.cache === 'mongodb' || cg.cache === 'mongo') {
|
|
115
|
+
var url = `mongodb://${mongodb.host}:${mongodb.port}/${mongodb.database}`;
|
|
116
|
+
if (mongodb.user) {
|
|
117
|
+
url =
|
|
118
|
+
`mongodb://${mongodb.user}:${mongodb.password}@${mongodb.host}:${mongodb.port}/${mongodb.database}`
|
|
119
|
+
}
|
|
120
|
+
conf.backend = {
|
|
121
|
+
// 增加了此项
|
|
122
|
+
type: 'mongo',
|
|
123
|
+
url,
|
|
124
|
+
pubsubCollection: 'ascoltatori',
|
|
125
|
+
mongo: {}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 数据持久化参数设置
|
|
129
|
+
conf.persistence = Object.assign({
|
|
130
|
+
factory: mosca.persistence.Mongo,
|
|
131
|
+
ttl: {
|
|
132
|
+
// TTL for subscriptions is 23 hour
|
|
133
|
+
subscriptions: 23 * 60 * 60 * 1000,
|
|
134
|
+
// TTL for packets is 23 hour
|
|
135
|
+
packets: 23 * 60 * 60 * 1000,
|
|
136
|
+
}
|
|
137
|
+
}, conf.backend);
|
|
138
|
+
}
|
|
139
|
+
this.server = new mosca.Server(conf);
|
|
140
|
+
return this;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 引用
|
|
145
|
+
* @param {Function} 函数
|
|
146
|
+
*/
|
|
147
|
+
MQTT.prototype.use = function(func) {
|
|
148
|
+
// this.server.use(func);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 运行主程序
|
|
153
|
+
* @param {String} state 状态
|
|
154
|
+
*/
|
|
155
|
+
MQTT.prototype.main = function(state) {
|
|
156
|
+
var cg = this.config;
|
|
157
|
+
sr = this.server;
|
|
158
|
+
|
|
159
|
+
var _this = this;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 对服务器端口进行配置,在此端口进行监听
|
|
163
|
+
* @param {Object} client 客户端信息
|
|
164
|
+
*/
|
|
165
|
+
sr.on('clientConnected', async function(client) {
|
|
166
|
+
return await _this.connected(client);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 监听MQTT主题消息
|
|
171
|
+
* @param {Object} packet 订阅消息
|
|
172
|
+
* @param {Object} client 客户端信息
|
|
173
|
+
*/
|
|
174
|
+
sr.on('published', function(packet, client) {
|
|
175
|
+
_this.published(packet, client);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 监听MQTT主题消息
|
|
180
|
+
* @param {String} topic 订阅主题
|
|
181
|
+
* @param {Object} client 客户端信息
|
|
182
|
+
*/
|
|
183
|
+
sr.on('subscribed', function(topic, client) {
|
|
184
|
+
_this.subscribed(topic, client);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 身份验证
|
|
189
|
+
*/
|
|
190
|
+
sr.authenticate = (client, username, password, callback) => {
|
|
191
|
+
$.log.info("收到身份验证", username, password);
|
|
192
|
+
this.auth(client, username, password, callback);
|
|
193
|
+
return true;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 当服务开启时
|
|
198
|
+
*/
|
|
199
|
+
sr.on('ready', function() {
|
|
200
|
+
// 当服务开启时
|
|
201
|
+
console.info(`MQTT访问 mqtt://127.0.0.1:${cg.socket_port} || ws://127.0.0.1:${cg.http_port}`);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 收到订阅时
|
|
207
|
+
* @param {String} topic 订阅主题
|
|
208
|
+
* @param {Object} client 客户端信息
|
|
209
|
+
*/
|
|
210
|
+
MQTT.prototype.subscribed = function(topic, client) {
|
|
211
|
+
// console.log("订阅", topic, client.id);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* 收到推送消息时
|
|
216
|
+
* @param {Object} packet 订阅的消息
|
|
217
|
+
* @param {Object} client 客户端信息
|
|
218
|
+
*/
|
|
219
|
+
MQTT.prototype.published = function(packet, client) {
|
|
220
|
+
// console.log("发布", packet.topic, packet.payload.toString());
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 身份验证
|
|
225
|
+
* @param {Object} client 客户端
|
|
226
|
+
* @param {String} username 用户名
|
|
227
|
+
* @param {String} password 密码
|
|
228
|
+
* @param {Function} callback 回调函数,回调返回true,则表示验证通过。
|
|
229
|
+
*/
|
|
230
|
+
MQTT.prototype.auth = function(client, username, password, callback) {
|
|
231
|
+
// console.log("连接授权", client.id, username, password ? password.toString() : '');
|
|
232
|
+
var bl = true;
|
|
233
|
+
// 回调第二个参数为true表示验证通过, 为false表示验证失败
|
|
234
|
+
callback(null, bl);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 运行主程序前
|
|
239
|
+
* @param {String} state 状态
|
|
240
|
+
*/
|
|
241
|
+
MQTT.prototype.before = async function(state) {
|
|
242
|
+
var list = this.list;
|
|
243
|
+
for (var i = 0; i < list.length; i++) {
|
|
244
|
+
var o = list[i];
|
|
245
|
+
o.func = require(o.func_file);
|
|
246
|
+
if (o.func) {
|
|
247
|
+
o.func(this.server, this.config);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 运行主程序后
|
|
254
|
+
* @param {String} state 状态
|
|
255
|
+
*/
|
|
256
|
+
MQTT.prototype.after = async function(state) {};
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* 运行
|
|
260
|
+
* @param {String} state 状态
|
|
261
|
+
*/
|
|
262
|
+
MQTT.prototype.run = async function(state = 'start') {
|
|
263
|
+
await this.before(state);
|
|
264
|
+
await this.main(state);
|
|
265
|
+
await this.after(state);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
module.exports = MQTT;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var urilib = require('url');
|
|
2
|
+
var scanSchema = require('jsonschema/lib/scan').scan;
|
|
3
|
+
var Validator = require("jsonschema/lib/validator.js");
|
|
4
|
+
var helpers = require('jsonschema/lib/helpers');
|
|
5
|
+
var SchemaContext = helpers.SchemaContext;
|
|
6
|
+
var anonymousBase = '/';
|
|
7
|
+
|
|
8
|
+
// 重构校验函数,解决error问题
|
|
9
|
+
Validator.prototype.validate = function validate(instance, schema, options, ctx) {
|
|
10
|
+
if (!options) {
|
|
11
|
+
options = {};
|
|
12
|
+
}
|
|
13
|
+
// This section indexes subschemas in the provided schema, so they don't need to be added with Validator#addSchema
|
|
14
|
+
// This will work so long as the function at uri.resolve() will resolve a relative URI to a relative URI
|
|
15
|
+
var id = schema.$id || schema.id;
|
|
16
|
+
var base = urilib.resolve(options.base || anonymousBase, id || '');
|
|
17
|
+
if (!ctx) {
|
|
18
|
+
ctx = new SchemaContext(schema, options, [], base, Object.create(this.schemas));
|
|
19
|
+
if (!ctx.schemas[base]) {
|
|
20
|
+
ctx.schemas[base] = schema;
|
|
21
|
+
}
|
|
22
|
+
var found = scanSchema(base, schema);
|
|
23
|
+
for (var n in found.id) {
|
|
24
|
+
var sch = found.id[n];
|
|
25
|
+
ctx.schemas[n] = sch;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (options.required && instance === undefined) {
|
|
29
|
+
var result = new ValidatorResult(instance, schema, options, ctx);
|
|
30
|
+
result.addError('is required, but is undefined');
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
var result = this.validateSchema(instance, schema, options, ctx);
|
|
34
|
+
if (!result) {
|
|
35
|
+
throw new Error('Result undefined');
|
|
36
|
+
} else if (options.throwAll && result.errors.length) {
|
|
37
|
+
throw new ValidatorResultError(result);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const Koa = require('koa');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Web http 通讯类
|
|
5
|
+
*/
|
|
6
|
+
class WEB {
|
|
7
|
+
/**
|
|
8
|
+
* 构造函数
|
|
9
|
+
* @param {Object} config 配置参数
|
|
10
|
+
*/
|
|
11
|
+
constructor(config) {
|
|
12
|
+
/**
|
|
13
|
+
* 配置参数
|
|
14
|
+
*/
|
|
15
|
+
this.config = Object.assign({
|
|
16
|
+
// 访问地址
|
|
17
|
+
"host": "0.0.0.0",
|
|
18
|
+
// 访问端口号
|
|
19
|
+
"port": 5000,
|
|
20
|
+
// 是否启用websocket
|
|
21
|
+
"socket": true,
|
|
22
|
+
// 是否启用压缩
|
|
23
|
+
"compress": true,
|
|
24
|
+
// 是否启用事件
|
|
25
|
+
"event": true,
|
|
26
|
+
// 是否启用事件
|
|
27
|
+
"log": true,
|
|
28
|
+
// 是否启用静态文件
|
|
29
|
+
"static": true,
|
|
30
|
+
// 静态文件路径
|
|
31
|
+
"static_path": "./static".fullname($.runPath),
|
|
32
|
+
// 代理转发
|
|
33
|
+
"proxy": {}
|
|
34
|
+
}, config);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* web服务器
|
|
38
|
+
*/
|
|
39
|
+
this.server = null;
|
|
40
|
+
this.list = [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 初始化
|
|
46
|
+
* @param {Object} config
|
|
47
|
+
*/
|
|
48
|
+
WEB.prototype.init = function(config) {
|
|
49
|
+
if (config) {
|
|
50
|
+
this.config = Object.assign(this.config, config);
|
|
51
|
+
}
|
|
52
|
+
this.server = new Koa();
|
|
53
|
+
return this;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 引用
|
|
58
|
+
* @param {Function} 函数
|
|
59
|
+
*/
|
|
60
|
+
WEB.prototype.use = function(func) {
|
|
61
|
+
this.server.use(func);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 运行主程序
|
|
66
|
+
* @param {String} state 状态
|
|
67
|
+
*/
|
|
68
|
+
WEB.prototype.main = function(state) {
|
|
69
|
+
var cg = this.config;
|
|
70
|
+
var host = cg.host;
|
|
71
|
+
if (host == '0.0.0.0') {
|
|
72
|
+
host = '127.0.0.1'
|
|
73
|
+
}
|
|
74
|
+
this.server.listen(cg.port, cg.host, () => {
|
|
75
|
+
console.info(`HTTP访问 http://${host}:${cg.port}`);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 运行主程序前
|
|
81
|
+
* @param {String} state 状态
|
|
82
|
+
*/
|
|
83
|
+
WEB.prototype.before = async function(state) {
|
|
84
|
+
var list = this.list;
|
|
85
|
+
for (var i = 0; i < list.length; i++) {
|
|
86
|
+
var o = list[i];
|
|
87
|
+
o.func = require(o.func_file);
|
|
88
|
+
if (o.func) {
|
|
89
|
+
o.func(this.server, this.config);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 运行主程序后
|
|
96
|
+
* @param {String} state 状态
|
|
97
|
+
*/
|
|
98
|
+
WEB.prototype.after = async function(state) {};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 运行
|
|
102
|
+
* @param {String} state 状态
|
|
103
|
+
*/
|
|
104
|
+
WEB.prototype.run = async function(state = 'start') {
|
|
105
|
+
await this.before(state);
|
|
106
|
+
await this.main(state);
|
|
107
|
+
await this.after(state);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
module.exports = WEB;
|