mm_os 2.4.0 → 2.4.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/core/com/api/index.js +9 -3
- package/core/com/cmd/index.js +17 -4
- package/core/com/event/index.js +8 -3
- package/core/com/mqtt/index.js +7 -5
- package/core/com/mqtt/script.js +208 -39
- package/core/com/plugin/index.js +8 -3
- package/core/com/static/index.js +11 -2
- package/core/com/task/index.js +14 -7
- package/demo/app/test/mqtt/df/index.js +107 -25
- package/demo/app/test/mqtt/test/index.js +590 -24
- package/demo/app/test/mqtt/zs/index.js +221 -146
- package/demo/com/server/index.js +62 -37
- package/index.js +3 -2
- package/package.json +1 -1
package/core/com/api/index.js
CHANGED
|
@@ -54,9 +54,15 @@ Api.prototype.run = async function(ctx, db) {
|
|
|
54
54
|
|
|
55
55
|
for (var i = 0, o; o = lt[i++];) {
|
|
56
56
|
if (o.config.state === 1 && path.has(o.config.path)) {
|
|
57
|
-
var ret
|
|
58
|
-
|
|
59
|
-
o.
|
|
57
|
+
var ret;
|
|
58
|
+
try {
|
|
59
|
+
ret = await o.run(ctx, db);
|
|
60
|
+
if (this.mode) {
|
|
61
|
+
o.load(o.filename);
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
$.log.error("接口错误", ctx.path, error);
|
|
65
|
+
//TODO handle the exception
|
|
60
66
|
}
|
|
61
67
|
if (ret) {
|
|
62
68
|
db.ret = ret;
|
package/core/com/cmd/index.js
CHANGED
|
@@ -77,7 +77,11 @@ Cmd.prototype.run = async function(msg, db, table) {
|
|
|
77
77
|
var lt = this.list_before;
|
|
78
78
|
for (var i = 0, o; o = lt[i++];) {
|
|
79
79
|
if (o.onOff) {
|
|
80
|
-
|
|
80
|
+
try {
|
|
81
|
+
ret = await o.run_cmd(msg, db);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
$.log.error("指令错误", o.config.name, error);
|
|
84
|
+
}
|
|
81
85
|
if (ret) {
|
|
82
86
|
break;
|
|
83
87
|
}
|
|
@@ -120,7 +124,11 @@ Cmd.prototype.run = async function(msg, db, table) {
|
|
|
120
124
|
var lt = this.list_main;
|
|
121
125
|
for (var i = 0, o; o = lt[i++];) {
|
|
122
126
|
if (o.onOff) {
|
|
123
|
-
|
|
127
|
+
try {
|
|
128
|
+
ret = await o.run_first(msg, db);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
$.log.error("指令错误", o.config.name, error);
|
|
131
|
+
}
|
|
124
132
|
if (ret) {
|
|
125
133
|
break;
|
|
126
134
|
}
|
|
@@ -131,7 +139,12 @@ Cmd.prototype.run = async function(msg, db, table) {
|
|
|
131
139
|
var lt = this.list_after;
|
|
132
140
|
for (var i = 0, o; o = lt[i++];) {
|
|
133
141
|
if (o.onOff) {
|
|
134
|
-
|
|
142
|
+
try {
|
|
143
|
+
ret = await o.run_first(msg, db);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
$.log.error("指令错误", o.config.name, error);
|
|
146
|
+
}
|
|
147
|
+
|
|
135
148
|
if (ret) {
|
|
136
149
|
break;
|
|
137
150
|
}
|
|
@@ -210,4 +223,4 @@ function cmd_admin(scope, title) {
|
|
|
210
223
|
/**
|
|
211
224
|
* @module 导出Cmd管理器
|
|
212
225
|
*/
|
|
213
|
-
$.cmd_admin = cmd_admin;
|
|
226
|
+
$.cmd_admin = cmd_admin;
|
package/core/com/event/index.js
CHANGED
|
@@ -171,9 +171,14 @@ Event.prototype.doing = async function(o, ctx, db) {
|
|
|
171
171
|
Event.prototype.run_sub = async function(list, target, ctx, db) {
|
|
172
172
|
for (var i = 0, o; o = list[i++];) {
|
|
173
173
|
if (o.config.state === 1 && target.has(o.config.target)) {
|
|
174
|
-
var ret
|
|
175
|
-
|
|
176
|
-
o.
|
|
174
|
+
var ret;
|
|
175
|
+
try {
|
|
176
|
+
ret = await o.run(ctx, db);
|
|
177
|
+
if (this.mode) {
|
|
178
|
+
o.load(o.filename);
|
|
179
|
+
}
|
|
180
|
+
} catch (error) {
|
|
181
|
+
$.log.error("事件执行错误", o.config.name, error);
|
|
177
182
|
}
|
|
178
183
|
if (ret) {
|
|
179
184
|
db.ret = ret;
|
package/core/com/mqtt/index.js
CHANGED
|
@@ -132,7 +132,11 @@ MQTT.prototype.update_after = function() {
|
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
try {
|
|
136
|
+
o.run('init');
|
|
137
|
+
} catch (error) {
|
|
138
|
+
$.log.error("MQTT类初始化失败", o.config.name, error);
|
|
139
|
+
}
|
|
136
140
|
var topics = o.config.topic;
|
|
137
141
|
if (topics) {
|
|
138
142
|
for (var i = 0; i < topics.length; i++) {
|
|
@@ -276,8 +280,7 @@ MQTT.prototype.receive = async function(push_topic, msg) {
|
|
|
276
280
|
try {
|
|
277
281
|
ret = await o.run("main", push_topic, msg, topic, i);
|
|
278
282
|
} catch (error) {
|
|
279
|
-
$.log.error("
|
|
280
|
-
return
|
|
283
|
+
$.log.error("MQTT执行失败", o.config.name, error);
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
286
|
}
|
|
@@ -459,8 +462,7 @@ MQTT.prototype.update_online = async function() {
|
|
|
459
462
|
} else {
|
|
460
463
|
list_online.push(clientid);
|
|
461
464
|
}
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
465
|
+
} else {
|
|
464
466
|
list_online.push(clientid);
|
|
465
467
|
}
|
|
466
468
|
}
|
package/core/com/mqtt/script.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* @param {String} clientid 客户端ID
|
|
4
4
|
* @param {Object} param
|
|
5
5
|
*/
|
|
6
|
-
exports.get_log = function(clientid, param) {
|
|
7
|
-
|
|
6
|
+
exports.get_log = async function(clientid, param) {
|
|
7
|
+
var res = await this.push("GetRecordsByPicOrID", clientid, param);
|
|
8
|
+
return res;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -14,11 +15,15 @@ exports.get_log = function(clientid, param) {
|
|
|
14
15
|
* @param {String} avatar base64头像
|
|
15
16
|
* @param {Number} longtime 超时回馈
|
|
16
17
|
*/
|
|
17
|
-
exports.sign_in = function(clientid, uuid, avatar) {
|
|
18
|
-
|
|
18
|
+
exports.sign_in = async function(clientid, uuid, avatar) {
|
|
19
|
+
var res = await this.push("PullRecordOnlyPic", clientid, {
|
|
19
20
|
"personID": uuid,
|
|
20
21
|
"picinfo": avatar
|
|
21
22
|
});
|
|
23
|
+
|
|
24
|
+
if (!res || res.result == "fail") {
|
|
25
|
+
return "打卡失败!";
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
/**
|
|
@@ -85,16 +90,37 @@ exports.unlock = async function(clientid, uuid = '0', pass = false, tip = '没
|
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 远程锁门(没用到)
|
|
96
|
+
* @param {String} clientid 客户端ID
|
|
97
|
+
* @param {String} uuid 用户唯一标识
|
|
98
|
+
* @param {Boolean} pass 是否可通行 true为是
|
|
99
|
+
* @param {String} tip 提示
|
|
100
|
+
*/
|
|
101
|
+
exports.lock = async function(clientid, uuid = '0', pass = false, tip = '没有访问权限') {
|
|
102
|
+
var res = await this.push("Lock", clientid, {
|
|
103
|
+
"uid": uuid,
|
|
104
|
+
"showInfo": tip
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
if (!res || res.result == "fail") {
|
|
108
|
+
return "已锁门!";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
88
112
|
/**
|
|
89
113
|
* 删除成员
|
|
90
114
|
* @param {String} clientid 客户端ID
|
|
91
115
|
* @param {String} uuid 用户唯一标识
|
|
92
116
|
* @param {Number} longtime 超时回馈
|
|
93
117
|
*/
|
|
94
|
-
exports.delete_member = function(clientid, uuid) {
|
|
95
|
-
|
|
118
|
+
exports.delete_member = async function(clientid, uuid) {
|
|
119
|
+
var res = await this.push("DeletePersons", clientid, {
|
|
96
120
|
"customId": uuid
|
|
97
121
|
});
|
|
122
|
+
|
|
123
|
+
return
|
|
98
124
|
}
|
|
99
125
|
|
|
100
126
|
/**
|
|
@@ -103,21 +129,59 @@ exports.delete_member = function(clientid, uuid) {
|
|
|
103
129
|
* @param {Object} arr 成员列表
|
|
104
130
|
* @param {Number} longtime 超时回馈
|
|
105
131
|
*/
|
|
106
|
-
exports.delete_member_batch = function(clientid, arr, longtime) {
|
|
107
|
-
|
|
132
|
+
exports.delete_member_batch = async function(clientid, arr, longtime) {
|
|
133
|
+
var res = await this.push("DeletePersons", clientid, {
|
|
108
134
|
DataBegin: "BeginFlag",
|
|
109
135
|
DataEnd: "EndFlag",
|
|
110
136
|
PersonNum: arr.length.toString(),
|
|
111
137
|
customId: arr
|
|
112
138
|
}, longtime);
|
|
139
|
+
|
|
140
|
+
var result;
|
|
141
|
+
var error = 0;
|
|
142
|
+
var success = 0;
|
|
143
|
+
var error_info = [];
|
|
144
|
+
var success_info = [];
|
|
145
|
+
|
|
146
|
+
if (res) {
|
|
147
|
+
if (res.result == 'ok') {
|
|
148
|
+
var now = new Date().toStr("yyyy-MM-dd hh:mm:ss");
|
|
149
|
+
error = Number(res.DelErrNum);
|
|
150
|
+
success = Number(res.DelSucNum);
|
|
151
|
+
error_info = res.DelErrInfo.map((o) => {
|
|
152
|
+
o.time_create = now;
|
|
153
|
+
return o
|
|
154
|
+
});
|
|
155
|
+
success_info = res.DelSucInfo.map((o) => {
|
|
156
|
+
o.time_create = now;
|
|
157
|
+
return o
|
|
158
|
+
});
|
|
159
|
+
result = res.result;
|
|
160
|
+
} else if (res.detail && res.detail.indexOf('busy') === -1) {
|
|
161
|
+
result = 'fail';
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
error,
|
|
166
|
+
success,
|
|
167
|
+
error_info,
|
|
168
|
+
success_info,
|
|
169
|
+
result
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return
|
|
113
173
|
}
|
|
114
174
|
|
|
115
175
|
/**
|
|
116
176
|
* 重启设备
|
|
117
177
|
* @param {String} clientid 设备sn
|
|
118
178
|
*/
|
|
119
|
-
exports.reboot_device = function(clientid) {
|
|
120
|
-
|
|
179
|
+
exports.reboot_device = async function(clientid) {
|
|
180
|
+
var res = await this.push("RebootDevice", clientid, {});
|
|
181
|
+
if (!res || res.result == "ok") {
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
return "重启设备失败"
|
|
121
185
|
}
|
|
122
186
|
|
|
123
187
|
/**
|
|
@@ -186,12 +250,17 @@ exports.get_progress = async function(clientid, mode = 'update') {
|
|
|
186
250
|
* @param {Object} param 其他信息
|
|
187
251
|
* @param {Number} longtime 超时回馈
|
|
188
252
|
*/
|
|
189
|
-
exports.replacement = function(clientid, uuid, time, avatar) {
|
|
190
|
-
|
|
253
|
+
exports.replacement = async function(clientid, uuid, time, avatar) {
|
|
254
|
+
var res = await this.push("PullRecordOnlyPic", clientid, {
|
|
191
255
|
"personID": uuid,
|
|
192
256
|
"time": time,
|
|
193
257
|
"picinfo": avatar
|
|
194
|
-
}
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
if (!res || res.result == "fail") {
|
|
261
|
+
return "补卡失败!";
|
|
262
|
+
}
|
|
263
|
+
return
|
|
195
264
|
}
|
|
196
265
|
|
|
197
266
|
/**
|
|
@@ -241,7 +310,8 @@ exports.member_model_out = function(m) {
|
|
|
241
310
|
"picURI": this.fullUrl(m.avatar)
|
|
242
311
|
}
|
|
243
312
|
|
|
244
|
-
if (m.time_valid_end && m.time_valid_end > "2021-01-01 00:00:00".toTime() && m.time_valid_end
|
|
313
|
+
if (m.time_valid_end && m.time_valid_end.toTime() > "2021-01-01 00:00:00".toTime() && m.time_valid_end
|
|
314
|
+
.toTime() <=
|
|
245
315
|
"2038-01-01 00:00:00".toTime()) {
|
|
246
316
|
if (typeof(m.time_valid_start) == "object") {
|
|
247
317
|
obj.cardValidBegin = m.time_valid_start.toStr("yyyy-MM-dd hh:mm:ss");
|
|
@@ -277,7 +347,37 @@ exports.update_member_batch = async function(clientid, list, longtime = 180) {
|
|
|
277
347
|
return this.member_model_out(o);
|
|
278
348
|
})
|
|
279
349
|
}, longtime);
|
|
280
|
-
|
|
350
|
+
|
|
351
|
+
var result;
|
|
352
|
+
var error = 0;
|
|
353
|
+
var success = 0;
|
|
354
|
+
var error_info = [];
|
|
355
|
+
var success_info = [];
|
|
356
|
+
if (res) {
|
|
357
|
+
if (res.result == 'ok') {
|
|
358
|
+
var now = new Date().toStr("yyyy-MM-dd hh:mm:ss");
|
|
359
|
+
error = Number(res.AddErrNum);
|
|
360
|
+
success = Number(res.AddSucNum);
|
|
361
|
+
error_info = res.AddErrInfo.map((o) => {
|
|
362
|
+
o.time_create = now;
|
|
363
|
+
return o
|
|
364
|
+
});
|
|
365
|
+
success_info = res.AddSucInfo.map((o) => {
|
|
366
|
+
o.time_create = now;
|
|
367
|
+
return o
|
|
368
|
+
});
|
|
369
|
+
result = res.result;
|
|
370
|
+
} else if (res.detail && res.detail.indexOf('busy') === -1) {
|
|
371
|
+
result = 'fail';
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return {
|
|
375
|
+
error,
|
|
376
|
+
success,
|
|
377
|
+
error_info,
|
|
378
|
+
success_info,
|
|
379
|
+
result
|
|
380
|
+
};
|
|
281
381
|
}
|
|
282
382
|
|
|
283
383
|
/**
|
|
@@ -309,24 +409,16 @@ exports.init = function() {
|
|
|
309
409
|
}
|
|
310
410
|
_this.drives[clientid].online = 1;
|
|
311
411
|
_this.drives[clientid].time_last = new Date().getTime();
|
|
412
|
+
// console.log("心跳", clientid, _this.drives[clientid]);
|
|
312
413
|
}
|
|
313
414
|
|
|
314
415
|
/**
|
|
315
|
-
*
|
|
416
|
+
* 离线通知
|
|
316
417
|
* @param {String} clientid 设备sn
|
|
317
418
|
* @param {Object} param 其他信息
|
|
318
419
|
*/
|
|
319
420
|
m["Offline"] = async function(clientid, params) {
|
|
320
|
-
|
|
321
|
-
_this.drives[clientid].online = 0;
|
|
322
|
-
}
|
|
323
|
-
var {
|
|
324
|
-
tip,
|
|
325
|
-
device
|
|
326
|
-
} = await $.server.check_device(clientid);
|
|
327
|
-
if (device) {
|
|
328
|
-
device.online = 0;
|
|
329
|
-
}
|
|
421
|
+
_this.update_online(clientid, 0);
|
|
330
422
|
// console.log("离线", clientid, _this.drives[clientid]);
|
|
331
423
|
};
|
|
332
424
|
|
|
@@ -336,19 +428,101 @@ exports.init = function() {
|
|
|
336
428
|
* @param {Object} param 其他信息
|
|
337
429
|
*/
|
|
338
430
|
m["Online"] = async function(clientid, params) {
|
|
339
|
-
await
|
|
431
|
+
await _this.update_online(clientid, 1, params.ip);
|
|
340
432
|
return {
|
|
341
433
|
"facesluiceId": clientid,
|
|
342
434
|
"result": "ok",
|
|
343
435
|
"detail": ""
|
|
344
436
|
};
|
|
345
|
-
|
|
437
|
+
console.log("上线", clientid, _this.drives[clientid]);
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* 更新人体生命体征,如温度、湿度、位置、
|
|
442
|
+
* @param {String} clientid 设备sn
|
|
443
|
+
* @param {Object} param 其他信息
|
|
444
|
+
*/
|
|
445
|
+
m["life"] = async function(clientid, params) {
|
|
446
|
+
_this.update_life(clientid, {
|
|
447
|
+
// 心率
|
|
448
|
+
heart_rate: 0,
|
|
449
|
+
// 睡眠状态 是深度睡眠还是浅睡眠
|
|
450
|
+
sleep: 0,
|
|
451
|
+
// 血氧饱和度
|
|
452
|
+
oxygen: 0,
|
|
453
|
+
// 行走步数
|
|
454
|
+
step: 0,
|
|
455
|
+
// 压力
|
|
456
|
+
pressure: 0,
|
|
457
|
+
// 时间戳
|
|
458
|
+
timestamp: 0,
|
|
459
|
+
// GPS横坐标,保留生命体脱下设备时的最后位置
|
|
460
|
+
gps_x: 0,
|
|
461
|
+
// GPS纵坐标,保留生命体脱下设备时的最后位置
|
|
462
|
+
gps_y: 0
|
|
463
|
+
});
|
|
464
|
+
// console.log("离线", clientid, _this.drives[clientid]);
|
|
346
465
|
};
|
|
347
466
|
|
|
467
|
+
/**
|
|
468
|
+
* 更新设备信息,如温度、湿度、位置
|
|
469
|
+
* @param {String} clientid 设备sn
|
|
470
|
+
* @param {Object} param 其他信息
|
|
471
|
+
*/
|
|
472
|
+
m["info"] = async function(clientid, params) {
|
|
473
|
+
_this.update_device_info(clientid, {
|
|
474
|
+
// 温度
|
|
475
|
+
temperature: 0,
|
|
476
|
+
// 湿度
|
|
477
|
+
humidity: 0,
|
|
478
|
+
// 氧气
|
|
479
|
+
oxygen: 0,
|
|
480
|
+
// 二氧化碳
|
|
481
|
+
carbon_dioxide: 0,
|
|
482
|
+
// 光照强度
|
|
483
|
+
light: 0,
|
|
484
|
+
// 烟雾浓度
|
|
485
|
+
smoke: 0,
|
|
486
|
+
// 压力
|
|
487
|
+
pressure: 0,,
|
|
488
|
+
// 光敏
|
|
489
|
+
photosensitive: 0,
|
|
490
|
+
// 声波
|
|
491
|
+
acoustic_wave: 0,
|
|
492
|
+
// 磁力
|
|
493
|
+
magnetism: 0,
|
|
494
|
+
// 火焰
|
|
495
|
+
flame: 0,
|
|
496
|
+
// 震动
|
|
497
|
+
vibrate: 0,
|
|
498
|
+
// 时间戳
|
|
499
|
+
timestamp: 0,
|
|
500
|
+
// GPS横坐标
|
|
501
|
+
gps_x: 0,
|
|
502
|
+
// GPS纵坐标
|
|
503
|
+
gps_y: 0
|
|
504
|
+
});
|
|
505
|
+
// console.log("离线", clientid, _this.drives[clientid]);
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* 上报
|
|
511
|
+
* @param {String} clientid 设备sn
|
|
512
|
+
* @param {Object} param 其他信息
|
|
513
|
+
*/
|
|
348
514
|
m["RecPush"] = async function(clientid, params, msg, id) {
|
|
515
|
+
_this.send(`mqtt/face/${clientid}`, {
|
|
516
|
+
"messageId": _this.get_msgid('PushAck'),
|
|
517
|
+
"operator": "PushAck",
|
|
518
|
+
"info": {
|
|
519
|
+
"PushAckType": "2",
|
|
520
|
+
"SnapOrRecordID": params.RecordID
|
|
521
|
+
}
|
|
522
|
+
});
|
|
349
523
|
var type = 1;
|
|
350
524
|
switch (params.otype) {
|
|
351
|
-
// (1
|
|
525
|
+
// (1刷脸验证|2远程开门|3智码开门|4刷卡验证)
|
|
352
526
|
case "7":
|
|
353
527
|
case "27":
|
|
354
528
|
type = 2;
|
|
@@ -385,6 +559,9 @@ exports.init = function() {
|
|
|
385
559
|
var phone = (params.telnum || "").trim();
|
|
386
560
|
var idcard = (params.idCard || "").trim();
|
|
387
561
|
var nfc = (params.cardNum2 || params.RFIDCard || "").trim();
|
|
562
|
+
if (nfc == "0") {
|
|
563
|
+
ncf = ""
|
|
564
|
+
}
|
|
388
565
|
var time = params.time;
|
|
389
566
|
var avatar = "";
|
|
390
567
|
if (params.pic) {
|
|
@@ -405,19 +582,11 @@ exports.init = function() {
|
|
|
405
582
|
type,
|
|
406
583
|
person_type,
|
|
407
584
|
record_type,
|
|
585
|
+
action: "刷脸验证",
|
|
408
586
|
time,
|
|
409
587
|
avatar
|
|
410
588
|
}
|
|
411
589
|
$.server.exec_log(clientid, log);
|
|
412
|
-
|
|
413
|
-
_this.send(`mqtt/face/${clientid}`, {
|
|
414
|
-
"messageId": _this.get_msgid('PushAck'),
|
|
415
|
-
"operator": "PushAck",
|
|
416
|
-
"info": {
|
|
417
|
-
"PushAckType": "2",
|
|
418
|
-
"SnapOrRecordID": params.RecordID
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
590
|
}
|
|
422
591
|
|
|
423
592
|
m["QRCodePush"] = async function(clientid, params, msg, id) {
|
|
@@ -427,7 +596,7 @@ exports.init = function() {
|
|
|
427
596
|
pass,
|
|
428
597
|
tip,
|
|
429
598
|
device
|
|
430
|
-
} = $.server.exec_qrcode(clientid, qrcode);
|
|
599
|
+
} = await $.server.exec_qrcode(clientid, qrcode);
|
|
431
600
|
if (device && device.online) {
|
|
432
601
|
await _this.unlock(clientid, uuid, pass, tip);
|
|
433
602
|
}
|
package/core/com/plugin/index.js
CHANGED
|
@@ -32,10 +32,15 @@ Plugin.prototype.run = function(param1, param2) {
|
|
|
32
32
|
var lt = this.list;
|
|
33
33
|
for (var i = 0, o; o = lt[i++];) {
|
|
34
34
|
if (o.config.state === 1) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
try {
|
|
36
|
+
ret = o.run(param1, param2);
|
|
37
|
+
if (this.mode) {
|
|
38
|
+
o.load(o.filename);
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
$.log.error("运行插件错误", o.config.name, error);
|
|
38
42
|
}
|
|
43
|
+
|
|
39
44
|
if (ret && o.end) {
|
|
40
45
|
break;
|
|
41
46
|
}
|
package/core/com/static/index.js
CHANGED
|
@@ -40,7 +40,12 @@ class Static extends Index {
|
|
|
40
40
|
if (path.indexOf('.') !== -1) {
|
|
41
41
|
for (var i = 0; i < len; i++) {
|
|
42
42
|
var o = list[i];
|
|
43
|
-
|
|
43
|
+
try {
|
|
44
|
+
done = await o.run(ctx, path, next);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
$.log.error("静态文件执行错误", o.config.name, error);
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
if (done) {
|
|
45
50
|
break;
|
|
46
51
|
}
|
|
@@ -63,7 +68,11 @@ class Static extends Index {
|
|
|
63
68
|
}
|
|
64
69
|
break;
|
|
65
70
|
} else {
|
|
66
|
-
|
|
71
|
+
try {
|
|
72
|
+
done = await o.run(ctx, path, next);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
$.log.error("静态文件执行错误", o.config.name, error);
|
|
75
|
+
}
|
|
67
76
|
if (done) {
|
|
68
77
|
break;
|
|
69
78
|
}
|
package/core/com/task/index.js
CHANGED
|
@@ -27,17 +27,24 @@ class Task extends Index {
|
|
|
27
27
|
*/
|
|
28
28
|
Task.prototype.run = async function(name) {
|
|
29
29
|
var lt = this.list;
|
|
30
|
-
if(name){
|
|
30
|
+
if (name) {
|
|
31
31
|
for (var i = 0, o; o = lt[i++];) {
|
|
32
|
-
if(o.name === name){
|
|
33
|
-
|
|
32
|
+
if (o.name === name) {
|
|
33
|
+
try {
|
|
34
|
+
o.run();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
$.log.error("定时任务错误", o.name, error);
|
|
37
|
+
}
|
|
34
38
|
break;
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
41
|
+
} else {
|
|
39
42
|
for (var i = 0, o; o = lt[i++];) {
|
|
40
|
-
|
|
43
|
+
try {
|
|
44
|
+
o.run();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
$.log.error("定时任务错误", o.name, error);
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
};
|
|
@@ -115,4 +122,4 @@ function task_admin(scope, title) {
|
|
|
115
122
|
/**
|
|
116
123
|
* @module 导出Task管理器
|
|
117
124
|
*/
|
|
118
|
-
$.task_admin = task_admin;
|
|
125
|
+
$.task_admin = task_admin;
|