mm_os 3.3.0 → 4.0.0
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/LICENSE +21 -201
- package/README.md +491 -99
- package/README_EN.md +498 -0
- package/adapter/adapter.js +431 -0
- package/adapter/custom_persistence.js +660 -0
- package/adapter/mqtt.js +273 -0
- package/adapter/socket.js +113 -0
- package/adapter/web.js +67 -0
- package/adapter/websocket.js +146 -0
- package/com/api/com.json +5 -0
- package/{core/com → com}/api/config.tpl.json +8 -8
- package/com/api/drive.js +708 -0
- package/com/api/index.js +198 -0
- package/com/api/oauth.js +200 -0
- package/com/api/script.tpl.js +32 -0
- package/com/cmd/README.md +11 -0
- package/com/cmd/com.json +5 -0
- package/com/cmd/config.tpl.json +122 -0
- package/com/cmd/drive.js +1548 -0
- package/com/cmd/index.js +1066 -0
- package/com/cmd/msg.json +48 -0
- package/com/cmd/nlp.js +525 -0
- package/com/cmd/script.tpl.js +32 -0
- package/com/db/com.json +5 -0
- package/com/db/drive.js +1999 -0
- package/com/db/index.js +242 -0
- package/com/event/com.json +5 -0
- package/{core/com → com}/event/config.tpl.json +8 -8
- package/com/event/drive.js +59 -0
- package/com/event/index.js +409 -0
- package/com/event/script.tpl.js +23 -0
- package/com/mqtt/com.json +5 -0
- package/{core/com → com}/mqtt/config.tpl.json +3 -5
- package/com/mqtt/drive.js +676 -0
- package/com/mqtt/index.js +822 -0
- package/com/mqtt/mm_mqtt.js +425 -0
- package/com/mqtt/script.tpl.js +723 -0
- package/com/nav/com.json +5 -0
- package/com/nav/config.tpl.json +84 -0
- package/com/nav/drive.js +702 -0
- package/com/nav/index.js +231 -0
- package/{core/com → com}/nav/tpl/admin_pc/page_config.vue +280 -280
- package/{core/com → com}/nav/tpl/admin_pc/page_config_form.vue +194 -194
- package/com/nav/tpl/admin_pc/page_form.vue +180 -0
- package/com/nav/tpl/admin_pc/page_view.vue +124 -0
- package/com/nav/tpl/dev_pc/page_default.vue +247 -0
- package/com/nav/tpl/dev_pc/page_type.vue +313 -0
- package/com/nav/tpl/home_pc/page_default.vue +234 -0
- package/com/nav/tpl/home_pc/page_form.vue +137 -0
- package/com/nav/tpl/home_pc/page_list.vue +234 -0
- package/com/nav/tpl/home_pc/page_nav.vue +221 -0
- package/com/nav/tpl/home_pc/page_type.vue +234 -0
- package/com/nav/tpl/home_pc/page_view.vue +125 -0
- package/com/nav/tpl/home_phone/page_channel.vue +234 -0
- package/com/nav/tpl/home_phone/page_default.vue +234 -0
- package/com/nav/tpl/home_phone/page_form.vue +137 -0
- package/com/nav/tpl/home_phone/page_nav.vue +237 -0
- package/com/nav/tpl/home_phone/page_type.vue +234 -0
- package/com/nav/tpl/home_phone/page_view.vue +125 -0
- package/com/nav/viewmodel.js +446 -0
- package/com/param/com.json +5 -0
- package/{core/com → com}/param/config.tpl.json +7 -1
- package/com/param/drive.js +502 -0
- package/com/param/index.js +155 -0
- package/com/param/script.tpl.js +12 -0
- package/com/pendant/com.json +5 -0
- package/{core/com/component → com/pendant}/config.tpl.json +15 -13
- package/com/pendant/drive.js +204 -0
- package/com/pendant/index.js +441 -0
- package/com/pendant/pendant.html +16 -0
- package/com/pendant/script.tpl.js +18 -0
- package/com/socket/com.json +5 -0
- package/com/socket/config.tpl.json +12 -0
- package/com/socket/drive.js +651 -0
- package/com/socket/index.js +351 -0
- package/com/socket/script.tpl.js +41 -0
- package/com/sql/com.json +5 -0
- package/{core/com → com}/sql/config.tpl.json +13 -9
- package/com/sql/drive.js +1259 -0
- package/com/sql/index.js +150 -0
- package/com/sql/script.tpl.js +47 -0
- package/com/static/com.json +5 -0
- package/{core/com → com}/static/config.tpl.json +10 -6
- package/com/static/drive.js +194 -0
- package/com/static/index.js +226 -0
- package/com/static/script.tpl.js +28 -0
- package/com/task/com.json +5 -0
- package/{core/com → com}/task/config.tpl.json +4 -6
- package/com/task/drive.js +405 -0
- package/com/task/index.js +148 -0
- package/com/task/script.tpl.js +37 -0
- package/com/template/com.json +5 -0
- package/com/template/config.tpl.json +16 -0
- package/com/template/drive.js +80 -0
- package/com/template/index.js +141 -0
- package/com.js +156 -0
- package/common/README.md +2 -0
- package/common/handler/msg/handler.json +22 -0
- package/common/handler/msg/index.js +23 -0
- package/common/handler/player/handler.json +22 -0
- package/common/handler/player/index.js +287 -0
- package/common/handler/user/handler.json +22 -0
- package/common/handler/user/index.js +23 -0
- package/common/middleware/web_after/index.js +29 -0
- package/common/middleware/web_after/middleware.json +9 -0
- package/common/middleware/web_base/index.js +113 -0
- package/common/middleware/web_base/middleware.json +19 -0
- package/common/middleware/web_before/index.js +33 -0
- package/common/middleware/web_before/middleware.json +9 -0
- package/common/middleware/web_cors/index.js +87 -0
- package/common/middleware/web_cors/middleware.json +24 -0
- package/common/middleware/web_error/index.js +119 -0
- package/common/middleware/web_error/middleware.json +18 -0
- package/common/middleware/web_ip/index.js +15 -0
- package/common/middleware/web_ip/middleware.json +14 -0
- package/common/middleware/web_logger/index.js +156 -0
- package/common/middleware/web_logger/middleware.json +14 -0
- package/common/middleware/web_main/index.js +24 -0
- package/common/middleware/web_main/middleware.json +9 -0
- package/common/middleware/web_static/index.js +73 -0
- package/common/middleware/web_static/middleware.json +54 -0
- package/common/middleware/web_waf/index.js +385 -0
- package/common/middleware/web_waf/middleware.json +13 -0
- package/common/model/msg/index.js +88 -0
- package/common/model/msg/model.json +401 -0
- package/common/model/player/index.js +63 -0
- package/common/model/player/model.json +185 -0
- package/common/model/user/index.js +11 -0
- package/common/model/user/model.json +219 -0
- package/core/app/config.tpl.json +67 -0
- package/core/app/index.js +632 -0
- package/core/app/script.tpl.js +52 -0
- package/core/channel/index.js +899 -0
- package/core/channel/matcher.js +585 -0
- package/core/com/config.tpl.json +16 -0
- package/core/com/index.js +74 -0
- package/core/com/script.tpl.js +5 -0
- package/core/component/component.js +42 -0
- package/core/component/config.tpl.json +63 -0
- package/core/component/index.js +273 -0
- package/core/component/script.tpl.js +19 -0
- package/core/controller/config.tpl.json +14 -0
- package/core/controller/index.js +373 -0
- package/core/controller/script.tpl.js +27 -0
- package/core/factory/config.tpl.json +14 -0
- package/core/factory/entity.js +275 -0
- package/core/factory/index.js +241 -0
- package/core/factory/script.tpl.js +16 -0
- package/core/game/bat/index.js +137 -0
- package/core/game/bat/world.js +622 -0
- package/core/game/config.tpl.json +16 -0
- package/core/game/entity_admin.js +230 -0
- package/core/game/index.js +186 -0
- package/core/handler/config.tpl.json +22 -0
- package/core/handler/index.js +181 -0
- package/core/handler/script.tpl.js +23 -0
- package/core/logic/config.tpl.json +14 -0
- package/core/logic/index.js +59 -0
- package/core/logic/script.tpl.js +19 -0
- package/core/middleware/config.tpl.json +16 -0
- package/core/middleware/index.js +125 -0
- package/core/middleware/script.tpl.js +37 -0
- package/core/mod/config.tpl.json +22 -0
- package/core/mod/index.js +130 -0
- package/core/mod/script.tpl.js +34 -0
- package/core/model/config.tpl.json +219 -0
- package/core/model/index.js +272 -0
- package/core/model/model.js +27 -0
- package/core/model/script.tpl.js +20 -0
- package/core/notifier/config.tpl.json +14 -0
- package/core/notifier/index.js +77 -0
- package/core/notifier/script.tpl.js +20 -0
- package/core/plugin/config.tpl.json +24 -0
- package/core/plugin/index.js +232 -0
- package/core/plugin/script.tpl.js +51 -0
- package/core/pusher/config.tpl.json +14 -0
- package/core/pusher/index.js +161 -0
- package/core/pusher/script.tpl.js +20 -0
- package/core/room/bat/index.js +170 -0
- package/core/room/bat/room.js +524 -0
- package/core/room/config.tpl.json +20 -0
- package/core/room/index.js +249 -0
- package/core/room/room.js +61 -0
- package/core/scene/config.tpl.json +14 -0
- package/core/scene/index.js +466 -0
- package/core/scene/loop.js +1255 -0
- package/core/scene/map.js +28 -0
- package/core/scene/script.tpl.js +22 -0
- package/core/sender/config.tpl.json +14 -0
- package/core/sender/index.js +79 -0
- package/core/sender/script.tpl.js +20 -0
- package/core/service/config.tpl.json +14 -0
- package/core/service/index.js +100 -0
- package/core/service/script.tpl.js +25 -0
- package/core/store/config.tpl.json +26 -0
- package/core/store/index.js +1755 -0
- package/core/store/script.tpl.js +22 -0
- package/core/store/sql.js +1464 -0
- package/core/system/config.tpl.json +18 -0
- package/core/system/index.js +312 -0
- package/core/system/script.tpl.js +77 -0
- package/core/view/config.tpl.json +14 -0
- package/core/view/index.js +91 -0
- package/core/view/script.tpl.js +20 -0
- package/core/zone/bat/index.js +725 -0
- package/core/zone/config.tpl.json +54 -0
- package/core/zone/index.js +614 -0
- package/core/zone/script.tpl.js +10 -0
- package/core/zone/zone_bat.js +136 -0
- package/core//345/237/272/347/261/273/346/250/241/345/235/227/346/270/205/345/215/225.md +24 -0
- package/index.js +17 -314
- package/os.js +57 -0
- package/package.json +60 -58
- package/server.js +598 -0
- package/README.en.md +0 -36
- package/conf.json +0 -3
- package/core/base/mqtt/index.js +0 -1107
- package/core/base/mqtt/lib.js +0 -40
- package/core/base/web/index.js +0 -243
- package/core/com/api/com.json +0 -4
- package/core/com/api/drive.js +0 -668
- package/core/com/api/index.js +0 -108
- package/core/com/api/oauth.js +0 -158
- package/core/com/api/script.js +0 -32
- package/core/com/app/README.md +0 -3
- package/core/com/app/com.json +0 -4
- package/core/com/app/config.tpl.json +0 -16
- package/core/com/app/drive.js +0 -309
- package/core/com/app/index.js +0 -211
- package/core/com/app/script.js +0 -155
- package/core/com/cmd/com.json +0 -4
- package/core/com/cmd/config.tpl.json +0 -66
- package/core/com/cmd/drive.js +0 -513
- package/core/com/cmd/index.js +0 -354
- package/core/com/cmd/old/5w2h.js +0 -54
- package/core/com/cmd/old/drive.js +0 -423
- package/core/com/cmd/script.js +0 -11
- package/core/com/component/README.md +0 -3
- package/core/com/component/com.json +0 -4
- package/core/com/component/component.html +0 -16
- package/core/com/component/drive.js +0 -197
- package/core/com/component/index.js +0 -312
- package/core/com/component/script.js +0 -18
- package/core/com/db/com.json +0 -4
- package/core/com/db/drive.js +0 -1160
- package/core/com/db/index.js +0 -176
- package/core/com/event/com.json +0 -4
- package/core/com/event/drive.js +0 -133
- package/core/com/event/index.js +0 -345
- package/core/com/event/script.js +0 -26
- package/core/com/eventer/com.js +0 -477
- package/core/com/eventer/com.json +0 -4
- package/core/com/middleware/com.js +0 -153
- package/core/com/middleware/com.json +0 -4
- package/core/com/middleware/config.tpl.json +0 -8
- package/core/com/middleware/script.js +0 -9
- package/core/com/mqtt/com.json +0 -4
- package/core/com/mqtt/drive.js +0 -600
- package/core/com/mqtt/index.js +0 -572
- package/core/com/mqtt/mm_mqtt.js +0 -330
- package/core/com/mqtt/script.js +0 -604
- package/core/com/msg/com.js +0 -296
- package/core/com/msg/com.json +0 -4
- package/core/com/nav/com.json +0 -4
- package/core/com/nav/config.tpl.json +0 -75
- package/core/com/nav/drive.js +0 -549
- package/core/com/nav/index.js +0 -182
- package/core/com/nav/tpl/admin_pc/page_form.vue +0 -180
- package/core/com/nav/tpl/admin_pc/page_view.vue +0 -124
- package/core/com/nav/tpl/dev_pc/page_default.vue +0 -247
- package/core/com/nav/tpl/dev_pc/page_type.vue +0 -313
- package/core/com/nav/tpl/home_pc/page_default.vue +0 -234
- package/core/com/nav/tpl/home_pc/page_form.vue +0 -137
- package/core/com/nav/tpl/home_pc/page_list.vue +0 -234
- package/core/com/nav/tpl/home_pc/page_nav.vue +0 -221
- package/core/com/nav/tpl/home_pc/page_type.vue +0 -234
- package/core/com/nav/tpl/home_pc/page_view.vue +0 -125
- package/core/com/nav/tpl/home_phone/page_channel.vue +0 -234
- package/core/com/nav/tpl/home_phone/page_default.vue +0 -234
- package/core/com/nav/tpl/home_phone/page_form.vue +0 -137
- package/core/com/nav/tpl/home_phone/page_nav.vue +0 -237
- package/core/com/nav/tpl/home_phone/page_type.vue +0 -234
- package/core/com/nav/tpl/home_phone/page_view.vue +0 -125
- package/core/com/nav/viewmodel.js +0 -296
- package/core/com/param/drive.js +0 -366
- package/core/com/param/index.js +0 -80
- package/core/com/param/script.js +0 -12
- package/core/com/param/test.js +0 -98
- package/core/com/plugin/README.md +0 -3
- package/core/com/plugin/com.json +0 -4
- package/core/com/plugin/config.tpl.json +0 -26
- package/core/com/plugin/drive.js +0 -536
- package/core/com/plugin/index.js +0 -259
- package/core/com/plugin/script.js +0 -213
- package/core/com/rpc/com.json +0 -4
- package/core/com/rpc/drive.js +0 -160
- package/core/com/rpc/index.js +0 -87
- package/core/com/rpc/rpc.js +0 -118
- package/core/com/socket/com.json +0 -4
- package/core/com/socket/config.tpl.json +0 -14
- package/core/com/socket/drive.js +0 -403
- package/core/com/socket/index.js +0 -62
- package/core/com/socket/script.js +0 -42
- package/core/com/sql/drive.js +0 -1087
- package/core/com/sql/index.js +0 -83
- package/core/com/sql/script.js +0 -48
- package/core/com/static/com.json +0 -4
- package/core/com/static/drive.js +0 -220
- package/core/com/static/index.js +0 -149
- package/core/com/static/script.js +0 -28
- package/core/com/task/com.json +0 -4
- package/core/com/task/drive.js +0 -403
- package/core/com/task/index.js +0 -110
- package/core/com/task/script.js +0 -37
- package/core/com/timer/com.js +0 -217
- package/core/com/timer/com.json +0 -4
- package/core/com/tpl/com.js +0 -19
- package/core/com/tpl/com.json +0 -4
- package/lib/actions.js +0 -50
- package/lib/base.js +0 -361
- package/lib/com.js +0 -29
- package/lib/ref.js +0 -121
- package/middleware/mqtt_base/index.js +0 -10
- package/middleware/mqtt_base/middleware.json +0 -10
- package/middleware/performance/index.js +0 -151
- package/middleware/performance/middleware.json +0 -16
- package/middleware/security_audit/index.js +0 -549
- package/middleware/security_audit/middleware.json +0 -48
- package/middleware/security_headers/index.js +0 -487
- package/middleware/security_headers/middleware.json +0 -45
- package/middleware/waf/index.js +0 -348
- package/middleware/waf/middleware.json +0 -10
- package/middleware/waf_ddos/index.js +0 -520
- package/middleware/waf_ddos/middleware.json +0 -38
- package/middleware/waf_ip/index.js +0 -379
- package/middleware/waf_ip/middleware.json +0 -49
- package/middleware/waf_xss/index.js +0 -269
- package/middleware/waf_xss/middleware.json +0 -18
- package/middleware/web_after/index.js +0 -33
- package/middleware/web_after/middleware.json +0 -9
- package/middleware/web_base/index.js +0 -90
- package/middleware/web_base/middleware.json +0 -9
- package/middleware/web_before/index.js +0 -27
- package/middleware/web_before/middleware.json +0 -9
- package/middleware/web_check/index.js +0 -28
- package/middleware/web_check/middleware.json +0 -9
- package/middleware/web_main/index.js +0 -28
- package/middleware/web_main/middleware.json +0 -9
- package/middleware/web_proxy/index.js +0 -37
- package/middleware/web_proxy/middleware.json +0 -9
- package/middleware/web_render/index.js +0 -87
- package/middleware/web_render/middleware.json +0 -9
- package/middleware/web_socket/index.js +0 -34
- package/middleware/web_socket/middleware.json +0 -9
- package/middleware/web_static/index.js +0 -115
- package/middleware/web_static/middleware.json +0 -9
- /package/{core/com → com}/api/README.md +0 -0
- /package/{core/com → com}/db/README.md +0 -0
- /package/{core/com → com}/event/README.md +0 -0
- /package/{core/com → com}/mqtt/README.md +0 -0
- /package/{core/com → com}/nav/README.md +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_channel.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_default.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_lang.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_nav.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_table.vue +0 -0
- /package/{core/com → com}/nav/tpl/admin_pc/page_type.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_channel.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_config.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_form.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_nav.vue +0 -0
- /package/{core/com → com}/nav/tpl/dev_pc/page_table.vue +0 -0
- /package/{core/com → com}/nav/tpl/home_pc/page_channel.vue +0 -0
- /package/{core/com → com}/nav/tpl/home_phone/page_list.vue +0 -0
- /package/{core/com → com}/param/README.md +0 -0
- /package/{core/com/cmd → com/pendant}/README.md +0 -0
- /package/{core/com → com}/socket/README.md +0 -0
- /package/{core/com → com}/sql/README.md +0 -0
- /package/{core/com → com}/static/README.md +0 -0
- /package/{core/com → com}/task/README.md +0 -0
package/core/com/db/index.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
const Index = require('mm_machine').Index;
|
|
2
|
-
const Drive = require('./drive');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 数据库帮助类
|
|
6
|
-
* @extends {Index}
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
|
-
class DB extends Index {
|
|
10
|
-
/**
|
|
11
|
-
* 构造函数
|
|
12
|
-
* @param {Object} scope 作用域
|
|
13
|
-
* @param {String} title 标题
|
|
14
|
-
* @constructor
|
|
15
|
-
*/
|
|
16
|
-
constructor(scope, title) {
|
|
17
|
-
super(scope, __dirname);
|
|
18
|
-
this.Drive = Drive;
|
|
19
|
-
this.type = "db";
|
|
20
|
-
this.title = title;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 加载配置
|
|
26
|
-
* @param {String} path 加载的路径
|
|
27
|
-
*/
|
|
28
|
-
DB.prototype.update_config_all = async function(path) {
|
|
29
|
-
if (!path) {
|
|
30
|
-
path = "./app/";
|
|
31
|
-
}
|
|
32
|
-
// 获取所有应用路径
|
|
33
|
-
var search_dir;
|
|
34
|
-
var _this = this;
|
|
35
|
-
if (this.scope && this.scope !== $.val.scope) {
|
|
36
|
-
search_dir = this.type + '_' + this.scope;
|
|
37
|
-
var list_scope = $.dir.getAll(path, search_dir);
|
|
38
|
-
for (var i = 0, o; o = list_scope[i++];) {
|
|
39
|
-
// 获取所有配置文件
|
|
40
|
-
var list_file = $.file.getAll(o, "*" + _this.type + ".json");
|
|
41
|
-
await _this.load_list(list_file);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
// 获取所有配置文件
|
|
45
|
-
var list_file = $.file.getAll(path, "*" + _this.type + ".json");
|
|
46
|
-
await _this.load_list(list_file);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 获取驱动项
|
|
53
|
-
* @param {String} table 表
|
|
54
|
-
*/
|
|
55
|
-
DB.prototype.getObj = function(table) {
|
|
56
|
-
var obj;
|
|
57
|
-
var list = this.list;
|
|
58
|
-
for (var i = 0, o; o = list[i++];) {
|
|
59
|
-
if (o.config.table === table) {
|
|
60
|
-
obj = o;
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return obj;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 通过数据库更新配置
|
|
69
|
-
* @param {Object} db 数据库管理器
|
|
70
|
-
* @param {String} name 要更新的配置名
|
|
71
|
-
* @param {String} table 表名关键词, 支持*table后缀匹配、table*前缀匹配、*table*包含匹配
|
|
72
|
-
* @param {Boolean} cover 是否覆盖文件
|
|
73
|
-
* @return {String} 更新成功返回null, 失败返回错误提示
|
|
74
|
-
*/
|
|
75
|
-
DB.prototype.update_file = async function(db, name, table, cover = true) {
|
|
76
|
-
if (name) {
|
|
77
|
-
var o = this.get(name);
|
|
78
|
-
if (o) {
|
|
79
|
-
await o.exec('update_file', db, cover);
|
|
80
|
-
} else {
|
|
81
|
-
return "该配置不存在";
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
var list = await db.tables(table);
|
|
85
|
-
var len = list.length;
|
|
86
|
-
if (len > 0) {
|
|
87
|
-
var lt = [];
|
|
88
|
-
var len = list.length;
|
|
89
|
-
for (var i = 0; i < len; i++) {
|
|
90
|
-
var te = list[i];
|
|
91
|
-
var obj = this.getObj(te);
|
|
92
|
-
if (obj) {
|
|
93
|
-
await obj.exec('update_file', db, cover);
|
|
94
|
-
} else {
|
|
95
|
-
var drive = new Drive();
|
|
96
|
-
drive.config.table = te;
|
|
97
|
-
await drive.exec('update_file', db, cover);
|
|
98
|
-
this.list.push(drive);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
return "没有找到相关的数据表";
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return null;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* 通过配置修改数据库
|
|
110
|
-
* @param {Object} db 数据库管理器
|
|
111
|
-
* @param {String} name 要更新的配置名
|
|
112
|
-
* @param {String} table 表名关键词, 支持*table后缀匹配、table*前缀匹配、*table*包含匹配
|
|
113
|
-
* @param {Boolean} all 是否更新全部表,true为是,false为否
|
|
114
|
-
* @return {String} 更新成功返回null, 失败返回错误提示
|
|
115
|
-
*/
|
|
116
|
-
DB.prototype.update_db = async function(db, name, table, all) {
|
|
117
|
-
var ret;
|
|
118
|
-
if (name) {
|
|
119
|
-
var o = this.get(name);
|
|
120
|
-
if (o) {
|
|
121
|
-
ret = await o.exec('update_db', db);
|
|
122
|
-
} else {
|
|
123
|
-
ret = "该配置不存在";
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
var list = this.list;
|
|
127
|
-
var len = list.length;
|
|
128
|
-
if (len > 0) {
|
|
129
|
-
if (table) {
|
|
130
|
-
for (var i = 0, o; o = list[i++];) {
|
|
131
|
-
if (o.config.table === table) {
|
|
132
|
-
ret = await o.exec('update_db', db);
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
} else if (all) {
|
|
137
|
-
for (var i = 0, o; o = list[i++];) {
|
|
138
|
-
await o.exec('update_db', db);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return ret;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
module.exports = DB;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* DB数据库池
|
|
150
|
-
*/
|
|
151
|
-
if (!$.pool.db) {
|
|
152
|
-
$.pool.db = {};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* DB数据库管理器,用于创建缓存
|
|
157
|
-
* @param {String} scope 作用域
|
|
158
|
-
* @param {string} title 标题
|
|
159
|
-
* @return {Object} 返回一个缓存类
|
|
160
|
-
*/
|
|
161
|
-
function db_admin(scope, title) {
|
|
162
|
-
if (!scope) {
|
|
163
|
-
scope = $.val.scope + '';
|
|
164
|
-
}
|
|
165
|
-
var obj = $.pool.db[scope];
|
|
166
|
-
if (!obj) {
|
|
167
|
-
$.pool.db[scope] = new DB(scope, title);
|
|
168
|
-
obj = $.pool.db[scope];
|
|
169
|
-
}
|
|
170
|
-
return obj;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @module 导出db管理器
|
|
175
|
-
*/
|
|
176
|
-
$.db_admin = db_admin;
|
package/core/com/event/com.json
DELETED
package/core/com/event/drive.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
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
|
-
this.mode = 3;
|
|
20
|
-
|
|
21
|
-
/* 通用项 */
|
|
22
|
-
// 配置参数
|
|
23
|
-
this.config = {
|
|
24
|
-
// 名称, 由中英文和下“_”组成, 用于修改或卸载 例如: demo
|
|
25
|
-
"name": "",
|
|
26
|
-
// 状态 0未启用,1启用
|
|
27
|
-
"state": 1,
|
|
28
|
-
// 标题, 介绍事件作用
|
|
29
|
-
"title": "示例事件",
|
|
30
|
-
// 描述, 用于描述该事件有什么用的
|
|
31
|
-
"description": "描述事件使用方法",
|
|
32
|
-
// 目标
|
|
33
|
-
"target": "",
|
|
34
|
-
// 阶段, 分执行前before、验证check、主要main、渲染render、执行后after阶段
|
|
35
|
-
"stage": "main",
|
|
36
|
-
// 文件路径, 当调用函数不存在时,会先从文件中加载
|
|
37
|
-
"func_file": "./main.js",
|
|
38
|
-
// 回调函数名 用于决定调用脚本的哪个函数
|
|
39
|
-
"func_name": "",
|
|
40
|
-
// 执行顺序, 数字越小,越优先执行
|
|
41
|
-
"sort": 100,
|
|
42
|
-
// 中断循环
|
|
43
|
-
"end": true,
|
|
44
|
-
// 请求方法
|
|
45
|
-
"method": "ALL"
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 新建脚本
|
|
52
|
-
* @param {String} 文件
|
|
53
|
-
*/
|
|
54
|
-
Drive.prototype.new_script = function(file) {
|
|
55
|
-
var fl = __dirname + "/script.js";
|
|
56
|
-
if (fl.hasFile()) {
|
|
57
|
-
var text = fl.loadText();
|
|
58
|
-
if (text) {
|
|
59
|
-
var l = $.slash;
|
|
60
|
-
var arr = file.split(l);
|
|
61
|
-
arr = arr.slice(arr.indexOf('app'));
|
|
62
|
-
var app_name = arr[1];
|
|
63
|
-
var event_name = arr[3];
|
|
64
|
-
if (event_name === 'client') {
|
|
65
|
-
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
66
|
-
} else if (event_name === 'manage') {
|
|
67
|
-
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
68
|
-
} else {
|
|
69
|
-
text = text.replaceAll('{0}', event_name);
|
|
70
|
-
}
|
|
71
|
-
file.saveText(text);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 新建脚本
|
|
78
|
-
* @param {String} 文件
|
|
79
|
-
*/
|
|
80
|
-
Drive.prototype.new_config = function(file) {
|
|
81
|
-
var fl = __dirname + "/config.tpl.json";
|
|
82
|
-
if (fl.hasFile()) {
|
|
83
|
-
var text = fl.loadText();
|
|
84
|
-
if (text) {
|
|
85
|
-
var l = $.slash;
|
|
86
|
-
var arr = file.split(l);
|
|
87
|
-
arr = arr.slice(arr.indexOf('app'));
|
|
88
|
-
var app_name = arr[1];
|
|
89
|
-
var event_name = arr[3];
|
|
90
|
-
if (event_name === 'client') {
|
|
91
|
-
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
92
|
-
text = text.replaceAll('{1}', '/api/' + app_name + '*');
|
|
93
|
-
} else if (event_name === 'manage') {
|
|
94
|
-
text = text.replaceAll('{0}', app_name + '_' + event_name);
|
|
95
|
-
text = text.replaceAll('{1}', '/apis/' + app_name + '*');
|
|
96
|
-
} else {
|
|
97
|
-
text = text.replaceAll('{0}', event_name);
|
|
98
|
-
text = text.replaceAll('{1}', '/' + event_name + '*');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
file.saveText(text);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 执行事件
|
|
108
|
-
* @param {Object} ctx 请求上下文
|
|
109
|
-
* @param {Object} db 数据管理器
|
|
110
|
-
* @param {String} method 执行方法
|
|
111
|
-
* @return {Object} 执行结果
|
|
112
|
-
*/
|
|
113
|
-
Drive.prototype.run = async function(ctx, db, method = 'main') {
|
|
114
|
-
var ret;
|
|
115
|
-
try {
|
|
116
|
-
ret = await this[method](ctx, db);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
$.log.error("事件执行失败!", this.config.name, error);
|
|
119
|
-
}
|
|
120
|
-
return ret;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 脚本主函数
|
|
125
|
-
* @param {Object} ctx 请求上下文
|
|
126
|
-
* @param {Object} db 数据管理器
|
|
127
|
-
* @return {Object} 执行结果
|
|
128
|
-
*/
|
|
129
|
-
Drive.prototype.main = async function(ctx, db) {
|
|
130
|
-
return null;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
module.exports = Drive;
|
package/core/com/event/index.js
DELETED
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
const Index = require('mm_machine').Index;
|
|
2
|
-
const Drive = require('./drive');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Event事件类
|
|
6
|
-
* @extends {Index}
|
|
7
|
-
* @class
|
|
8
|
-
*/
|
|
9
|
-
class Event extends Index {
|
|
10
|
-
/**
|
|
11
|
-
* 构造函数
|
|
12
|
-
* @param {Object} scope 作用域
|
|
13
|
-
* @param {String} title 标题
|
|
14
|
-
* @constructor
|
|
15
|
-
*/
|
|
16
|
-
constructor(scope, title) {
|
|
17
|
-
super(scope, __dirname);
|
|
18
|
-
this.Drive = Drive;
|
|
19
|
-
this.type = "event";
|
|
20
|
-
this.title = title;
|
|
21
|
-
// 默认启用热更新
|
|
22
|
-
this.mode = 3;
|
|
23
|
-
/* === 验证 === */
|
|
24
|
-
// 验证前
|
|
25
|
-
this.list_before = [];
|
|
26
|
-
// 验证
|
|
27
|
-
this.list_check = [];
|
|
28
|
-
// 执行
|
|
29
|
-
this.list_main = [];
|
|
30
|
-
// 渲染
|
|
31
|
-
this.list_render = [];
|
|
32
|
-
// 渲染后
|
|
33
|
-
this.list_after = [];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 清除事件
|
|
39
|
-
* @param {String} stage 阶段
|
|
40
|
-
*/
|
|
41
|
-
Event.prototype.clear = function(stage) {
|
|
42
|
-
if (stage) {
|
|
43
|
-
if (this[stage]) {
|
|
44
|
-
this[stage] = [];
|
|
45
|
-
} else {
|
|
46
|
-
$.log.debug('清空失败,事件发展阶段{0}不存在!'.replace("{0}", stage));
|
|
47
|
-
}
|
|
48
|
-
} else {
|
|
49
|
-
this.list_before = [];
|
|
50
|
-
this.list_check = [];
|
|
51
|
-
this.list_main = [];
|
|
52
|
-
this.list_render = [];
|
|
53
|
-
this.list_after = [];
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 更新脚本子函数
|
|
60
|
-
*/
|
|
61
|
-
Event.prototype.update_script_sub = async function(list) {
|
|
62
|
-
for (var i = 0; i < list.length; i++) {
|
|
63
|
-
var o = list[i];
|
|
64
|
-
if (o.config.state === 1) {
|
|
65
|
-
await o.exec('load');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 更新脚本
|
|
72
|
-
*/
|
|
73
|
-
Event.prototype.update_script = async function() {
|
|
74
|
-
this.update_script_sub(this.list_before);
|
|
75
|
-
this.update_script_sub(this.list_check);
|
|
76
|
-
this.update_script_sub(this.list_main);
|
|
77
|
-
this.update_script_sub(this.list_render);
|
|
78
|
-
this.update_script_sub(this.list_after);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 加载项
|
|
83
|
-
* @param {String} dir 文件路径
|
|
84
|
-
* @param {Object} cg 配置参数
|
|
85
|
-
* @param {String} file 配置文件
|
|
86
|
-
*/
|
|
87
|
-
Event.prototype.load_item = async function(dir, cg, file) {
|
|
88
|
-
if (this.Drive) {
|
|
89
|
-
var drive = new this.Drive(dir, this.dir_base.fullname());
|
|
90
|
-
drive.mode = this.mode;
|
|
91
|
-
if (cg) {
|
|
92
|
-
await drive.exec('load_config', file, cg.name);
|
|
93
|
-
await drive.exec('set_config', cg);
|
|
94
|
-
} else {
|
|
95
|
-
await drive.exec('load_config', file);
|
|
96
|
-
}
|
|
97
|
-
var key = 'list_' + drive.config.stage;
|
|
98
|
-
var list = this[key];
|
|
99
|
-
if (!list) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
list.push(drive);
|
|
103
|
-
return drive;
|
|
104
|
-
} else {
|
|
105
|
-
var json = file.loadJson();
|
|
106
|
-
if (!json) {
|
|
107
|
-
var fl = this.dir_base + "/config.tpl.json";
|
|
108
|
-
if (fl.hasFile()) {
|
|
109
|
-
fl.copyFile(file);
|
|
110
|
-
json = file.loadJson();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (json) {
|
|
114
|
-
var key = 'list_' + json.stage;
|
|
115
|
-
var list = this[key];
|
|
116
|
-
if (!list) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
list.push(json);
|
|
120
|
-
}
|
|
121
|
-
return json;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* 事件排序
|
|
127
|
-
* @param {String} list 列表
|
|
128
|
-
*/
|
|
129
|
-
Event.prototype.sort_sub = function(list) {
|
|
130
|
-
list.sort(function(o1, o2) {
|
|
131
|
-
var sort = o1.config.sort - o2.config.sort;
|
|
132
|
-
if (sort === 0) {
|
|
133
|
-
sort = o2.config.target.length - o1.config.target.length;
|
|
134
|
-
}
|
|
135
|
-
return sort;
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* 事件排序
|
|
141
|
-
* @param {String} stage 阶段
|
|
142
|
-
*/
|
|
143
|
-
Event.prototype.sort = function(stage) {
|
|
144
|
-
if (stage) {
|
|
145
|
-
if (this[stage]) {
|
|
146
|
-
this[stage] = [];
|
|
147
|
-
} else {
|
|
148
|
-
$.log.debug('清空失败,事件发展阶段{0}不存在!'.replace("{0}", stage));
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
this.sort_sub(this.list_before);
|
|
152
|
-
this.sort_sub(this.list_check);
|
|
153
|
-
this.sort_sub(this.list_main);
|
|
154
|
-
this.sort_sub(this.list_render);
|
|
155
|
-
this.sort_sub(this.list_after);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* 执行事件
|
|
161
|
-
*/
|
|
162
|
-
Event.prototype.doing = async function(o, ctx, db) {
|
|
163
|
-
var ret = o.run(ctx, db);
|
|
164
|
-
if (types.isPromise(ret)) {
|
|
165
|
-
ret = await ret;
|
|
166
|
-
}
|
|
167
|
-
if (this.mode > 4) {
|
|
168
|
-
o.exec('reload', o.filename);
|
|
169
|
-
}
|
|
170
|
-
return ret;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* 执行函数
|
|
175
|
-
* @param {Array} list 列表
|
|
176
|
-
* @param {String} target 目标
|
|
177
|
-
* @param {Object} ctx 请求上下文
|
|
178
|
-
* @param {Object} db 数据管理器
|
|
179
|
-
* @return {Object} 执行结果
|
|
180
|
-
*/
|
|
181
|
-
Event.prototype.run_sub = async function(list, target, ctx, db) {
|
|
182
|
-
for (var i = 0, o; o = list[i++];) {
|
|
183
|
-
if (o.config.state === 1 && target.has(o.config.target)) {
|
|
184
|
-
var ret = await o.run(ctx, db);
|
|
185
|
-
if (this.mode > 4) {
|
|
186
|
-
o.exec('reload', o.filename);
|
|
187
|
-
}
|
|
188
|
-
if (ret) {
|
|
189
|
-
db.ret = ret;
|
|
190
|
-
if (o.config.end) {
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return db.ret;
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* 之前
|
|
201
|
-
* @param {String} target 目标
|
|
202
|
-
* @param {Object} ctx 请求上下文
|
|
203
|
-
* @param {Object} db 数据管理器
|
|
204
|
-
* @return {Object} 执行结果
|
|
205
|
-
*/
|
|
206
|
-
Event.prototype.before = async function(target, ctx, db) {
|
|
207
|
-
return await this.run_sub(this.list_before, target, ctx, db);
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* 验证
|
|
212
|
-
* @param {String} target 目标
|
|
213
|
-
* @param {Object} ctx 请求上下文
|
|
214
|
-
* @param {Object} db 数据管理器
|
|
215
|
-
* @return {Object} 执行结果
|
|
216
|
-
*/
|
|
217
|
-
Event.prototype.check = async function(target, ctx, db) {
|
|
218
|
-
return await this.run_sub(this.list_check, target, ctx, db);
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* 主要
|
|
223
|
-
* @param {String} target 目标
|
|
224
|
-
* @param {Object} ctx 请求上下文
|
|
225
|
-
* @param {Object} db 数据管理器
|
|
226
|
-
* @return {Object} 执行结果
|
|
227
|
-
*/
|
|
228
|
-
Event.prototype.main = async function(target, ctx, db) {
|
|
229
|
-
return await this.run_sub(this.list_main, target, ctx, db);
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* 渲染
|
|
234
|
-
* @param {String} target 目标
|
|
235
|
-
* @param {Object} ctx 请求上下文
|
|
236
|
-
* @param {Object} db 数据管理器
|
|
237
|
-
* @return {Object} 执行结果
|
|
238
|
-
*/
|
|
239
|
-
Event.prototype.render = async function(target, ctx, db) {
|
|
240
|
-
return await this.run_sub(this.list_render, target, ctx, db);
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* 之后
|
|
245
|
-
* @param {String} target 目标
|
|
246
|
-
* @param {Object} ctx 请求上下文
|
|
247
|
-
* @param {Object} db 数据管理器
|
|
248
|
-
* @return {Object} 执行结果
|
|
249
|
-
*/
|
|
250
|
-
Event.prototype.after = async function(target, ctx, db) {
|
|
251
|
-
return await this.run_sub(this.list_after, target, ctx, db);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* 执行事件
|
|
256
|
-
* @param {String} target 目标
|
|
257
|
-
* @param {Object} ctx 请求上下文
|
|
258
|
-
* @param {Object} db 数据管理器
|
|
259
|
-
* @return {Object} 执行结果
|
|
260
|
-
*/
|
|
261
|
-
Event.prototype.run = async function(target, ctx, db) {
|
|
262
|
-
if (!db) {
|
|
263
|
-
db = {
|
|
264
|
-
ret: null
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
var ret = await this.before(target, ctx, db);
|
|
268
|
-
if (!ret) {
|
|
269
|
-
ret = await this.check(target, ctx, db);
|
|
270
|
-
if (!ret) {
|
|
271
|
-
ret = await this.main(target, ctx, db);
|
|
272
|
-
}
|
|
273
|
-
ret = await this.render(target, ctx, db);
|
|
274
|
-
if (ret) {
|
|
275
|
-
ret = await this.after(target, ctx, db);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return ret;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* @description 获取事件
|
|
283
|
-
* @param {String} name 名称
|
|
284
|
-
* @param {String} event_type 事件类型
|
|
285
|
-
* @return {Object} 返回单项配置
|
|
286
|
-
*/
|
|
287
|
-
Event.prototype.get = function(name, event_type = 'main') {
|
|
288
|
-
var obj;
|
|
289
|
-
var lt = this['list_' + event_type];
|
|
290
|
-
var len = lt.length;
|
|
291
|
-
for (var i = 0; i < len; i++) {
|
|
292
|
-
var o = lt[i];
|
|
293
|
-
if (name === o.config.name) {
|
|
294
|
-
obj = o;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return obj;
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* @description 重载脚本和配置
|
|
303
|
-
* @param {String} file 文件名
|
|
304
|
-
* @return {String} 重载失败返回错误提示,重载成功返回null
|
|
305
|
-
*/
|
|
306
|
-
Event.prototype.reload = async function(name, event_type = 'main') {
|
|
307
|
-
var o = this.get(name, event_type);
|
|
308
|
-
if (o) {
|
|
309
|
-
await o.exec('reload');
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
return '没有找到模块';
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* @module 导出Event类
|
|
317
|
-
*/
|
|
318
|
-
module.exports = Event;
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Event事件池
|
|
322
|
-
*/
|
|
323
|
-
if (!$.pool.event) {
|
|
324
|
-
$.pool.event = {};
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function event_admin(scope, title) {
|
|
328
|
-
if (!scope) {
|
|
329
|
-
scope = $.val.scope + '';
|
|
330
|
-
}
|
|
331
|
-
var obj = $.pool.event[scope];
|
|
332
|
-
if (!obj) {
|
|
333
|
-
$.pool.event[scope] = new Event(scope, title);
|
|
334
|
-
obj = $.pool.event[scope];
|
|
335
|
-
}
|
|
336
|
-
return obj;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Event管理器,用于创建缓存
|
|
341
|
-
* @param {String} scope 作用域
|
|
342
|
-
* @param {string} title 标题
|
|
343
|
-
* @return {Object} 返回一个缓存类
|
|
344
|
-
*/
|
|
345
|
-
$.event_admin = event_admin;
|
package/core/com/event/script.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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;
|