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
|
@@ -6,6 +6,11 @@ if (!$.dict.user_id) {
|
|
|
6
6
|
$.dict.user_id = "user_id";
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
var keyword_default =
|
|
10
|
+
"`user_id` in (SELECT `user_id` FROM `user_account` WHERE `nickname` LIKE '%{0}%' OR `phone` LIKE '%{0}%' OR `wallet_address` LIKE '%{0}%')";
|
|
11
|
+
|
|
12
|
+
var keyword_default_tip = "昵称、手机号、钱包地址";
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* db数据库开发驱动类
|
|
11
16
|
* @extends {Item}
|
|
@@ -34,20 +39,22 @@ class Drive extends Item {
|
|
|
34
39
|
|
|
35
40
|
// 是否设置以下字段为getObj查对象SQL时不可见
|
|
36
41
|
this.getObj_not = ['password', 'salt', 'display'];
|
|
37
|
-
|
|
42
|
+
|
|
38
43
|
// 是否设置默认该表仅用户可访问
|
|
39
44
|
this.query_default_table = ['user'];
|
|
40
|
-
|
|
45
|
+
|
|
41
46
|
/**
|
|
42
47
|
* 配置参数
|
|
43
48
|
*/
|
|
44
49
|
this.config = {
|
|
50
|
+
// 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
|
|
51
|
+
"name": "",
|
|
52
|
+
// 状态 0未启用,1启用
|
|
53
|
+
"state": 1,
|
|
45
54
|
// 标题
|
|
46
55
|
"title": "",
|
|
47
56
|
// 描述
|
|
48
57
|
"description": "",
|
|
49
|
-
// 名称
|
|
50
|
-
"name": "",
|
|
51
58
|
// 表名
|
|
52
59
|
"table": "",
|
|
53
60
|
// 主键,用于实体模型
|
|
@@ -57,6 +64,7 @@ class Drive extends Item {
|
|
|
57
64
|
/* */
|
|
58
65
|
]
|
|
59
66
|
};
|
|
67
|
+
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
|
|
@@ -96,7 +104,7 @@ Drive.prototype.model = function(fields) {
|
|
|
96
104
|
var min = 0;
|
|
97
105
|
var max = 0;
|
|
98
106
|
|
|
99
|
-
var note = note.replace(":", ":").replace('(', '(').replace(')',')');
|
|
107
|
+
var note = note.replace(":", ":").replace('(', '(').replace(')', ')');
|
|
100
108
|
var title = note.left(":", true).trim();
|
|
101
109
|
var desc = note.right(":");
|
|
102
110
|
var description = "";
|
|
@@ -130,8 +138,8 @@ Drive.prototype.model = function(fields) {
|
|
|
130
138
|
}
|
|
131
139
|
map = desc.between("(", ")");
|
|
132
140
|
}
|
|
133
|
-
if (
|
|
134
|
-
min =
|
|
141
|
+
if (name.indexOf('_id') !== -1 || name == 'id') {
|
|
142
|
+
min = 0;
|
|
135
143
|
}
|
|
136
144
|
if (max === 0) {
|
|
137
145
|
switch (tp) {
|
|
@@ -206,13 +214,7 @@ Drive.prototype.model = function(fields) {
|
|
|
206
214
|
// 默认值
|
|
207
215
|
"default": dflt_value,
|
|
208
216
|
// 转换编排
|
|
209
|
-
"map": map
|
|
210
|
-
// 联表入,唯一主键在其他表中,然后关联到该表
|
|
211
|
-
"join_in": [],
|
|
212
|
-
// 联表出,唯一主键在该表中,然后关联其他表
|
|
213
|
-
"join_out": [],
|
|
214
|
-
// 展现位置
|
|
215
|
-
"position": []
|
|
217
|
+
"map": map
|
|
216
218
|
};
|
|
217
219
|
};
|
|
218
220
|
|
|
@@ -226,7 +228,8 @@ Drive.prototype.update_config = async function(db, cover) {
|
|
|
226
228
|
var list = [];
|
|
227
229
|
|
|
228
230
|
// 查询表注释并修改
|
|
229
|
-
var sql = "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" + db
|
|
231
|
+
var sql = "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" + db
|
|
232
|
+
.database() +
|
|
230
233
|
"' && TABLE_NAME = '" + cg.table + "';";
|
|
231
234
|
|
|
232
235
|
var lt = await db.run(sql);
|
|
@@ -310,6 +313,7 @@ Drive.prototype.update_db = async function(db) {
|
|
|
310
313
|
var value = "";
|
|
311
314
|
switch (o.type) {
|
|
312
315
|
case "varchar":
|
|
316
|
+
case "longtext":
|
|
313
317
|
case "text":
|
|
314
318
|
if (o.decimal) {
|
|
315
319
|
type = o.type + '(' + o.max_length + ',' + o.decimal + ')';
|
|
@@ -369,7 +373,7 @@ Drive.prototype.update_db = async function(db) {
|
|
|
369
373
|
}
|
|
370
374
|
|
|
371
375
|
var note = o.title + ":";
|
|
372
|
-
if (o.type === 'varchar' || o.type === 'text') {
|
|
376
|
+
if (o.type === 'varchar' || o.type === 'text' || o.type === 'longtext') {
|
|
373
377
|
if (o.max_length) {
|
|
374
378
|
note += "[" + o.min_length + "," + o.max_length + "]"
|
|
375
379
|
} else if (o.min_length) {
|
|
@@ -383,19 +387,21 @@ Drive.prototype.update_db = async function(db) {
|
|
|
383
387
|
}
|
|
384
388
|
}
|
|
385
389
|
note += o.description;
|
|
386
|
-
if(o.map){
|
|
390
|
+
if (o.map) {
|
|
387
391
|
note += '(' + o.map + ')'
|
|
388
392
|
}
|
|
389
393
|
var sql = "`{1}` {2} {3} {4} COMMENT '{5}'";
|
|
390
|
-
sql = sql.replace('{1}', o.name).replace('{2}', type).replace('{3}', notnull).replace('{4}', value)
|
|
391
|
-
|
|
394
|
+
sql = sql.replace('{1}', o.name).replace('{2}', type).replace('{3}', notnull).replace('{4}', value)
|
|
395
|
+
.replace('{5}',
|
|
396
|
+
note);
|
|
392
397
|
|
|
393
398
|
if (arr.length === 0) {
|
|
394
399
|
// 如果没有则添加
|
|
395
400
|
await db.exec("alter table `{0}` add ".replace('{0}', cg.table) + sql);
|
|
396
401
|
} else {
|
|
397
402
|
// 如果有则修改
|
|
398
|
-
await db.exec("alter table `{0}` change `{1}` ".replace('{0}', cg.table).replace('{1}', o
|
|
403
|
+
await db.exec("alter table `{0}` change `{1}` ".replace('{0}', cg.table).replace('{1}', o
|
|
404
|
+
.name) + sql);
|
|
399
405
|
}
|
|
400
406
|
}
|
|
401
407
|
} else {
|
|
@@ -439,8 +445,9 @@ Drive.prototype.update_app = async function(cover) {
|
|
|
439
445
|
f = this.dir + cg.table.replace(scope + '_', '') + '.db.json';
|
|
440
446
|
this.filename = f;
|
|
441
447
|
} else {
|
|
442
|
-
f = this.filename;
|
|
448
|
+
f = this.filename + '.db.json';
|
|
443
449
|
}
|
|
450
|
+
|
|
444
451
|
if (f) {
|
|
445
452
|
if (!this.dir) {
|
|
446
453
|
this.dir = f.dirname();
|
|
@@ -514,7 +521,6 @@ Drive.prototype.update_api = async function(dir, cover) {
|
|
|
514
521
|
if (!fs.existsSync(manage)) {
|
|
515
522
|
fs.mkdirSync(manage);
|
|
516
523
|
}
|
|
517
|
-
|
|
518
524
|
this.new_sql(client, manage, cover);
|
|
519
525
|
await this.new_param(client, manage, cover);
|
|
520
526
|
this.new_api(client, manage, cover);
|
|
@@ -527,20 +533,6 @@ Drive.prototype.update_api = async function(dir, cover) {
|
|
|
527
533
|
* @param {String} scope 接口域
|
|
528
534
|
*/
|
|
529
535
|
Drive.prototype.new_event = async function(dir, path, scope) {
|
|
530
|
-
// // 添加事件
|
|
531
|
-
// var event_dir = dir + "/event_api";
|
|
532
|
-
// if (!fs.existsSync(event_dir)) {
|
|
533
|
-
// fs.mkdirSync(event_dir);
|
|
534
|
-
// }
|
|
535
|
-
//
|
|
536
|
-
// if (dir_arr.length > 1) {
|
|
537
|
-
// event_dir += "/" + dir_arr[1];
|
|
538
|
-
// if (!fs.existsSync(event_dir)) {
|
|
539
|
-
// fs.mkdirSync(event_dir);
|
|
540
|
-
// }
|
|
541
|
-
// this.new_event(event_dir, dir_arr[0], dir_arr[1]);
|
|
542
|
-
// }
|
|
543
|
-
|
|
544
536
|
var f = dir + "/main.js";
|
|
545
537
|
if (!f.hasFile()) {
|
|
546
538
|
var code = (__dirname + '/event_script.js').loadText();
|
|
@@ -554,31 +546,54 @@ Drive.prototype.new_event = async function(dir, path, scope) {
|
|
|
554
546
|
* @param {Object} obj
|
|
555
547
|
* @return {Object} 返回格式
|
|
556
548
|
*/
|
|
557
|
-
Drive.prototype.get_format = async function(obj){
|
|
549
|
+
Drive.prototype.get_format = async function(obj) {
|
|
558
550
|
var map = obj.map;
|
|
559
551
|
var format = {
|
|
560
552
|
key: obj.name,
|
|
561
553
|
title: obj.title.replace('ID', '').replace('id', '')
|
|
562
554
|
};
|
|
563
|
-
if(map.indexOf('|') !== -1){
|
|
555
|
+
if (map.indexOf('|') !== -1) {
|
|
564
556
|
var list = map.split('|');
|
|
565
|
-
if(map.indexOf('
|
|
566
|
-
list.
|
|
557
|
+
if (map.indexOf(',') !== -1) {
|
|
558
|
+
format.list = list.map((o) => {
|
|
559
|
+
var arr = o.split(',');
|
|
560
|
+
var value = arr[0];
|
|
561
|
+
if (arr.length > 0) {
|
|
562
|
+
return {
|
|
563
|
+
name: arr[1],
|
|
564
|
+
value: value
|
|
565
|
+
}
|
|
566
|
+
} else {
|
|
567
|
+
return {
|
|
568
|
+
name: value,
|
|
569
|
+
value
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
} else if (/^[0-9]+/.test(map)) {
|
|
574
|
+
if (map.indexOf('0') !== 0) {
|
|
575
|
+
list.unshift('');
|
|
576
|
+
}
|
|
577
|
+
format.list = list.map((value) => {
|
|
578
|
+
return value.replace(/[0-9]+/, '')
|
|
579
|
+
})
|
|
580
|
+
} else {
|
|
581
|
+
format.list = list.map((value) => {
|
|
582
|
+
return {
|
|
583
|
+
name: value,
|
|
584
|
+
value
|
|
585
|
+
}
|
|
586
|
+
});
|
|
567
587
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
})
|
|
571
|
-
}
|
|
572
|
-
else {
|
|
573
|
-
if(map.indexOf('.') !== -1){
|
|
588
|
+
} else {
|
|
589
|
+
if (map.indexOf('.') !== -1) {
|
|
574
590
|
var arr = obj.map.split('.');
|
|
575
591
|
format.table = arr[0];
|
|
576
592
|
format.name = arr[1];
|
|
577
|
-
if(arr.length > 2){
|
|
593
|
+
if (arr.length > 2) {
|
|
578
594
|
format.id = arr[2];
|
|
579
595
|
}
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
596
|
+
} else {
|
|
582
597
|
format.table = obj.map;
|
|
583
598
|
format.name = 'name';
|
|
584
599
|
}
|
|
@@ -619,7 +634,7 @@ Drive.prototype.new_sql = async function(client, manage, cover) {
|
|
|
619
634
|
field_obj += ",`" + n + "`";
|
|
620
635
|
}
|
|
621
636
|
|
|
622
|
-
if (p === 'varchar' || p === 'text') {
|
|
637
|
+
if (p === 'varchar' || p === 'text' || p === 'longtext') {
|
|
623
638
|
query[n] = "`" + n + "` like '%{0}%'";
|
|
624
639
|
if (this.isSet(n, this.query_keyword)) {
|
|
625
640
|
keyword += " || `" + n + "` like '%{0}%'";
|
|
@@ -638,16 +653,22 @@ Drive.prototype.new_sql = async function(client, manage, cover) {
|
|
|
638
653
|
}
|
|
639
654
|
} else if (n === uid && query_default_user) {
|
|
640
655
|
query_default[n] = "`" + n + "` = {" + uid + "}";
|
|
656
|
+
} else if (n === 'available' || n === 'show') {
|
|
657
|
+
query_default[n] = "`" + n + "` = 1";
|
|
641
658
|
}
|
|
642
659
|
}
|
|
643
|
-
if(o.map){
|
|
660
|
+
if (o.map) {
|
|
644
661
|
var fmt = await this.get_format(o);
|
|
645
|
-
if(fmt){
|
|
662
|
+
if (fmt) {
|
|
646
663
|
format.push(fmt);
|
|
647
664
|
}
|
|
648
665
|
}
|
|
649
666
|
}
|
|
650
667
|
|
|
668
|
+
if (cg.table.indexOf("user_") !== -1) {
|
|
669
|
+
keyword += ' || ' + keyword_default;
|
|
670
|
+
}
|
|
671
|
+
|
|
651
672
|
if (keyword) {
|
|
652
673
|
query["keyword"] = "(" + keyword.replace(' || ', '') + ")";
|
|
653
674
|
}
|
|
@@ -661,7 +682,7 @@ Drive.prototype.new_sql = async function(client, manage, cover) {
|
|
|
661
682
|
orderby_default: '`' + cg.key + '` desc',
|
|
662
683
|
field_obj: field_obj.replace(',', ''),
|
|
663
684
|
field_default: field.replace(',', ''),
|
|
664
|
-
method: 'get get_obj',
|
|
685
|
+
method: 'get get_obj avg sum count',
|
|
665
686
|
query,
|
|
666
687
|
query_default,
|
|
667
688
|
update,
|
|
@@ -672,7 +693,7 @@ Drive.prototype.new_sql = async function(client, manage, cover) {
|
|
|
672
693
|
if (orderby) {
|
|
673
694
|
oj.orderby_default = orderby;
|
|
674
695
|
}
|
|
675
|
-
if (oj.query_default[uid]) {
|
|
696
|
+
if (oj.query_default[uid] && cg.table.indexOf("user_") !== -1) {
|
|
676
697
|
oj.filter = {
|
|
677
698
|
"table": "table",
|
|
678
699
|
"page": "page",
|
|
@@ -690,7 +711,9 @@ Drive.prototype.new_sql = async function(client, manage, cover) {
|
|
|
690
711
|
delete m.method;
|
|
691
712
|
m.field_hide = [];
|
|
692
713
|
m.name += 2;
|
|
693
|
-
m.field_obj = m.field_obj.replace(",`time_create`", "").replace(",`time_update`", "").replace(
|
|
714
|
+
m.field_obj = m.field_obj.replace(",`time_create`", "").replace(",`time_update`", "").replace(
|
|
715
|
+
",`create_time`", "")
|
|
716
|
+
.replace(",`update_time`", "");
|
|
694
717
|
delete m.query_default;
|
|
695
718
|
this.save_file(manage + '/sql.json', m, cover);
|
|
696
719
|
}
|
|
@@ -751,6 +774,9 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
751
774
|
query: [],
|
|
752
775
|
query_required: []
|
|
753
776
|
},
|
|
777
|
+
get_obj: {
|
|
778
|
+
query_required: []
|
|
779
|
+
},
|
|
754
780
|
list: []
|
|
755
781
|
};
|
|
756
782
|
var len = lt.length;
|
|
@@ -772,11 +798,14 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
772
798
|
// 参数类型 string字符串、number数字、bool布尔、dateTime时间、object对象类型、array数组类型
|
|
773
799
|
"type": "",
|
|
774
800
|
// 数据存储类型
|
|
775
|
-
"dataType": p
|
|
801
|
+
"dataType": p
|
|
776
802
|
};
|
|
777
803
|
|
|
778
|
-
if (p === 'varchar' || p === 'text') {
|
|
804
|
+
if (p === 'varchar' || p === 'text' || p === 'longtext') {
|
|
779
805
|
m.type = "string";
|
|
806
|
+
// 默认值
|
|
807
|
+
m.default = o.default;
|
|
808
|
+
|
|
780
809
|
// 字符串相关验证
|
|
781
810
|
m.string = {
|
|
782
811
|
// // 非空
|
|
@@ -794,9 +823,9 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
794
823
|
var range = (o.min_length && o.max_length) ? [o.min_length, o.max_length] : [];
|
|
795
824
|
if (range.length > 0) {
|
|
796
825
|
m.string.range = range;
|
|
797
|
-
} else if (o.
|
|
826
|
+
} else if (o.min_length) {
|
|
798
827
|
m.string.min = o.min_length;
|
|
799
|
-
} else if (o.
|
|
828
|
+
} else if (o.max_length) {
|
|
800
829
|
m.string.max = o.max_length;
|
|
801
830
|
}
|
|
802
831
|
|
|
@@ -814,7 +843,7 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
814
843
|
m.string.format = "email"
|
|
815
844
|
}
|
|
816
845
|
if (o.not_null) {
|
|
817
|
-
m.string.notEmpty = o.not_null;
|
|
846
|
+
m.string.notEmpty = !!o.not_null;
|
|
818
847
|
cm.add.body_required.push(n);
|
|
819
848
|
} else {
|
|
820
849
|
cm.add.body.push(n);
|
|
@@ -825,7 +854,6 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
825
854
|
keyword += "、" + o.title + "(" + n + ")";
|
|
826
855
|
}
|
|
827
856
|
cm.set.body.push(n);
|
|
828
|
-
|
|
829
857
|
// 添加验证模型
|
|
830
858
|
cm.list.push(m);
|
|
831
859
|
} else if (p === 'date' || p === 'time' || p === 'datetime' || p === 'timestamp') {
|
|
@@ -836,6 +864,7 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
836
864
|
format = p;
|
|
837
865
|
}
|
|
838
866
|
m.type = "string";
|
|
867
|
+
m.default = "";
|
|
839
868
|
// 时间相关验证
|
|
840
869
|
m.string = {
|
|
841
870
|
// 非空
|
|
@@ -852,7 +881,7 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
852
881
|
m_max.name = n + "_max";
|
|
853
882
|
m_max.title += "——结束时间";
|
|
854
883
|
cm.list.push(m_max);
|
|
855
|
-
|
|
884
|
+
|
|
856
885
|
if (n.indexOf('create') !== -1 && n.indexOf('update') !== -1) {
|
|
857
886
|
cm.add.body.push(n);
|
|
858
887
|
cm.set.body.push(n);
|
|
@@ -862,6 +891,7 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
862
891
|
cm.get.query.push(n + "_max");
|
|
863
892
|
} else {
|
|
864
893
|
m.type = "number";
|
|
894
|
+
m.default = Number(o.default) + "";
|
|
865
895
|
// 数值相关验证
|
|
866
896
|
|
|
867
897
|
m.number = {
|
|
@@ -884,6 +914,7 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
884
914
|
cm.del.query_required.push(n);
|
|
885
915
|
cm.set.query.push(n);
|
|
886
916
|
cm.get.query.push(n);
|
|
917
|
+
cm.get_obj.query_required.push(n);
|
|
887
918
|
// 添加验证模型
|
|
888
919
|
cm.list.push(m);
|
|
889
920
|
} else {
|
|
@@ -907,9 +938,9 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
907
938
|
m_max.title += "——最大值";
|
|
908
939
|
cm.list.push(m_max);
|
|
909
940
|
} else {
|
|
941
|
+
cm.get.query.push(n);
|
|
910
942
|
if (this.isSet(n, this.query_number)) {
|
|
911
943
|
cm.set.query.push(n);
|
|
912
|
-
cm.get.query.push(n);
|
|
913
944
|
}
|
|
914
945
|
}
|
|
915
946
|
} else {
|
|
@@ -923,6 +954,9 @@ Drive.prototype.new_param = async function(client, manage, cover) {
|
|
|
923
954
|
if (keyword) {
|
|
924
955
|
cm.get.query.push('keyword');
|
|
925
956
|
cm.set.query.push('keyword');
|
|
957
|
+
if (cg.table.indexOf("user_") !== -1) {
|
|
958
|
+
keyword += '、' + keyword_default_tip;
|
|
959
|
+
}
|
|
926
960
|
var m_k = {
|
|
927
961
|
"name": "keyword",
|
|
928
962
|
"title": "关键词",
|
|
@@ -969,7 +1003,7 @@ Drive.prototype.isSet = function(name, arr) {
|
|
|
969
1003
|
* @return {Boolean} 是否可以
|
|
970
1004
|
*/
|
|
971
1005
|
Drive.prototype.isCan = function(name, arr, type) {
|
|
972
|
-
if(type === '
|
|
1006
|
+
if (type === 'longtext') {
|
|
973
1007
|
return false;
|
|
974
1008
|
}
|
|
975
1009
|
var bl = false;
|
|
@@ -1047,7 +1081,7 @@ Drive.prototype.new_api = async function(client, manage, cover) {
|
|
|
1047
1081
|
"user_admin": []
|
|
1048
1082
|
};
|
|
1049
1083
|
o.path = o.path.replace("/api/", "/apis/");
|
|
1050
|
-
o.name +=
|
|
1084
|
+
o.name += "_manage";
|
|
1051
1085
|
this.save_file(manage + '/api.json', o, cover);
|
|
1052
1086
|
}
|
|
1053
1087
|
};
|
|
@@ -145,7 +145,7 @@ DB.prototype.update_db = async function(db, name, table, all) {
|
|
|
145
145
|
return ret;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
-
exports
|
|
148
|
+
module.exports = DB;
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
151
|
* DB数据库池
|
|
@@ -175,4 +175,4 @@ function db_admin(scope, title) {
|
|
|
175
175
|
/**
|
|
176
176
|
* @module 导出db管理器
|
|
177
177
|
*/
|
|
178
|
-
|
|
178
|
+
$.db_admin = db_admin;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const Item = require('mm_machine').Item;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Event事件驱动类
|
|
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 = "./event.json";
|
|
17
|
+
|
|
18
|
+
/* 通用项 */
|
|
19
|
+
// 配置参数
|
|
20
|
+
this.config = {
|
|
21
|
+
// 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
|
|
22
|
+
"name": "",
|
|
23
|
+
// 状态 0未启用,1启用
|
|
24
|
+
"state": 1,
|
|
25
|
+
// 标题, 介绍事件作用
|
|
26
|
+
"title": "示例事件",
|
|
27
|
+
// 描述, 用于描述该事件有什么用的
|
|
28
|
+
"description": "描述事件使用方法",
|
|
29
|
+
// 目标
|
|
30
|
+
"target": "",
|
|
31
|
+
// 阶段, 分执行前before、验证check、主要main、渲染render、执行后after阶段
|
|
32
|
+
"stage": "main",
|
|
33
|
+
// 文件路径, 当调用函数不存在时,会先从文件中加载
|
|
34
|
+
"func_file": "./main.js",
|
|
35
|
+
// 回调函数名 用于决定调用脚本的哪个函数
|
|
36
|
+
"func_name": "main",
|
|
37
|
+
// 执行顺序, 数字越小,越优先执行
|
|
38
|
+
"sort": 100,
|
|
39
|
+
// 中断循环
|
|
40
|
+
"end": true,
|
|
41
|
+
// 请求方法
|
|
42
|
+
"method": "ALL"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 新建脚本
|
|
49
|
+
* @param {String} 文件
|
|
50
|
+
*/
|
|
51
|
+
Drive.prototype.new_script = function(file) {
|
|
52
|
+
var fl = __dirname + "/script.js";
|
|
53
|
+
if (fl.hasFile()) {
|
|
54
|
+
var text = fl.loadText();
|
|
55
|
+
if (text) {
|
|
56
|
+
var l = $.slash;
|
|
57
|
+
var arr = file.split(l);
|
|
58
|
+
arr = arr.slice(arr.indexOf('app'));
|
|
59
|
+
var app_name = arr[1];
|
|
60
|
+
var event_name = arr[3];
|
|
61
|
+
if (event_name === 'client') {
|
|
62
|
+
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
63
|
+
} else if (event_name === 'manage') {
|
|
64
|
+
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
65
|
+
} else {
|
|
66
|
+
text = text.replaceAll('{0}', event_name);
|
|
67
|
+
}
|
|
68
|
+
file.saveText(text);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 新建脚本
|
|
76
|
+
* @param {String} 文件
|
|
77
|
+
*/
|
|
78
|
+
Drive.prototype.new_config = function(file) {
|
|
79
|
+
var fl = __dirname + "/config.tpl.json";
|
|
80
|
+
if (fl.hasFile()) {
|
|
81
|
+
var text = fl.loadText();
|
|
82
|
+
if (text) {
|
|
83
|
+
var l = $.slash;
|
|
84
|
+
var arr = file.split(l);
|
|
85
|
+
arr = arr.slice(arr.indexOf('app'));
|
|
86
|
+
var app_name = arr[1];
|
|
87
|
+
var event_name = arr[3];
|
|
88
|
+
if (event_name === 'client') {
|
|
89
|
+
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
90
|
+
text = text.replaceAll('{1}', '/api/' + app_name + '*');
|
|
91
|
+
} else if (event_name === 'manage') {
|
|
92
|
+
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
93
|
+
text = text.replaceAll('{1}', '/apis/' + app_name + '*');
|
|
94
|
+
} else {
|
|
95
|
+
text = text.replaceAll('{0}', event_name);
|
|
96
|
+
text = text.replaceAll('{1}', '/' + event_name + '*');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
file.saveText(text);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 执行事件
|
|
106
|
+
* @param {Object} ctx 请求上下文
|
|
107
|
+
* @param {Object} db 数据管理器
|
|
108
|
+
* @return {Object} 执行结果
|
|
109
|
+
*/
|
|
110
|
+
Drive.prototype.run = async function(ctx, db) {
|
|
111
|
+
var ret = await this.main(ctx, db);
|
|
112
|
+
return ret;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 脚本主函数
|
|
117
|
+
* @param {Object} ctx 请求上下文
|
|
118
|
+
* @param {Object} db 数据管理器
|
|
119
|
+
* @return {Object} 执行结果
|
|
120
|
+
*/
|
|
121
|
+
Drive.prototype.main = async function(ctx, db) {
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
module.exports = Drive;
|
|
@@ -88,8 +88,8 @@ Event.prototype.load = function(path) {
|
|
|
88
88
|
if (list) {
|
|
89
89
|
// 实例化一个驱动
|
|
90
90
|
var d = new Drive(dir);
|
|
91
|
-
d.loadObj(o);
|
|
92
91
|
d.filename = file;
|
|
92
|
+
d.loadObj(o);
|
|
93
93
|
list.push(d);
|
|
94
94
|
}
|
|
95
95
|
});
|
|
@@ -98,8 +98,8 @@ Event.prototype.load = function(path) {
|
|
|
98
98
|
var list = _this[key];
|
|
99
99
|
if (list) {
|
|
100
100
|
var drive = new Drive(dir);
|
|
101
|
-
drive.loadObj(obj);
|
|
102
101
|
drive.filename = file;
|
|
102
|
+
drive.loadObj(obj);
|
|
103
103
|
list.push(drive);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -150,7 +150,7 @@ Event.prototype.sort = function(stage) {
|
|
|
150
150
|
*/
|
|
151
151
|
Event.prototype.run_sub = async function(list, target, ctx, db) {
|
|
152
152
|
for (var i = 0, o; o = list[i++];) {
|
|
153
|
-
if (o.
|
|
153
|
+
if (o.config.state === 1 && target.has(o.config.target)) {
|
|
154
154
|
var ret = await o.run(ctx, db);
|
|
155
155
|
if (ret) {
|
|
156
156
|
db.ret = ret;
|
|
@@ -249,7 +249,7 @@ Event.prototype.run = async function(target, ctx, db) {
|
|
|
249
249
|
/**
|
|
250
250
|
* @module 导出Event类
|
|
251
251
|
*/
|
|
252
|
-
exports
|
|
252
|
+
module.exports = Event;
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* Event事件池
|
|
@@ -264,7 +264,7 @@ if (!$.pool.event) {
|
|
|
264
264
|
* @param {string} title 标题
|
|
265
265
|
* @return {Object} 返回一个缓存类
|
|
266
266
|
*/
|
|
267
|
-
function
|
|
267
|
+
$.event_admin = function(scope, title) {
|
|
268
268
|
if (!scope) {
|
|
269
269
|
scope = $.val.scope + '';
|
|
270
270
|
}
|
|
@@ -275,8 +275,3 @@ function event_admin(scope, title) {
|
|
|
275
275
|
}
|
|
276
276
|
return obj;
|
|
277
277
|
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* @module 导出Event管理器
|
|
281
|
-
*/
|
|
282
|
-
exports.event_admin = event_admin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// 使用api管理器
|
|
2
|
+
var api = $.api_admin('{0}', '{0}');
|
|
3
|
+
// 首次启动更新api接口;
|
|
4
|
+
api.update();
|
|
5
|
+
|
|
6
|
+
// 使用mysql数据库管理器
|
|
7
|
+
var sql = $.mysql_admin('sys', __dirname);
|
|
8
|
+
// sql.setConfig($.config.mysql);
|
|
9
|
+
// sql.open();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description 接口主函数
|
|
13
|
+
* @param {Object} ctx HTTP上下文
|
|
14
|
+
* @param {Object} db 数据管理器,如: { next: async function{}, ret: {} }
|
|
15
|
+
* @return {Object} 执行结果
|
|
16
|
+
*/
|
|
17
|
+
async function main(ctx, db) {
|
|
18
|
+
// 使用模板引擎
|
|
19
|
+
db.tpl = new $.Tpl();
|
|
20
|
+
|
|
21
|
+
// 在这定义要访问的数据库 (分布式开发时设置不同的数据库名)
|
|
22
|
+
$.push(db, sql.db(), true);
|
|
23
|
+
return api.run(ctx, db);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.main = main;
|