mm_os 2.9.1 → 2.9.3
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/cache/route/main/config.json +1 -0
- package/cache/sys/app_admin/config.json +1 -0
- package/cache/sys/mqtt_engine/config.json +1 -0
- package/cache/sys/user/config.json +1 -0
- package/core/com/api/drive.js +9 -89
- package/core/com/api/index.js +3 -31
- package/core/com/cmd/drive.js +10 -1
- package/core/com/cmd/index.js +15 -1
- package/core/com/component/drive.js +1 -1
- package/core/com/component/index.js +16 -12
- package/core/com/db/drive.js +1 -1
- package/core/com/db/index.js +15 -17
- package/core/com/event/drive.js +3 -1
- package/core/com/event/index.js +74 -61
- package/core/com/eventer/com.js +2 -2
- package/core/com/middleware/com.js +41 -16
- package/core/com/mqtt/drive.js +4 -3
- package/core/com/mqtt/index.js +10 -8
- package/core/com/nav/drive.js +1 -19
- package/core/com/nav/index.js +1 -1
- package/core/com/param/drive.js +1 -1
- package/core/com/param/index.js +1 -27
- package/core/com/plugin/drive.js +18 -19
- package/core/com/plugin/index.js +16 -21
- package/core/com/plugin/script.js +109 -58
- package/core/com/rpc/com.json +4 -0
- package/core/com/rpc/drive.js +160 -0
- package/core/com/rpc/index.js +87 -0
- package/core/com/socket/drive.js +0 -1
- package/core/com/socket/index.js +5 -15
- package/core/com/sql/drive.js +1 -1
- package/core/com/sql/index.js +4 -31
- package/core/com/static/drive.js +13 -54
- package/core/com/static/index.js +14 -6
- package/core/com/task/drive.js +7 -2
- package/core/com/task/index.js +16 -36
- package/core/com/tpl/com.js +2 -2
- package/demo/app/dev/event_api/manage/event.json +19 -0
- package/demo/app/dev/event_api/manage/main.js +26 -0
- package/demo/app/dev/plugin/doc/static/api_list.html +144 -0
- package/demo/app/dev/plugin/doc/static/api_view.html +692 -0
- package/demo/app/dev/plugin/doc/static/index.html +138 -0
- package/demo/app/dev/plugin/doc/static/request_test.html +311 -0
- package/demo/app/dev/plugin/doc/static/static.js +28 -0
- package/demo/app/dev/plugin/doc/static/static.json +20 -0
- package/demo/app/dev/plugin/main/api_dev_client/app/api.json +13 -0
- package/demo/app/dev/plugin/main/api_dev_client/app/index.js +13 -0
- package/demo/app/dev/plugin/main/api_dev_client/app/param.json +147 -0
- package/demo/app/dev/plugin/main/api_dev_client/app/sql.json +28 -0
- package/demo/app/dev/plugin/main/api_dev_client/auto/api.json +37 -0
- package/demo/app/dev/plugin/main/api_dev_client/auto/auto_db.js +70 -0
- package/demo/app/dev/plugin/main/api_dev_client/auto/auto_file.js +32 -0
- package/demo/app/dev/plugin/main/api_dev_client/auto/index.js +51 -0
- package/demo/app/dev/plugin/main/api_dev_client/auto/param.json +51 -0
- package/demo/app/dev/plugin/main/api_dev_client/db/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/db/index.js +69 -0
- package/demo/app/dev/plugin/main/api_dev_client/db/param.json +31 -0
- package/demo/app/dev/plugin/main/api_dev_client/dict/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/dict/index.js +49 -0
- package/demo/app/dev/plugin/main/api_dev_client/dict/param.json +29 -0
- package/demo/app/dev/plugin/main/api_dev_client/help/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/help/index.js +14 -0
- package/demo/app/dev/plugin/main/api_dev_client/help/param.json +31 -0
- package/demo/app/dev/plugin/main/api_dev_client/nav/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/nav/index.js +36 -0
- package/demo/app/dev/plugin/main/api_dev_client/nav/param.json +36 -0
- package/demo/app/dev/plugin/main/api_dev_client/plugin/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/plugin/index.js +13 -0
- package/demo/app/dev/plugin/main/api_dev_client/plugin/param.json +31 -0
- package/demo/app/dev/plugin/main/api_dev_client/source/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/source/index.js +14 -0
- package/demo/app/dev/plugin/main/api_dev_client/source/param.json +31 -0
- package/demo/app/dev/plugin/main/api_dev_client/sql/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/sql/index.js +13 -0
- package/demo/app/dev/plugin/main/api_dev_client/sql/param.json +31 -0
- package/demo/app/dev/plugin/main/api_dev_client/task/api.json +16 -0
- package/demo/app/dev/plugin/main/api_dev_client/task/index.js +13 -0
- package/demo/app/dev/plugin/main/api_dev_client/task/param.json +31 -0
- package/demo/app/dev/plugin/main/api_dev_client/translate/api.json +39 -0
- package/demo/app/dev/plugin/main/api_dev_client/translate/index.js +43 -0
- package/demo/app/dev/plugin/main/api_dev_client/translate/param.json +130 -0
- package/demo/app/dev/plugin/main/api_dev_client/translate/sql.json +62 -0
- package/demo/app/dev/plugin/main/api_dev_client/ui/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/ui/index.js +146 -0
- package/demo/app/dev/plugin/main/api_dev_client/ui/param.json +31 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/api.json +10 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/index.js +100 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/param.json +29 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/nav.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/obj.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/post.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/block/query.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/edit.vue +39 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/list.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/search.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/table.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/type.vue +12 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/page/view.vue +56 -0
- package/demo/app/dev/plugin/main/api_dev_client/view/tpl/view.json +48 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/api.json +37 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/auto_db.js +120 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy.js +101 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy_framework.js +118 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy/copy_template.js +78 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/copy_file.js +97 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/common.js +198 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/django_server.js +104 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/helper.js +161 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/koa_art_server.js +102 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/mini_app_home.js +415 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/razor.js +0 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/springboot.js +0 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/thinkphp.js +0 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/uni_app_home.js +418 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/vue_cli_admin.js +78 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create/vue_cli_home.js +112 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/create_file.js +97 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/add_data.js +221 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/create_table.js +162 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/db/set_auth_table.js +86 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/index.js +524 -0
- package/demo/app/dev/plugin/main/api_dev_manage/auto_subject/param.json +37 -0
- package/demo/app/route/app.js +131 -0
- package/demo/app/route/app.json +11 -0
- package/demo/app/route/event_api/client/event.json +10 -0
- package/demo/app/route/event_api/client/main.js +19 -0
- package/demo/app/route/event_api/manage/event.json +18 -0
- package/demo/app/route/event_api/manage/main.js +70 -0
- package/demo/app/route/plugin/main/api_route_client/pass/api.json +37 -0
- package/demo/app/route/plugin/main/api_route_client/pass/index.js +33 -0
- package/demo/app/route/plugin/main/api_route_client/pass/param.json +50 -0
- package/demo/app/route/plugin/main/index.js +144 -0
- package/demo/app/route/plugin/main/plugin.json +20 -0
- package/demo/app/sys/event_api/api/event.json +1 -1
- package/demo/app/sys/event_api/doc/event.json +18 -0
- package/demo/app/sys/event_api/doc/main.js +67 -0
- package/demo/app/sys/event_api/img/event.json +11 -0
- package/demo/app/sys/event_api/img/main.js +90 -0
- package/demo/app/sys/event_api/web/event.json +4 -4
- package/demo/app/sys/plugin/app_admin/index.js +127 -0
- package/demo/app/sys/plugin/app_admin/plugin.json +20 -0
- package/demo/app/sys/plugin/main/api_client/config/sql.json +70 -0
- package/demo/app/sys/plugin/main/api_client/lang/api.json +37 -0
- package/demo/app/sys/plugin/main/api_client/lang/index.js +27 -0
- package/demo/app/sys/plugin/main/api_client/lang/param.json +22 -0
- package/demo/app/sys/plugin/main/api_client/translate/api.json +39 -0
- package/demo/app/sys/plugin/main/api_client/translate/index.js +21 -0
- package/demo/app/sys/plugin/main/api_client/translate/param.json +130 -0
- package/demo/app/sys/plugin/main/api_client/translate/sql.json +62 -0
- package/demo/app/sys/plugin/main/static/static.json +1 -1
- package/demo/app/sys/plugin/main/task/task_demo/index.js +37 -0
- package/demo/app/sys/plugin/main/task/task_demo/task.json +24 -0
- package/demo/app/sys/plugin/mqtt_engine/LICENSE +201 -0
- package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/api.json +33 -0
- package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/index.js +31 -0
- package/demo/app/sys/plugin/mqtt_engine/api_sys_client/scheme/param.json +130 -0
- package/demo/app/sys/plugin/mqtt_engine/index.js +51 -0
- package/demo/app/sys/plugin/mqtt_engine/mqtt/df/index.js +509 -0
- package/demo/app/sys/plugin/mqtt_engine/mqtt/df/mqtt.json +24 -0
- package/demo/app/sys/plugin/mqtt_engine/mqtt/zs/index.js +622 -0
- package/demo/app/sys/plugin/mqtt_engine/mqtt/zs/mqtt.json +36 -0
- package/demo/app/sys/plugin/mqtt_engine/plugin.json +21 -0
- package/demo/app/sys/plugin/mqtt_engine/static/img/logo.png +0 -0
- package/demo/app/sys/plugin/mqtt_engine/static/img/logo1.png +0 -0
- package/demo/app/sys/plugin/mqtt_engine/static/static.json +18 -0
- package/demo/app/sys/plugin/user/index.js +127 -0
- package/demo/app/sys/plugin/user/plugin.json +20 -0
- package/demo/app/sys/plugin/user/static/img/logo.png +0 -0
- package/demo/app/sys/plugin/user/static/static.js +28 -0
- package/demo/app/sys/plugin/user/static/static.json +20 -0
- package/demo/app/sys/static/img/avatar_1674484608066.png +0 -0
- package/demo/app/sys/static/img/avatar_1674633778171.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1674962702334.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1675075431736.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1675497065533.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685352550990.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685353685992.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685353956587.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685353971148.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685353983723.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685354014745.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685354122355.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685357983520.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685358453383.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685416570438.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685512675830.png +0 -0
- package/demo/app/sys/static/img/avatar_1685939425608.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1685939886560.jpeg +0 -0
- package/demo/app/sys/static/img/avatar_1686106313194.png +0 -0
- package/demo/app/sys/static/img/avatar_1686371876175.png +0 -0
- package/demo/app/sys/static/img/avatar_1686372033596.png +0 -0
- package/demo/app/sys/static/img/avatar_1688215220669.png +0 -0
- package/demo/app/sys/static/img/avatar_1688531184690.png +0 -0
- package/demo/app/sys/static/img/avatar_1688531233080.png +0 -0
- package/demo/app/sys/static/img/avatar_1688548526909.png +0 -0
- package/demo/app/sys/static/img/avatar_1688549213411.png +0 -0
- package/demo/app/sys/static/img/avatar_1688549511977.png +0 -0
- package/demo/app/sys/static/img/avatar_1688549685464.png +0 -0
- package/demo/app/sys/static/img/avatar_1688608623049.png +0 -0
- package/demo/app/sys/static/img/avatar_1688638500476.png +0 -0
- package/demo/app/sys/static/img/avatar_1688638515195.png +0 -0
- package/demo/app/sys/static/img/avatar_1688638539928.png +0 -0
- package/demo/app/sys/static/img/avatar_1688638557960.png +0 -0
- package/demo/app/sys/static/img/avatar_1688638761798.png +0 -0
- package/demo/app/sys/static/img/avatar_1688638943140.png +0 -0
- package/demo/app/sys/static/img/avatar_1688639068330.png +0 -0
- package/demo/app/sys/static/img/image_1685357101273.jpeg +0 -0
- package/demo/app/sys/static/img/logo.png +0 -0
- package/demo/app/sys/static/static.js +28 -0
- package/demo/app/sys/static/static.json +20 -0
- package/demo/app/user/plugin/main/api_user_client/core/api.json +20 -0
- package/demo/app/user/plugin/main/api_user_client/core/forgot.js +14 -0
- package/demo/app/user/plugin/main/api_user_client/core/password.js +14 -0
- package/demo/app/user/plugin/main/api_user_client/core/sign_out.js +26 -0
- package/demo/app/user/plugin/main/api_user_client/core/state.js +21 -0
- package/demo/app/user/plugin/main/api_user_client/forgot/index - /345/211/257/346/234/254.jsbat" +41 -0
- package/demo/app/user/plugin/main/api_user_client/phone_code/index.js_ +230 -0
- package/demo/app/user/plugin/main/api_user_manage/account_base/api.json +37 -0
- package/demo/app/user/plugin/main/api_user_manage/account_base/index.js +40 -0
- package/demo/app/user/plugin/main/api_user_manage/account_base/param.json +130 -0
- package/demo/app/user/plugin/main/api_user_manage/invitation_code/api.json +37 -0
- package/demo/app/user/plugin/main/api_user_manage/invitation_code/index.js +106 -0
- package/demo/app/user/plugin/main/api_user_manage/invitation_code/param.json +130 -0
- package/demo/app/user/plugin/main/api_user_manage/update_team/api.json +35 -0
- package/demo/app/user/plugin/main/api_user_manage/update_team/index.js +218 -0
- package/demo/app/user/plugin/main/api_user_manage/update_team/param.json +130 -0
- package/demo/app/user/static/img/logo.png +0 -0
- package/demo/app/user/static/static.js +28 -0
- package/demo/app/user/static/static.json +20 -0
- package/demo/app/ws/app.js +122 -0
- package/demo/app/ws/app.json +11 -0
- package/demo/app/ws/event_api/client/event.json +10 -0
- package/demo/app/ws/event_api/client/main.js +17 -0
- package/demo/app/ws/socket/ws/index.js +43 -0
- package/demo/app/ws/socket/ws/socket.json +14 -0
- package/demo/config/face.sql +3824 -0
- package/demo/config/local.json +2 -2
- package/demo/config/test.json +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- /package/core/com/{api → rpc}/rpc.js +0 -0
package/core/com/eventer/com.js
CHANGED
|
@@ -151,8 +151,8 @@ Eventer.prototype.doing = async function(o, ...msg) {
|
|
|
151
151
|
if (types.isPromise(ret)) {
|
|
152
152
|
ret = await ret;
|
|
153
153
|
}
|
|
154
|
-
if (this.mode >
|
|
155
|
-
o.
|
|
154
|
+
if (this.mode > 4) {
|
|
155
|
+
o.exec('reload', o.filename);
|
|
156
156
|
}
|
|
157
157
|
} catch (err) {
|
|
158
158
|
$.log.error("事件器执行失败!", err);
|
|
@@ -7,14 +7,20 @@ class Middleware {
|
|
|
7
7
|
// 中间件列表
|
|
8
8
|
this.list = [];
|
|
9
9
|
|
|
10
|
-
this.config =
|
|
10
|
+
this.config = {
|
|
11
11
|
path: "./middleware".fullname($.runPath),
|
|
12
12
|
file: "middleware.json",
|
|
13
13
|
mode: "web"
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
|
+
this.init(config);
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
Middleware.prototype.init = function(config) {
|
|
20
|
+
if (config) {
|
|
21
|
+
Object.assign(this.config, config);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* 新建脚本
|
|
@@ -58,8 +64,7 @@ Middleware.prototype.new_config = function(file) {
|
|
|
58
64
|
* 加载配置
|
|
59
65
|
* @param {String} file 配置文件路径
|
|
60
66
|
*/
|
|
61
|
-
Middleware.prototype.
|
|
62
|
-
var f = this.config.file;
|
|
67
|
+
Middleware.prototype.load_item = function(file) {
|
|
63
68
|
var config = file.loadJson();
|
|
64
69
|
if (config) {
|
|
65
70
|
var cg = this.list.getObj({
|
|
@@ -69,7 +74,7 @@ Middleware.prototype.load = function(file) {
|
|
|
69
74
|
$.push(cg, config, true);
|
|
70
75
|
} else {
|
|
71
76
|
cg = {
|
|
72
|
-
func_file: file.replace(
|
|
77
|
+
func_file: file.replace(this.config.file, 'index.js')
|
|
73
78
|
}
|
|
74
79
|
$.push(cg, config, true);
|
|
75
80
|
this.list.push(cg);
|
|
@@ -87,14 +92,15 @@ Middleware.prototype.load = function(file) {
|
|
|
87
92
|
* 遍历加载配置
|
|
88
93
|
* @param {Object} path
|
|
89
94
|
*/
|
|
90
|
-
Middleware.prototype.
|
|
95
|
+
Middleware.prototype.update_config_all = function(path, accurate) {
|
|
91
96
|
if (path.hasDir()) {
|
|
92
|
-
var dirs = $.dir.getAll(path);
|
|
97
|
+
var dirs = $.dir.getAll(path);
|
|
93
98
|
// 遍历目录路径
|
|
94
99
|
var file = this.config.file;
|
|
95
|
-
dirs.
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
for (var i = 0; i < dirs.length; i++) {
|
|
101
|
+
var d = dirs[i];
|
|
102
|
+
this.load_item(d + file);
|
|
103
|
+
}
|
|
98
104
|
}
|
|
99
105
|
};
|
|
100
106
|
|
|
@@ -105,24 +111,43 @@ Middleware.prototype.sort = function() {
|
|
|
105
111
|
return this.list.sortBy('asc', 'sort');
|
|
106
112
|
};
|
|
107
113
|
|
|
114
|
+
/**
|
|
115
|
+
* 清除接口缓存
|
|
116
|
+
*/
|
|
117
|
+
Middleware.prototype.clear = function() {
|
|
118
|
+
this.list = [];
|
|
119
|
+
};
|
|
120
|
+
|
|
108
121
|
/**
|
|
109
122
|
* 遍历加载配置
|
|
110
123
|
*/
|
|
111
|
-
Middleware.prototype.
|
|
112
|
-
|
|
124
|
+
Middleware.prototype.update_config = function(path, accurate = true, clear = true) {
|
|
125
|
+
if (clear) {
|
|
126
|
+
this.clear();
|
|
127
|
+
}
|
|
128
|
+
this.update_config_all("../../../middleware/".fullname(__dirname));
|
|
113
129
|
if (path) {
|
|
114
|
-
this.
|
|
130
|
+
this.update_config_all(path);
|
|
115
131
|
}
|
|
116
|
-
this.
|
|
132
|
+
this.update_config_all(this.config.path);
|
|
117
133
|
var p = "./middleware".fullname($.runPath);
|
|
118
134
|
if (this.config.path !== p) {
|
|
119
|
-
this.
|
|
135
|
+
this.update_config_all(p);
|
|
120
136
|
}
|
|
121
137
|
this.sort();
|
|
122
138
|
};
|
|
123
139
|
|
|
140
|
+
/**
|
|
141
|
+
* 更新
|
|
142
|
+
* @param {String} dir 检索的路径
|
|
143
|
+
* @param {Boolean} loadJS 是否加载JS
|
|
144
|
+
*/
|
|
145
|
+
Middleware.prototype.update = function(dir, accurate = true, loadJS = true, clear = true) {
|
|
146
|
+
this.update_config(dir, accurate, clear);
|
|
147
|
+
}
|
|
148
|
+
|
|
124
149
|
if (!$.middleware) {
|
|
125
150
|
$.middleware = new Middleware();
|
|
126
151
|
}
|
|
127
152
|
|
|
128
|
-
module.exports = Middleware;
|
|
153
|
+
module.exports = Middleware;
|
package/core/com/mqtt/drive.js
CHANGED
|
@@ -16,7 +16,8 @@ class Drive extends Item {
|
|
|
16
16
|
constructor(dir) {
|
|
17
17
|
super(dir, __dirname);
|
|
18
18
|
this.default_file = "./mqtt.json";
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
this.mode = 3;
|
|
20
21
|
/* 通用项 */
|
|
21
22
|
/**
|
|
22
23
|
* 配置参数
|
|
@@ -400,7 +401,7 @@ Drive.prototype.run_event = function(clientid, key, json) {
|
|
|
400
401
|
* @param {String} msgid 消息ID
|
|
401
402
|
* @param {Object} json 信息
|
|
402
403
|
*/
|
|
403
|
-
Drive.prototype.
|
|
404
|
+
Drive.prototype.run = async function(clientid, key, json) {
|
|
404
405
|
var o;
|
|
405
406
|
if (this.drives[clientid]) {
|
|
406
407
|
o = this.drives[clientid][key];
|
|
@@ -495,7 +496,7 @@ Drive.prototype.handle = async function(push_topic, msg, topic, index) {
|
|
|
495
496
|
var id = json.id;
|
|
496
497
|
if (json.result && id) {
|
|
497
498
|
var key = this.get_key(json.method, json.clientid, id);
|
|
498
|
-
var o = await this.
|
|
499
|
+
var o = await this.run(json.clientid, key, json.result);
|
|
499
500
|
if (o) {
|
|
500
501
|
return
|
|
501
502
|
}
|
package/core/com/mqtt/index.js
CHANGED
|
@@ -21,22 +21,24 @@ class MQTT extends Index {
|
|
|
21
21
|
constructor(scope, title) {
|
|
22
22
|
super(scope, __dirname);
|
|
23
23
|
this.Drive = Drive;
|
|
24
|
+
// 更新并重载脚本
|
|
25
|
+
this.mode = 3;
|
|
24
26
|
this.type = "mqtt";
|
|
25
27
|
this.title = title;
|
|
26
28
|
this.dict = {};
|
|
27
|
-
|
|
28
29
|
this.config = {
|
|
29
30
|
hostname: "127.0.0.1",
|
|
30
31
|
port: "1883",
|
|
31
32
|
protocol: "mqtt",
|
|
32
|
-
clientId: "
|
|
33
|
-
subscribe_qos:
|
|
33
|
+
clientId: "iot_test",
|
|
34
|
+
subscribe_qos: 1,
|
|
34
35
|
publish_qos: 1,
|
|
35
|
-
username: "
|
|
36
|
+
username: "iot_test",
|
|
36
37
|
password: "asd123",
|
|
37
38
|
table: "iot_device",
|
|
38
39
|
clean: false,
|
|
39
40
|
longtime: 15000,
|
|
41
|
+
requestTimeout: 3000,
|
|
40
42
|
// 在线有效期时长判断 单位:毫秒,150000毫秒为2.5分钟
|
|
41
43
|
online_expires: 150000,
|
|
42
44
|
// 在线有效期检测间隔
|
|
@@ -123,7 +125,7 @@ MQTT.prototype.match = function(topic, top) {
|
|
|
123
125
|
/**
|
|
124
126
|
* 初始化
|
|
125
127
|
*/
|
|
126
|
-
MQTT.prototype.update_after = function() {
|
|
128
|
+
MQTT.prototype.update_after = async function() {
|
|
127
129
|
var _this = this;
|
|
128
130
|
var list = this.list;
|
|
129
131
|
for (var i = 0, o; o = list[i++];) {
|
|
@@ -133,7 +135,7 @@ MQTT.prototype.update_after = function() {
|
|
|
133
135
|
_this.send(topic, msg, qos, retain);
|
|
134
136
|
}
|
|
135
137
|
};
|
|
136
|
-
o.
|
|
138
|
+
await o.exec('init');
|
|
137
139
|
var topics = o.config.topic;
|
|
138
140
|
if (topics) {
|
|
139
141
|
for (var i = 0; i < topics.length; i++) {
|
|
@@ -273,7 +275,7 @@ MQTT.prototype.receive = async function(push_topic, msg) {
|
|
|
273
275
|
for (var i = 0; i < topics.length; i++) {
|
|
274
276
|
var topic = topics[i];
|
|
275
277
|
if (this.match(push_topic, topic)) {
|
|
276
|
-
ret = await o.
|
|
278
|
+
ret = await o.exec('handle', push_topic, msg, topic, i);
|
|
277
279
|
}
|
|
278
280
|
}
|
|
279
281
|
}
|
|
@@ -410,7 +412,7 @@ MQTT.prototype.reqASync = function(topic, method, params) {
|
|
|
410
412
|
resolve(null);
|
|
411
413
|
reject("request timeout!");
|
|
412
414
|
}
|
|
413
|
-
},
|
|
415
|
+
}, _this.config.requestTimeout);
|
|
414
416
|
});
|
|
415
417
|
};
|
|
416
418
|
|
package/core/com/nav/drive.js
CHANGED
|
@@ -29,7 +29,7 @@ class Drive extends Item {
|
|
|
29
29
|
// 模板路径
|
|
30
30
|
this.tpl_path = "./tpl/";
|
|
31
31
|
// 默认启用热更新
|
|
32
|
-
this.mode =
|
|
32
|
+
this.mode = 3;
|
|
33
33
|
/* 通用项 */
|
|
34
34
|
// 配置参数
|
|
35
35
|
this.config = {
|
|
@@ -349,24 +349,6 @@ Drive.prototype.new_config = function(file) {
|
|
|
349
349
|
file.saveText(JSON.stringify(cg, null, 4));
|
|
350
350
|
};
|
|
351
351
|
|
|
352
|
-
/**
|
|
353
|
-
* 载入配置
|
|
354
|
-
* @param {Object|String} cg 配置对象或配置路径
|
|
355
|
-
*/
|
|
356
|
-
Drive.prototype.load = function(cg) {
|
|
357
|
-
var obj;
|
|
358
|
-
if (!cg) {
|
|
359
|
-
cg = this.extensions;
|
|
360
|
-
}
|
|
361
|
-
if (typeof(cg) === "string") {
|
|
362
|
-
obj = this.loadFile(cg);
|
|
363
|
-
} else {
|
|
364
|
-
obj = cg;
|
|
365
|
-
}
|
|
366
|
-
this.loadObj(obj);
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
|
|
370
352
|
/**
|
|
371
353
|
* 获取API配置
|
|
372
354
|
* @param {String} app 应用域名
|
package/core/com/nav/index.js
CHANGED
package/core/com/param/drive.js
CHANGED
package/core/com/param/index.js
CHANGED
|
@@ -19,36 +19,10 @@ class Param extends Index {
|
|
|
19
19
|
this.type = "param";
|
|
20
20
|
this.title = title;
|
|
21
21
|
// 默认启用热更新
|
|
22
|
-
this.mode =
|
|
22
|
+
this.mode = 3;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* 加载配置
|
|
28
|
-
* @param {String} path 检索路径
|
|
29
|
-
*/
|
|
30
|
-
Param.prototype.load = function(path) {
|
|
31
|
-
if (!path) {
|
|
32
|
-
path = "./app/";
|
|
33
|
-
}
|
|
34
|
-
// 获取所有应用路径
|
|
35
|
-
var search_dir;
|
|
36
|
-
var _this = this;
|
|
37
|
-
if (this.scope && this.scope !== $.val.scope) {
|
|
38
|
-
search_dir = this.type + '_' + this.scope;
|
|
39
|
-
var list_scope = $.dir.getAll(path, search_dir);
|
|
40
|
-
list_scope.map(function(f) {
|
|
41
|
-
// 获取所有param配置文件
|
|
42
|
-
var list_file = $.file.getAll(f, "*" + _this.type + ".json");
|
|
43
|
-
_this.load_list(list_file);
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
// 获取所有param配置文件
|
|
47
|
-
var list_file = $.file.getAll(path, "*" + _this.type + ".json");
|
|
48
|
-
_this.load_list(list_file);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
26
|
/**
|
|
53
27
|
* 排序
|
|
54
28
|
*/
|
package/core/com/plugin/drive.js
CHANGED
|
@@ -18,7 +18,7 @@ class Drive extends Item {
|
|
|
18
18
|
super(dir, __dirname);
|
|
19
19
|
this.default_file = "./plugin.json";
|
|
20
20
|
// 默认启用热更新
|
|
21
|
-
this.mode =
|
|
21
|
+
this.mode = 3;
|
|
22
22
|
/**
|
|
23
23
|
* 当前语言
|
|
24
24
|
*/
|
|
@@ -80,7 +80,6 @@ Drive.prototype.set_config = function(config) {
|
|
|
80
80
|
var file = this.filename;
|
|
81
81
|
var cg = Object.assign({}, this.config, config || {});
|
|
82
82
|
this.config = conf(cg, file);
|
|
83
|
-
this.set_config_after();
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
/**
|
|
@@ -98,15 +97,6 @@ Drive.prototype.set_config_after = function() {
|
|
|
98
97
|
this.backup_options();
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
/**
|
|
102
|
-
* 重启设备
|
|
103
|
-
* @param {Object} option 配置
|
|
104
|
-
*/
|
|
105
|
-
Drive.prototype.restart = function(option) {
|
|
106
|
-
this.stop();
|
|
107
|
-
this.start();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
100
|
/**
|
|
111
101
|
* 更新配置
|
|
112
102
|
*/
|
|
@@ -327,31 +317,40 @@ Drive.prototype.set_lang = function(lang) {
|
|
|
327
317
|
};
|
|
328
318
|
|
|
329
319
|
/**
|
|
330
|
-
*
|
|
320
|
+
* 安装
|
|
331
321
|
* @param {Object} option 配置参数
|
|
332
|
-
* @return {String} 成功返回null
|
|
322
|
+
* @return {String} 成功返回null,否则返回错误提示
|
|
333
323
|
*/
|
|
334
|
-
Drive.prototype.
|
|
324
|
+
Drive.prototype.install = function(option) {
|
|
335
325
|
var msg = null;
|
|
336
326
|
return msg;
|
|
337
327
|
};
|
|
338
328
|
|
|
339
329
|
/**
|
|
340
|
-
*
|
|
330
|
+
* 重启设备
|
|
331
|
+
* @param {Object} option 配置
|
|
332
|
+
*/
|
|
333
|
+
Drive.prototype.restart = async function(option) {
|
|
334
|
+
await this.run('stop');
|
|
335
|
+
await this.run('start');
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* 初始化
|
|
341
340
|
* @param {Object} option 配置参数
|
|
342
341
|
* @return {String} 成功返回null, 否则返回错误提示
|
|
343
342
|
*/
|
|
344
|
-
Drive.prototype.
|
|
343
|
+
Drive.prototype.init = function(option) {
|
|
345
344
|
var msg = null;
|
|
346
345
|
return msg;
|
|
347
346
|
};
|
|
348
347
|
|
|
349
348
|
/**
|
|
350
|
-
*
|
|
349
|
+
* 更新
|
|
351
350
|
* @param {Object} option 配置参数
|
|
352
|
-
* @return {String} 成功返回null
|
|
351
|
+
* @return {String} 成功返回null, 否则返回错误提示
|
|
353
352
|
*/
|
|
354
|
-
Drive.prototype.
|
|
353
|
+
Drive.prototype.update = function(option) {
|
|
355
354
|
var msg = null;
|
|
356
355
|
return msg;
|
|
357
356
|
};
|
package/core/com/plugin/index.js
CHANGED
|
@@ -20,7 +20,7 @@ class Plugin extends Index {
|
|
|
20
20
|
this.type = "plugin";
|
|
21
21
|
this.title = title;
|
|
22
22
|
// 默认启用热更新
|
|
23
|
-
this.mode =
|
|
23
|
+
this.mode = 3;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -58,40 +58,35 @@ Plugin.prototype.init = function(option) {
|
|
|
58
58
|
var ret = "";
|
|
59
59
|
var lt = this.list;
|
|
60
60
|
for (var i = 0, o; o = lt[i++];) {
|
|
61
|
-
ret = o.
|
|
61
|
+
ret = o.exec('init', option);
|
|
62
62
|
}
|
|
63
63
|
return ret;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
Plugin.prototype.sort = function() {
|
|
67
|
-
this.list.sortBy('sort');
|
|
68
|
-
};
|
|
69
|
-
|
|
70
66
|
/**
|
|
71
67
|
* 加载插件
|
|
72
68
|
* @param {String} path 检索路径
|
|
73
|
-
* @param {Boolean}
|
|
69
|
+
* @param {Boolean} accurate 是否精确路径
|
|
74
70
|
*/
|
|
75
|
-
Plugin.prototype.
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
Plugin.prototype.update_config_all = async function(path, accurate) {
|
|
72
|
+
var dir_plugin;
|
|
73
|
+
if (accurate) {
|
|
74
|
+
dir_plugin = path;
|
|
75
|
+
} else {
|
|
76
|
+
if (!path) {
|
|
77
|
+
path = '/app/' + this.scope;
|
|
78
|
+
}
|
|
79
|
+
dir_plugin = path + "/plugin/";
|
|
78
80
|
}
|
|
79
|
-
list = this.list;
|
|
80
|
-
var dir_plugin = path + "/plugin/";
|
|
81
81
|
if (dir_plugin.hasDir()) {
|
|
82
82
|
var list_scope = $.dir.get(dir_plugin);
|
|
83
|
-
|
|
84
83
|
// 遍历目录路径
|
|
85
|
-
|
|
84
|
+
for (var i = 0, o; o = list_scope[i++];) {
|
|
86
85
|
var file = './plugin.json'.fullname(o);
|
|
87
86
|
if (file.hasFile()) {
|
|
88
|
-
|
|
89
|
-
obj.load(file);
|
|
90
|
-
if (obj.config.name) {
|
|
91
|
-
list.push(obj);
|
|
92
|
-
}
|
|
87
|
+
await this.load_file(file, true);
|
|
93
88
|
}
|
|
94
|
-
}
|
|
89
|
+
}
|
|
95
90
|
}
|
|
96
91
|
};
|
|
97
92
|
|
|
@@ -138,7 +133,7 @@ Plugin.prototype.unzip = async function(file) {
|
|
|
138
133
|
Plugin.prototype.uninstall = async function(name) {
|
|
139
134
|
var plus = this.get(name);
|
|
140
135
|
if (plus) {
|
|
141
|
-
await plus.
|
|
136
|
+
await plus.exec('uninstall');
|
|
142
137
|
var obj = this.del(name, true);
|
|
143
138
|
if (obj) {
|
|
144
139
|
var file = obj.filename;
|