mm_os 3.3.1 → 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/{core/com → com}/event/README.md +4 -4
- package/com/event/com.json +5 -0
- package/{core/com → com}/event/config.tpl.json +18 -18
- 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 -333
- package/os.js +57 -0
- package/package.json +58 -58
- package/server.js +598 -0
- package/README.en.md +0 -36
- package/conf.json +0 -3
- package/core/base/mqtt/index.js +0 -1110
- package/core/base/mqtt/lib.js +0 -40
- package/core/base/web/index.js +0 -245
- 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 -154
- 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/cors/index.js +0 -119
- package/middleware/cors/middleware.json +0 -20
- package/middleware/csrf/index.js +0 -202
- package/middleware/csrf/middleware.json +0 -24
- package/middleware/ip_firewall/index.js +0 -476
- package/middleware/ip_firewall/middleware.json +0 -109
- package/middleware/mqtt_base/index.js +0 -10
- package/middleware/mqtt_base/middleware.json +0 -11
- package/middleware/security_audit/index.js +0 -543
- package/middleware/security_audit/middleware.json +0 -48
- package/middleware/waf/index.js +0 -343
- 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_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 -10
- package/middleware/web_base/index.js +0 -90
- package/middleware/web_base/middleware.json +0 -10
- package/middleware/web_before/index.js +0 -27
- package/middleware/web_before/middleware.json +0 -10
- package/middleware/web_check/index.js +0 -28
- package/middleware/web_check/middleware.json +0 -10
- package/middleware/web_main/index.js +0 -28
- package/middleware/web_main/middleware.json +0 -10
- package/middleware/web_proxy/index.js +0 -37
- package/middleware/web_proxy/middleware.json +0 -10
- package/middleware/web_render/index.js +0 -87
- package/middleware/web_render/middleware.json +0 -10
- package/middleware/web_socket/index.js +0 -34
- package/middleware/web_socket/middleware.json +0 -10
- package/middleware/web_static/index.js +0 -115
- package/middleware/web_static/middleware.json +0 -10
- /package/{core/com → com}/api/README.md +0 -0
- /package/{core/com → com}/db/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
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
const {
|
|
2
|
+
Drive
|
|
3
|
+
} = require('mm_machine');
|
|
4
|
+
const Mod = require('./model.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 数据模型基类
|
|
8
|
+
* 提供数据存储、查询、修改等核心功能
|
|
9
|
+
*/
|
|
10
|
+
class Model extends Drive {
|
|
11
|
+
static config = {
|
|
12
|
+
// 模型名称
|
|
13
|
+
'name': 'default',
|
|
14
|
+
// 标题
|
|
15
|
+
'title': '用户账户模型',
|
|
16
|
+
// 描述
|
|
17
|
+
'description': '定于用户账户模型的组件',
|
|
18
|
+
// 主文件
|
|
19
|
+
'main': '',
|
|
20
|
+
// 状态 0:禁用 1:启用
|
|
21
|
+
'state': 1,
|
|
22
|
+
// 排序,越小越靠前
|
|
23
|
+
'sort': 100,
|
|
24
|
+
// 模型包含字段
|
|
25
|
+
'fields': {}
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 构造函数
|
|
29
|
+
* @param {object} config 配置参数
|
|
30
|
+
* @param {object} parent 父对象
|
|
31
|
+
*/
|
|
32
|
+
constructor(config, parent) {
|
|
33
|
+
super({ ...Model.config, ...config || {} }, parent);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 获取模板目录
|
|
39
|
+
* @returns {string} 模板目录
|
|
40
|
+
*/
|
|
41
|
+
Model.prototype.getTplDir = function() {
|
|
42
|
+
return __dirname;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 初始化核心组件
|
|
47
|
+
* @param {object} eventer 事件管理器
|
|
48
|
+
* @param {object} logger 日志管理器
|
|
49
|
+
*/
|
|
50
|
+
Model.prototype._initCore = async function (eventer, logger) {
|
|
51
|
+
// 初始化依赖项
|
|
52
|
+
if (logger) {
|
|
53
|
+
this.setLogger(logger);
|
|
54
|
+
}
|
|
55
|
+
if (eventer) {
|
|
56
|
+
this.getEventer = function () {
|
|
57
|
+
return eventer;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 校验字段值是否在范围内
|
|
64
|
+
* @param {number} value 要校验的值
|
|
65
|
+
* @param {object} rule 字段配置对象
|
|
66
|
+
* @param {string} key 字段名
|
|
67
|
+
* @throws {TypeError} 校验失败时抛出错误
|
|
68
|
+
*/
|
|
69
|
+
Model.prototype._checkRange = function (value, rule, key) {
|
|
70
|
+
// 参数校验
|
|
71
|
+
if (typeof rule !== 'object' || Array.isArray(rule)) {
|
|
72
|
+
throw new TypeError('字段配置必须是对象');
|
|
73
|
+
}
|
|
74
|
+
if (typeof key !== 'string') {
|
|
75
|
+
throw new TypeError('字段名必须是字符串');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (rule.min !== undefined && value < rule.min) {
|
|
79
|
+
throw new TypeError(`字段 ${key} 必须大于等于 ${rule.min}`);
|
|
80
|
+
}
|
|
81
|
+
if (rule.max !== undefined && value > rule.max) {
|
|
82
|
+
throw new TypeError(`字段 ${key} 必须小于等于 ${rule.max}`);
|
|
83
|
+
}
|
|
84
|
+
// 校验枚举值
|
|
85
|
+
if (rule.enum !== undefined && !rule.enum.includes(value)) {
|
|
86
|
+
throw new TypeError(`字段 ${key} 的值必须是 ${rule.enum.join('、')}`);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 验证必填字段
|
|
92
|
+
* @param {object} fields 字段配置
|
|
93
|
+
* @param {object} data 数据
|
|
94
|
+
*/
|
|
95
|
+
Model.prototype._checkRequired = function (fields, data) {
|
|
96
|
+
for (var key in fields) {
|
|
97
|
+
var rule = fields[key];
|
|
98
|
+
if (rule.required && (data[key] === undefined || data[key] === null)) {
|
|
99
|
+
throw new TypeError(`字段 ${key} 是必填字段`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 验证字段类型
|
|
106
|
+
* @param {*} value 字段值
|
|
107
|
+
* @param {object} rule 规则
|
|
108
|
+
* @param {string} key 字段名
|
|
109
|
+
*/
|
|
110
|
+
Model.prototype._checkType = function (value, rule, key) {
|
|
111
|
+
const TYPE_CHECKS = {
|
|
112
|
+
'number': typeof value === 'number',
|
|
113
|
+
'string': typeof value === 'string',
|
|
114
|
+
'boolean': typeof value === 'boolean',
|
|
115
|
+
'object': typeof value === 'object' && !Array.isArray(value),
|
|
116
|
+
'array': Array.isArray(value)
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (!TYPE_CHECKS[rule.type]) {
|
|
120
|
+
const TYPE_NAMES = {
|
|
121
|
+
'number': '数字',
|
|
122
|
+
'string': '字符串',
|
|
123
|
+
'boolean': '布尔值',
|
|
124
|
+
'object': '对象',
|
|
125
|
+
'array': '数组'
|
|
126
|
+
};
|
|
127
|
+
throw new TypeError(`字段 ${key} 必须是${TYPE_NAMES[rule.type]}`);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 验证字符串长度
|
|
133
|
+
* @param {string} value 字段值
|
|
134
|
+
* @param {object} rule 规则
|
|
135
|
+
* @param {string} key 字段名
|
|
136
|
+
*/
|
|
137
|
+
Model.prototype._checkStringLength = function (value, rule, key) {
|
|
138
|
+
if (rule.min_length !== undefined && value.length < rule.min_length) {
|
|
139
|
+
throw new TypeError(`字段 ${key} 长度不能小于 ${rule.min_length}`);
|
|
140
|
+
}
|
|
141
|
+
if (rule.max_length !== undefined && value.length > rule.max_length) {
|
|
142
|
+
throw new TypeError(`字段 ${key} 长度不能大于 ${rule.max_length}`);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 验证单个字段
|
|
148
|
+
* @param {*} value 字段值
|
|
149
|
+
* @param {object} rule 规则
|
|
150
|
+
* @param {string} key 字段名
|
|
151
|
+
*/
|
|
152
|
+
Model.prototype._checkField = function (value, rule, key) {
|
|
153
|
+
this._checkType(value, rule, key);
|
|
154
|
+
if (rule.type === 'string') {
|
|
155
|
+
this._checkStringLength(value, rule, key);
|
|
156
|
+
if (rule.pattern && !rule.pattern.test(value)) {
|
|
157
|
+
throw new TypeError(`字段 ${key} 格式不正确`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (rule.min !== undefined || rule.max !== undefined || rule.enum !== undefined) {
|
|
161
|
+
this._checkRange(value, rule, key);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 数据校验方法
|
|
167
|
+
* @param {object} data 要校验的数据
|
|
168
|
+
* @param {string} type 校验类型
|
|
169
|
+
* @returns {boolean} 校验结果
|
|
170
|
+
* @throws {TypeError} 校验失败时抛出错误
|
|
171
|
+
*/
|
|
172
|
+
Model.prototype._check = function (data, type = 'add') {
|
|
173
|
+
if (typeof data !== 'object' || Array.isArray(data)) {
|
|
174
|
+
throw new TypeError('校验数据必须是对象');
|
|
175
|
+
}
|
|
176
|
+
if (typeof type !== 'string') {
|
|
177
|
+
throw new TypeError('校验类型必须是字符串');
|
|
178
|
+
}
|
|
179
|
+
var fields = this.config.fields;
|
|
180
|
+
if (!fields || typeof fields !== 'object') {
|
|
181
|
+
throw new TypeError('字段配置不存在');
|
|
182
|
+
}
|
|
183
|
+
if (type === 'add') {
|
|
184
|
+
this._checkRequired(fields, data);
|
|
185
|
+
}
|
|
186
|
+
for (var key in data) {
|
|
187
|
+
var rule = fields[key];
|
|
188
|
+
if (rule) {
|
|
189
|
+
this._checkField(data[key], rule, key);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 创建模型实例
|
|
197
|
+
* @param {object} data 实例数据
|
|
198
|
+
* @returns {object} 新实例
|
|
199
|
+
* @throws {TypeError} 参数类型错误时抛出
|
|
200
|
+
*/
|
|
201
|
+
Model.prototype.create = function (data = {}) {
|
|
202
|
+
// 参数校验
|
|
203
|
+
if (typeof data !== 'object' || Array.isArray(data)) {
|
|
204
|
+
throw new TypeError('实例数据必须是对象');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var model = new Mod();
|
|
208
|
+
var fields = this.config.fields;
|
|
209
|
+
|
|
210
|
+
// 数据校验
|
|
211
|
+
if (this._check(data, 'add')) {
|
|
212
|
+
for (var key in fields) {
|
|
213
|
+
model[key] = this._getDefaultValue(data[key], fields[key]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return model;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 获取默认值
|
|
222
|
+
* @param {any} dataValue 数据值
|
|
223
|
+
* @param {object} rule 字段规则
|
|
224
|
+
* @returns {any} 默认值
|
|
225
|
+
* @private
|
|
226
|
+
*/
|
|
227
|
+
Model.prototype._getDefaultValue = function (dataValue, rule) {
|
|
228
|
+
if (dataValue !== undefined) {
|
|
229
|
+
return dataValue;
|
|
230
|
+
}
|
|
231
|
+
if (rule.default !== undefined) {
|
|
232
|
+
return rule.default;
|
|
233
|
+
}
|
|
234
|
+
var typeDefaults = {
|
|
235
|
+
'number': 0,
|
|
236
|
+
'string': '',
|
|
237
|
+
'boolean': false,
|
|
238
|
+
'object': {},
|
|
239
|
+
'array': []
|
|
240
|
+
};
|
|
241
|
+
return typeDefaults[rule.type] || null;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* 更新模型实例
|
|
246
|
+
* @param {object} model 要更新的模型实例
|
|
247
|
+
* @param {object} data 更新数据
|
|
248
|
+
* @returns {object} 更新后的实例
|
|
249
|
+
* @throws {TypeError} 参数类型错误时抛出
|
|
250
|
+
*/
|
|
251
|
+
Model.prototype.update = function (model, data = {}) {
|
|
252
|
+
// 参数校验
|
|
253
|
+
if (typeof model !== 'object' || Array.isArray(model)) {
|
|
254
|
+
throw new TypeError('模型实例必须是对象');
|
|
255
|
+
}
|
|
256
|
+
if (typeof data !== 'object' || Array.isArray(data)) {
|
|
257
|
+
throw new TypeError('更新数据必须是对象');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// 数据校验
|
|
261
|
+
if (this._check(data, 'update')) {
|
|
262
|
+
for (var key in data) {
|
|
263
|
+
if (key in model) {
|
|
264
|
+
model[key] = data[key];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return model;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
exports.Model = Model;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模型基类
|
|
3
|
+
*/
|
|
4
|
+
class Model {
|
|
5
|
+
#is_dirty = false;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 模型构造函数
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 检查模型是否脏数据
|
|
16
|
+
* @param {boolean} is_dirty 是否脏数据
|
|
17
|
+
* @returns {boolean} 是否脏数据
|
|
18
|
+
*/
|
|
19
|
+
isDirty(is_dirty) {
|
|
20
|
+
if (is_dirty !== undefined) {
|
|
21
|
+
this.#is_dirty = is_dirty;
|
|
22
|
+
}
|
|
23
|
+
return this.#is_dirty;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = Model;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 富血模型
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
/**
|
|
6
|
+
* 添加消息模型方法
|
|
7
|
+
* @param {object} model 消息模型实例
|
|
8
|
+
*/
|
|
9
|
+
addMethods(model) {
|
|
10
|
+
// /**
|
|
11
|
+
// * 发送消息
|
|
12
|
+
// * @param {string} content 消息内容
|
|
13
|
+
// * @param {string} priority 消息优先级
|
|
14
|
+
// */
|
|
15
|
+
// model.send = function (content, priority = $.const.PRIORITIES.normal) {
|
|
16
|
+
// this.log('debug', '发送消息', { content, priority });
|
|
17
|
+
// // 实际发送消息的逻辑
|
|
18
|
+
// };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const { Drive } = require('mm_machine');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 通知器
|
|
5
|
+
* 进行邮箱、短信等通知
|
|
6
|
+
*/
|
|
7
|
+
class Notifier extends Drive {
|
|
8
|
+
static config = {
|
|
9
|
+
// 通知器名称
|
|
10
|
+
name: 'default'
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 构造函数
|
|
14
|
+
* @param {object} config 配置参数
|
|
15
|
+
*/
|
|
16
|
+
constructor(config) {
|
|
17
|
+
super({ ...Notifier.config, ...config || {} });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 获取模板目录
|
|
23
|
+
* @returns {string} 模板目录
|
|
24
|
+
*/
|
|
25
|
+
Notifier.prototype.getTplDir = function() {
|
|
26
|
+
return __dirname;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 初始化核心
|
|
31
|
+
* @param {object} eventer 事件总线
|
|
32
|
+
* @param {object} logger 日志管理器
|
|
33
|
+
*/
|
|
34
|
+
Notifier.prototype._initCore = async function(eventer, logger) {
|
|
35
|
+
// 初始化依赖项
|
|
36
|
+
if (logger) {
|
|
37
|
+
this.setLogger(logger);
|
|
38
|
+
}
|
|
39
|
+
if (eventer) {
|
|
40
|
+
this.getEventer = function () {
|
|
41
|
+
return eventer;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 启动
|
|
48
|
+
*/
|
|
49
|
+
Notifier.prototype._start = async function() {
|
|
50
|
+
this.log('info', 'started');
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 停止模型
|
|
55
|
+
*/
|
|
56
|
+
Notifier.prototype._stop = async function() {
|
|
57
|
+
this.log('info', 'stopped');
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 销毁
|
|
62
|
+
*/
|
|
63
|
+
Notifier.prototype._destroy = function() {
|
|
64
|
+
try {
|
|
65
|
+
// 清理存储引用
|
|
66
|
+
this._store = {};
|
|
67
|
+
this._data_validator = null;
|
|
68
|
+
|
|
69
|
+
this.log('info', 'destroyed');
|
|
70
|
+
// 移除所有监听器
|
|
71
|
+
this.removeAllListeners();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
this.log('error', `销毁失败`, error);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.Notifier = Notifier;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通知器
|
|
3
|
+
*/
|
|
4
|
+
module.exports = {
|
|
5
|
+
/**
|
|
6
|
+
* 初始化
|
|
7
|
+
* @param {object} eventer 事件总线
|
|
8
|
+
*/
|
|
9
|
+
async _init(eventer) {
|
|
10
|
+
// this.log('debug', '初始化');
|
|
11
|
+
},
|
|
12
|
+
/**
|
|
13
|
+
* 主要逻辑
|
|
14
|
+
* @param {...any} args 参数列表
|
|
15
|
+
*/
|
|
16
|
+
async main(...args) {
|
|
17
|
+
// 主要代码写在这
|
|
18
|
+
this.log('debug', 'notifier main 被调用', { args });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
// 名称
|
|
3
|
+
"name": "${name}",
|
|
4
|
+
// 标题
|
|
5
|
+
"title": "${title || '战斗插件'}",
|
|
6
|
+
// 描述
|
|
7
|
+
"description": "${description || '介绍插件的作用'}",
|
|
8
|
+
// 版本
|
|
9
|
+
"version": "${version || '1.0.0'}",
|
|
10
|
+
// 作者
|
|
11
|
+
"author": "${author || '(匿名)'}",
|
|
12
|
+
// 用于什么应用
|
|
13
|
+
"app": "${app || 'sys'}",
|
|
14
|
+
// 主文件
|
|
15
|
+
"main": "${main || 'index.js'}",
|
|
16
|
+
// 状态 0:禁用 1:启用
|
|
17
|
+
"state": 1,
|
|
18
|
+
// 排序,越小越靠前
|
|
19
|
+
"sort": 100,
|
|
20
|
+
// git仓库地址
|
|
21
|
+
"git": "${git || ''}",
|
|
22
|
+
// 依赖的npm module
|
|
23
|
+
"dependencies": []
|
|
24
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
const {
|
|
2
|
+
Drive
|
|
3
|
+
} = require('mm_machine');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 插件基类
|
|
7
|
+
* 负责管理插件的生命周期、资源加载和依赖管理
|
|
8
|
+
*/
|
|
9
|
+
class Plugin extends Drive {
|
|
10
|
+
static config = {
|
|
11
|
+
// 插件名称
|
|
12
|
+
name: '',
|
|
13
|
+
// 插件标题
|
|
14
|
+
title: '插件',
|
|
15
|
+
// 插件描述
|
|
16
|
+
description: '介绍插件的作用',
|
|
17
|
+
// 插件版本
|
|
18
|
+
version: '1.0.0',
|
|
19
|
+
// 用于什么应用
|
|
20
|
+
app: 'tool',
|
|
21
|
+
// 作者
|
|
22
|
+
author: 'qww',
|
|
23
|
+
// 主文件
|
|
24
|
+
main: './index.js',
|
|
25
|
+
// git仓库地址
|
|
26
|
+
git: '',
|
|
27
|
+
// 依赖的npm模块
|
|
28
|
+
dependencies: []
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 构造函数
|
|
32
|
+
* @param {object} config 配置参数
|
|
33
|
+
* @param {object} parent 父对象
|
|
34
|
+
*/
|
|
35
|
+
constructor(config, parent) {
|
|
36
|
+
super({ ...Plugin.config, ...config || {} }, parent);
|
|
37
|
+
this.options = {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 获取模板目录
|
|
44
|
+
* @returns {string} 模板目录
|
|
45
|
+
*/
|
|
46
|
+
Plugin.prototype.getTplDir = function () {
|
|
47
|
+
return __dirname;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 初始化核心
|
|
52
|
+
* @param {object} app 应用实例
|
|
53
|
+
* @param {object} eventer 事件管理器
|
|
54
|
+
* @param {object} logger 日志管理器
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
Plugin.prototype._initCore = async function (app, eventer, logger) {
|
|
58
|
+
// 初始化依赖项
|
|
59
|
+
if (logger) {
|
|
60
|
+
this.setLogger(logger);
|
|
61
|
+
}
|
|
62
|
+
if (eventer) {
|
|
63
|
+
this.getEventer = function () {
|
|
64
|
+
return eventer;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (app) {
|
|
68
|
+
this.getApp = function () {
|
|
69
|
+
return app;
|
|
70
|
+
};
|
|
71
|
+
this._db = app.db;
|
|
72
|
+
this._cache = app.cache;
|
|
73
|
+
this._filer = app.filer;
|
|
74
|
+
}
|
|
75
|
+
// // 初始化管理
|
|
76
|
+
// await this._initManager();
|
|
77
|
+
// // 加载资源
|
|
78
|
+
// await this._loadSources();
|
|
79
|
+
// // 初始化资源
|
|
80
|
+
// await this._initSources();
|
|
81
|
+
// 初始化配置
|
|
82
|
+
this._initOptions();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 获取插件配置
|
|
87
|
+
* @returns {object} 插件配置
|
|
88
|
+
*/
|
|
89
|
+
Plugin.prototype.getOptions = function () {
|
|
90
|
+
return this.options;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 插件初始化之后
|
|
95
|
+
*/
|
|
96
|
+
Plugin.prototype._initOptions = function () {
|
|
97
|
+
var options = this.getConfigOptions();
|
|
98
|
+
this.options = this.mergeOptions(options);
|
|
99
|
+
this.backupOptions();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 获取配置参数
|
|
104
|
+
* @return {Object} 返回配置参数
|
|
105
|
+
*/
|
|
106
|
+
Plugin.prototype.getConfigOptions = function () {
|
|
107
|
+
var op = this.config.options || [];
|
|
108
|
+
var dict = {};
|
|
109
|
+
for (var i = 0; i < op.length; i++) {
|
|
110
|
+
var o = op[i];
|
|
111
|
+
if (o.type === "number") {
|
|
112
|
+
var val = o.value === 'null' ? '0' : o.value;
|
|
113
|
+
dict[o.name] = Number(val || '0');
|
|
114
|
+
} else if (o.type === "boolean") {
|
|
115
|
+
var val = false;
|
|
116
|
+
if (o.value) {
|
|
117
|
+
if (typeof (o.value) == "string") {
|
|
118
|
+
if (o.value == '1' || o.value == 'true') {
|
|
119
|
+
val = true;
|
|
120
|
+
}
|
|
121
|
+
} else if (typeof (o.value) == "boolean") {
|
|
122
|
+
val = o.value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
dict[o.name] = val;
|
|
126
|
+
} else if (o.type === "object") {
|
|
127
|
+
var val = o.value === 'null' ? '{}' : o.value;
|
|
128
|
+
dict[o.name] = o.value.toJSON();
|
|
129
|
+
} else if (o.type === "array") {
|
|
130
|
+
var val = o.value === 'null' ? '[]' : o.value;
|
|
131
|
+
dict[o.name] = o.value.toJSON();
|
|
132
|
+
} else if (o.value === "null") {
|
|
133
|
+
dict[o.name] = null;
|
|
134
|
+
} else if (o.type === "string") {
|
|
135
|
+
dict[o.name] = o.value || "";
|
|
136
|
+
} else {
|
|
137
|
+
dict[o.name] = o.value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return dict;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 设计配置
|
|
145
|
+
* @param {Object} 设置配置
|
|
146
|
+
* @return {Object} 返回配置参数
|
|
147
|
+
*/
|
|
148
|
+
Plugin.prototype.designOptions = function (body) {
|
|
149
|
+
var cg = this.config;
|
|
150
|
+
if (Array.isArray(body)) {
|
|
151
|
+
cg.options = body;
|
|
152
|
+
} else {
|
|
153
|
+
var options = cg.options || [];
|
|
154
|
+
var option = options.getObj({
|
|
155
|
+
name: body.name
|
|
156
|
+
});
|
|
157
|
+
if (option) {
|
|
158
|
+
Object.assign(option, body);
|
|
159
|
+
} else {
|
|
160
|
+
options.push(body);
|
|
161
|
+
}
|
|
162
|
+
cg.options = options;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 保存配置
|
|
168
|
+
*/
|
|
169
|
+
Plugin.prototype.saveOptions = function (options) {
|
|
170
|
+
this.options = options;
|
|
171
|
+
this.backupOptions();
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 保存配置
|
|
176
|
+
*/
|
|
177
|
+
Plugin.prototype.backupOptions = function () {
|
|
178
|
+
var file = this._getCacheOptionsFile();
|
|
179
|
+
file = file.fullname();
|
|
180
|
+
file.addDir();
|
|
181
|
+
file.saveJson(this.options);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 合并配置
|
|
186
|
+
* @param {Object} cg 配置
|
|
187
|
+
*/
|
|
188
|
+
Plugin.prototype.mergeOptions = function (options) {
|
|
189
|
+
var file = this._getCacheOptionsFile();
|
|
190
|
+
var options_cache = file.loadJson();
|
|
191
|
+
if (options_cache) {
|
|
192
|
+
$.push(options, options_cache);
|
|
193
|
+
}
|
|
194
|
+
return options;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 获取缓存配置文件
|
|
199
|
+
* @returns {string} 缓存配置文件
|
|
200
|
+
*/
|
|
201
|
+
Plugin.prototype._getCacheOptionsFile = function () {
|
|
202
|
+
// let app = this.getApp();
|
|
203
|
+
// let app_name = app.config.name;
|
|
204
|
+
// let plugin_name = this.config.name;
|
|
205
|
+
var l = $.slash;
|
|
206
|
+
let plugin_name = this.config.name;
|
|
207
|
+
let app_name = this.getApp().config.name;
|
|
208
|
+
var file = `/cache/${app_name}/${plugin_name}/config.json`.fullname();
|
|
209
|
+
return file;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 获取模型
|
|
215
|
+
* @param {string} type 模型类型
|
|
216
|
+
* @returns {object} 返回获取到的模型
|
|
217
|
+
*/
|
|
218
|
+
Drive.prototype.getModel = function (type) {
|
|
219
|
+
let model = { ...this.config };
|
|
220
|
+
let dir = this._getDir();
|
|
221
|
+
let l = $.slash;
|
|
222
|
+
let app_name = dir.between('app' + l, l);
|
|
223
|
+
let plugin_name = dir.between('plugin' + l, l);
|
|
224
|
+
let name = dir.basename();
|
|
225
|
+
model.app = app_name;
|
|
226
|
+
model.plugin = plugin_name;
|
|
227
|
+
model.name = model.name || name;
|
|
228
|
+
model.path = "/" + app_name + "/" + name;
|
|
229
|
+
return model;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
exports.Plugin = Plugin;
|