mm_os 4.1.7 → 4.1.9
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/adapter/mqtt.js +1 -0
- package/adapter/socket.js +1 -0
- package/adapter/web.js +2 -1
- package/adapter/websocket.js +1 -1
- package/com/api/drive.js +3 -3
- package/com/api/index.js +2 -2
- package/com/cmd/drive.js +2 -2
- package/com/cmd/index.js +1 -1
- package/com/cmd/script.tpl.js +7 -6
- package/com/db/drive.js +1 -1
- package/com/event/index.js +2 -2
- package/com/mqtt/index.js +6 -6
- package/com/mqtt/mm_mqtt.js +0 -5
- package/com/param/index.js +3 -2
- package/com/pendant/index.js +1 -1
- package/com/socket/drive.js +13 -13
- package/com/socket/index.js +5 -5
- package/com/sql/index.js +1 -1
- package/com/template/drive.js +30 -29
- package/com/template/index.js +27 -30
- package/common/middleware/web_after/index.js +2 -2
- package/core/app/{bat.js → index copy.js } +10 -56
- package/core/app/index.js +5 -82
- package/core/channel/index.js +1 -2
- package/core/controller/index.js +1 -3
- package/core/game/bat/world.js +1 -1
- package/core/game/index.js +1 -1
- package/core/middleware/index.js +4 -4
- package/core/middleware/script.tpl.js +3 -3
- package/core/plugin/index.js +93 -37
- package/core/room/room.js +2 -2
- package/core/scene/index.js +1 -0
- package/core/zone/bat/index.js +2 -0
- package/core/zone/index.js +1 -0
- package/package.json +6 -6
- package/server.js +4 -3
- package/software.js +5 -2
- package/tcp.js +4 -1
package/adapter/mqtt.js
CHANGED
package/adapter/socket.js
CHANGED
package/adapter/web.js
CHANGED
|
@@ -32,7 +32,7 @@ Web.prototype._preset = function () {
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* 使用中间件
|
|
35
|
-
* @param {
|
|
35
|
+
* @param {Function} middleware 中间件函数
|
|
36
36
|
*/
|
|
37
37
|
Web.prototype.use = function (middleware) {
|
|
38
38
|
this.web.use(middleware);
|
|
@@ -41,6 +41,7 @@ Web.prototype.use = function (middleware) {
|
|
|
41
41
|
/**
|
|
42
42
|
* 初始化
|
|
43
43
|
* @param {object} server 服务器实例
|
|
44
|
+
* @returns {object} 适配器实例
|
|
44
45
|
*/
|
|
45
46
|
Web.prototype.init = function (server) {
|
|
46
47
|
if (server) {
|
package/adapter/websocket.js
CHANGED
|
@@ -137,7 +137,7 @@ WebSocket.prototype._onError = function (client_id, error) {
|
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* 使用中间件
|
|
140
|
-
* @param {
|
|
140
|
+
* @param {Function} middleware 中间件函数
|
|
141
141
|
*/
|
|
142
142
|
WebSocket.prototype.use = function (middleware) {
|
|
143
143
|
this.broker.use(middleware);
|
package/com/api/drive.js
CHANGED
|
@@ -50,8 +50,8 @@ class Drive extends Item {
|
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* 构造函数
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {
|
|
53
|
+
* @param {object} config 配置项
|
|
54
|
+
* @param {object} parent 父对象
|
|
55
55
|
* @class
|
|
56
56
|
*/
|
|
57
57
|
constructor(config, parent) {
|
|
@@ -701,7 +701,7 @@ Drive.prototype.getModel = function (type) {
|
|
|
701
701
|
model.app = app_name;
|
|
702
702
|
model.plugin = plugin_name;
|
|
703
703
|
model.name = model.name || name;
|
|
704
|
-
model.path =
|
|
704
|
+
model.path = '/' + app_name + '/' + name;
|
|
705
705
|
return model;
|
|
706
706
|
};
|
|
707
707
|
|
package/com/api/index.js
CHANGED
|
@@ -114,14 +114,14 @@ Api.prototype.isMatch = function (str, pattern) {
|
|
|
114
114
|
if (str === pattern) {
|
|
115
115
|
return true;
|
|
116
116
|
} else if (pattern.startsWith('*')) {
|
|
117
|
-
|
|
117
|
+
let clean = pattern.replaceAll('*', '');
|
|
118
118
|
if (pattern.endsWith('*')) {
|
|
119
119
|
return str.indexOf(clean) !== -1;
|
|
120
120
|
} else {
|
|
121
121
|
return str.endsWith(clean);
|
|
122
122
|
}
|
|
123
123
|
} else if (pattern.endsWith('*')) {
|
|
124
|
-
|
|
124
|
+
let clean = pattern.replaceAll('*', '');
|
|
125
125
|
return str.startsWith(clean);
|
|
126
126
|
}
|
|
127
127
|
else {
|
package/com/cmd/drive.js
CHANGED
|
@@ -177,8 +177,8 @@ Drive.prototype.enhancedMatch = function (msg, db) {
|
|
|
177
177
|
Drive.prototype._contextAwareMatch = function (msg, db) {
|
|
178
178
|
var name = this.config.name.toLowerCase();
|
|
179
179
|
var title = this.config.title.toLowerCase();
|
|
180
|
-
var description = this.config.description.toLowerCase();
|
|
181
|
-
var content = (msg.content || '').toLowerCase();
|
|
180
|
+
// var description = this.config.description.toLowerCase();
|
|
181
|
+
// var content = (msg.content || '').toLowerCase();
|
|
182
182
|
|
|
183
183
|
// 1. 基于消息类型的匹配
|
|
184
184
|
if (this._matchByMsgType(msg, name, title)) {
|
package/com/cmd/index.js
CHANGED
|
@@ -204,7 +204,7 @@ Cmd.prototype._fullList = async function () {
|
|
|
204
204
|
* @returns {object|string} 返回指令执行结果
|
|
205
205
|
*/
|
|
206
206
|
Cmd.prototype.cmd = async function (name, state, ...params) {
|
|
207
|
-
var obj = this.
|
|
207
|
+
var obj = this.getMod(name);
|
|
208
208
|
if (!obj) {
|
|
209
209
|
return '错误: 指令不存在';
|
|
210
210
|
}
|
package/com/cmd/script.tpl.js
CHANGED
|
@@ -21,12 +21,13 @@ module.exports = {
|
|
|
21
21
|
async main(msg, db) {
|
|
22
22
|
let form = msg.form;
|
|
23
23
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
location: '梅州',
|
|
25
|
+
datetime: '2023-08-25 12:00',
|
|
26
|
+
weather: '晴朗',
|
|
27
|
+
temperature: '25',
|
|
28
|
+
humidity: '60%',
|
|
29
|
+
wind: '3级',
|
|
30
|
+
...form
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
};
|
package/com/db/drive.js
CHANGED
package/com/event/index.js
CHANGED
|
@@ -220,14 +220,14 @@ Event.prototype.isMatch = function (str, pattern) {
|
|
|
220
220
|
if (str === pattern) {
|
|
221
221
|
return true;
|
|
222
222
|
} else if (pattern.startsWith('*')) {
|
|
223
|
-
|
|
223
|
+
let clean = pattern.replaceAll('*', '');
|
|
224
224
|
if (pattern.endsWith('*')) {
|
|
225
225
|
return str.indexOf(clean) !== -1;
|
|
226
226
|
} else {
|
|
227
227
|
return str.endsWith(clean);
|
|
228
228
|
}
|
|
229
229
|
} else if (pattern.endsWith('*')) {
|
|
230
|
-
|
|
230
|
+
let clean = pattern.replaceAll('*', '');
|
|
231
231
|
return str.startsWith(clean);
|
|
232
232
|
}
|
|
233
233
|
else {
|
package/com/mqtt/index.js
CHANGED
|
@@ -533,7 +533,7 @@ Mqtt.prototype.req = function (topic, method, params, func, timeout = 0) {
|
|
|
533
533
|
|
|
534
534
|
// 设置超时移除定时器
|
|
535
535
|
var _this = this;
|
|
536
|
-
data.timer = setTimeout(
|
|
536
|
+
data.timer = setTimeout(() => {
|
|
537
537
|
_this._delMsgById(data.id);
|
|
538
538
|
}, data.timeout);
|
|
539
539
|
}
|
|
@@ -586,17 +586,17 @@ Mqtt.prototype._handleResponse = function (msg) {
|
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
for (var i = 0; i < this.list_msg.length; i++) {
|
|
589
|
-
|
|
590
|
-
if (
|
|
589
|
+
let o = this.list_msg[i];
|
|
590
|
+
if (o.id === msg.id && o.func) {
|
|
591
591
|
try {
|
|
592
592
|
// 执行回调函数
|
|
593
|
-
|
|
593
|
+
o.func(msg);
|
|
594
594
|
} catch (error) {
|
|
595
595
|
console.error('MQTT回调函数执行错误:', error);
|
|
596
596
|
}
|
|
597
597
|
|
|
598
598
|
// 从列表中移除已处理的消息
|
|
599
|
-
this._delMsgById(
|
|
599
|
+
this._delMsgById(o.id);
|
|
600
600
|
break;
|
|
601
601
|
}
|
|
602
602
|
}
|
|
@@ -642,7 +642,7 @@ Mqtt.prototype.updateOnline = async function () {
|
|
|
642
642
|
|
|
643
643
|
// 获取所有客户端
|
|
644
644
|
var drives = await this.getClients();
|
|
645
|
-
var { list_online, list_offline
|
|
645
|
+
var { list_online, list_offline } = this._processDeviceStatus(drives, now, online_expires);
|
|
646
646
|
|
|
647
647
|
// 处理未出现的设备
|
|
648
648
|
// this._processUnseenDevices(drives, list_offline, list_has);
|
package/com/mqtt/mm_mqtt.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
const MQTT = require('mqtt');
|
|
2
|
-
const {
|
|
3
|
-
v4
|
|
4
|
-
} = require('uuid');
|
|
5
|
-
|
|
6
2
|
|
|
7
3
|
/**
|
|
8
4
|
* @module MQTT客户端
|
|
@@ -32,7 +28,6 @@ class Mqtt {
|
|
|
32
28
|
*/
|
|
33
29
|
constructor(config) {
|
|
34
30
|
this.config = {...Mqtt.config, ...config};
|
|
35
|
-
var client_id = v4();
|
|
36
31
|
// mqtt客户端服务器
|
|
37
32
|
this.client = null;
|
|
38
33
|
|
package/com/param/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const Drive = require('./drive');
|
|
|
7
7
|
* @class
|
|
8
8
|
*/
|
|
9
9
|
class Param extends Manager {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
11
|
* 配置参数
|
|
12
12
|
* @type {object}
|
|
13
13
|
*/
|
|
@@ -102,7 +102,7 @@ Param.prototype.sort = function() {
|
|
|
102
102
|
* @returns {object} 验证失败返回错误信息,成功返回null
|
|
103
103
|
*/
|
|
104
104
|
Param.prototype.run = async function(db, name, query, body) {
|
|
105
|
-
var obj = this.
|
|
105
|
+
var obj = this.getMod(name);
|
|
106
106
|
if (obj) {
|
|
107
107
|
// 检查参数状态,状态为0时跳过执行
|
|
108
108
|
if (obj.config && obj.config.state === 0) {
|
|
@@ -111,6 +111,7 @@ Param.prototype.run = async function(db, name, query, body) {
|
|
|
111
111
|
try {
|
|
112
112
|
return await obj.run(db, query, body);
|
|
113
113
|
} catch (error) {
|
|
114
|
+
this.log('error', 'Param验证异常:', error);
|
|
114
115
|
// 参数验证异常时返回null
|
|
115
116
|
return null;
|
|
116
117
|
}
|
package/com/pendant/index.js
CHANGED
|
@@ -360,7 +360,7 @@ Pendant.prototype.renderBlock = async function (ctx, db, blocks) {
|
|
|
360
360
|
var html = '';
|
|
361
361
|
for (var i = 0; i < blocks.length; i++) {
|
|
362
362
|
var block = blocks[i];
|
|
363
|
-
var o = this.
|
|
363
|
+
var o = this.getMod(block.pendant);
|
|
364
364
|
if (o) {
|
|
365
365
|
var option = this.optionModel(block);
|
|
366
366
|
var ret = await o.call('main', ctx, db, option);
|
package/com/socket/drive.js
CHANGED
|
@@ -39,7 +39,7 @@ Drive.prototype._getStorageKey = function () {
|
|
|
39
39
|
* 确保数据引用有效(热更新后调用)
|
|
40
40
|
* @private
|
|
41
41
|
*/
|
|
42
|
-
Drive.prototype.
|
|
42
|
+
Drive.prototype._ensureRefs = function () {
|
|
43
43
|
var storage_key = this._getStorageKey();
|
|
44
44
|
|
|
45
45
|
// 检查全局存储是否存在
|
|
@@ -291,7 +291,7 @@ Drive.prototype.add = async function (ctx) {
|
|
|
291
291
|
*/
|
|
292
292
|
Drive.prototype.send = function (token, method, params) {
|
|
293
293
|
// 确保数据引用有效(热更新保护)
|
|
294
|
-
this.
|
|
294
|
+
this._ensureRefs();
|
|
295
295
|
|
|
296
296
|
var list = this.clients[token];
|
|
297
297
|
if (list && list.length > 0) {
|
|
@@ -319,7 +319,7 @@ Drive.prototype.send = function (token, method, params) {
|
|
|
319
319
|
*/
|
|
320
320
|
Drive.prototype.sendAll = function (method, params) {
|
|
321
321
|
// 确保数据引用有效(热更新保护)
|
|
322
|
-
this.
|
|
322
|
+
this._ensureRefs();
|
|
323
323
|
|
|
324
324
|
var data = {
|
|
325
325
|
method: method,
|
|
@@ -349,7 +349,7 @@ Drive.prototype.sendAll = function (method, params) {
|
|
|
349
349
|
*/
|
|
350
350
|
Drive.prototype.req = function (token, method, params, func, timeout = 0) {
|
|
351
351
|
// 确保数据引用有效(热更新保护)
|
|
352
|
-
this.
|
|
352
|
+
this._ensureRefs();
|
|
353
353
|
|
|
354
354
|
var list = this.clients[token];
|
|
355
355
|
if (list && list.length > 0) {
|
|
@@ -369,7 +369,7 @@ Drive.prototype.req = function (token, method, params, func, timeout = 0) {
|
|
|
369
369
|
|
|
370
370
|
// 设置超时移除定时器
|
|
371
371
|
var _this = this;
|
|
372
|
-
data.timer = setTimeout(
|
|
372
|
+
data.timer = setTimeout(() => {
|
|
373
373
|
_this._delMsgById(data.id);
|
|
374
374
|
}, data.timeout);
|
|
375
375
|
}
|
|
@@ -395,7 +395,7 @@ Drive.prototype.req = function (token, method, params, func, timeout = 0) {
|
|
|
395
395
|
*/
|
|
396
396
|
Drive.prototype.reqAll = function (method, params, func, timeout = 0) {
|
|
397
397
|
// 确保数据引用有效(热更新保护)
|
|
398
|
-
this.
|
|
398
|
+
this._ensureRefs();
|
|
399
399
|
|
|
400
400
|
var data = {
|
|
401
401
|
id: this._genMsgId(),
|
|
@@ -413,7 +413,7 @@ Drive.prototype.reqAll = function (method, params, func, timeout = 0) {
|
|
|
413
413
|
|
|
414
414
|
// 设置超时移除定时器
|
|
415
415
|
var _this = this;
|
|
416
|
-
data.timer = setTimeout(
|
|
416
|
+
data.timer = setTimeout(() => {
|
|
417
417
|
_this._delMsgById(data.id);
|
|
418
418
|
}, data.timeout);
|
|
419
419
|
}
|
|
@@ -446,7 +446,7 @@ Drive.prototype._genMsgId = function () {
|
|
|
446
446
|
*/
|
|
447
447
|
Drive.prototype._delMsgById = function (msg_id) {
|
|
448
448
|
// 确保数据引用有效(热更新保护)
|
|
449
|
-
this.
|
|
449
|
+
this._ensureRefs();
|
|
450
450
|
|
|
451
451
|
for (var i = 0; i < this.list_msg.length; i++) {
|
|
452
452
|
if (this.list_msg[i].id === msg_id) {
|
|
@@ -467,24 +467,24 @@ Drive.prototype._delMsgById = function (msg_id) {
|
|
|
467
467
|
*/
|
|
468
468
|
Drive.prototype._handleResponse = function (msg) {
|
|
469
469
|
// 确保数据引用有效(热更新保护)
|
|
470
|
-
this.
|
|
470
|
+
this._ensureRefs();
|
|
471
471
|
|
|
472
472
|
if (!msg || !msg.id) {
|
|
473
473
|
return;
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
for (var i = 0; i < this.list_msg.length; i++) {
|
|
477
|
-
|
|
478
|
-
if (
|
|
477
|
+
let o = this.list_msg[i];
|
|
478
|
+
if (o.id === msg.id && o.func) {
|
|
479
479
|
try {
|
|
480
480
|
// 执行回调函数
|
|
481
|
-
|
|
481
|
+
o.func(msg);
|
|
482
482
|
} catch (error) {
|
|
483
483
|
console.error('Socket驱动回调函数执行错误:', error);
|
|
484
484
|
}
|
|
485
485
|
|
|
486
486
|
// 从列表中移除已处理的消息
|
|
487
|
-
this._delMsgById(
|
|
487
|
+
this._delMsgById(o.id);
|
|
488
488
|
break;
|
|
489
489
|
}
|
|
490
490
|
}
|
package/com/socket/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const Drive = require('./drive');
|
|
|
7
7
|
* @class
|
|
8
8
|
*/
|
|
9
9
|
class Socket extends Manager {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
11
|
* 配置参数
|
|
12
12
|
* @type {object}
|
|
13
13
|
*/
|
|
@@ -282,17 +282,17 @@ Socket.prototype._handleResponse = function (msg) {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
for (var i = 0; i < this.list_msg.length; i++) {
|
|
285
|
-
|
|
286
|
-
if (
|
|
285
|
+
let o = this.list_msg[i];
|
|
286
|
+
if (o.id === msg.id && o.func) {
|
|
287
287
|
try {
|
|
288
288
|
// 执行回调函数
|
|
289
|
-
|
|
289
|
+
o.func(msg);
|
|
290
290
|
} catch (error) {
|
|
291
291
|
console.error('Socket回调函数执行错误:', error);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
// 从列表中移除已处理的消息
|
|
295
|
-
this._delMsgById(
|
|
295
|
+
this._delMsgById(o.id);
|
|
296
296
|
break;
|
|
297
297
|
}
|
|
298
298
|
}
|
package/com/sql/index.js
CHANGED
|
@@ -102,7 +102,7 @@ Sql.prototype.sort = function () {
|
|
|
102
102
|
* @returns {object} 执行结果
|
|
103
103
|
*/
|
|
104
104
|
Sql.prototype.run = async function (name, query, body, db) {
|
|
105
|
-
var obj = this.
|
|
105
|
+
var obj = this.getMod(name);
|
|
106
106
|
if (obj) {
|
|
107
107
|
var ret = await obj.run(query, body, db);
|
|
108
108
|
if (this.mode > 4) {
|
package/com/template/drive.js
CHANGED
|
@@ -3,43 +3,44 @@ const Item = require('mm_machine').Item;
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 主题模板驱动类
|
|
6
|
-
* @extends {Item}
|
|
7
6
|
* @class
|
|
8
7
|
*/
|
|
9
8
|
class Drive extends Item {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
static config = {
|
|
10
|
+
name: '',
|
|
11
|
+
title: '',
|
|
12
|
+
description: '',
|
|
13
|
+
version: '1.0.0',
|
|
14
|
+
preview: '',
|
|
15
|
+
preview_large: '',
|
|
16
|
+
git: ''
|
|
17
|
+
};
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
/**
|
|
20
|
+
* 主题模板驱动类
|
|
21
|
+
* @param {object} config 主题模板配置
|
|
22
|
+
* @param {object} parent 父项
|
|
23
|
+
*/
|
|
24
|
+
constructor(config, parent) {
|
|
25
|
+
super({ ...Drive.config, ...config }, parent);
|
|
26
|
+
// this.default_file = "./template.json";
|
|
27
|
+
// dir, "/static/template".fullname()
|
|
28
|
+
}
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
32
|
* 压缩主题模板
|
|
33
|
+
* @param {string} zip_dir 压缩目录
|
|
34
|
+
* @returns {object} 压缩后的文件对象
|
|
34
35
|
*/
|
|
35
|
-
Drive.prototype.zip = async function (zip_dir =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
Drive.prototype.zip = async function (zip_dir = '/static/file/zip/') {
|
|
37
|
+
var file = ('./' + this.config.name + '.zip').fullname(zip_dir);
|
|
38
|
+
file.addDir();
|
|
39
|
+
await compressing.zip.compressDir(this.getDir(), file);
|
|
40
|
+
if (file.hasFile()) {
|
|
41
|
+
return file;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -75,6 +76,6 @@ Drive.prototype.getModel = function (type) {
|
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
module.exports = {
|
|
78
|
-
|
|
79
|
+
Drive
|
|
79
80
|
};
|
|
80
81
|
|
package/com/template/index.js
CHANGED
|
@@ -3,12 +3,11 @@ const Index = require('mm_machine').Index;
|
|
|
3
3
|
const Drive = require('./drive').Drive;
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @extends {Index}
|
|
6
|
+
* 主题模板管理类
|
|
8
7
|
* @class
|
|
9
8
|
*/
|
|
10
9
|
class Template extends Index {
|
|
11
|
-
|
|
10
|
+
/**
|
|
12
11
|
* 配置参数
|
|
13
12
|
* @type {object}
|
|
14
13
|
*/
|
|
@@ -70,28 +69,26 @@ class Template extends Index {
|
|
|
70
69
|
mode: 3
|
|
71
70
|
};
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.type = "template";
|
|
82
|
-
this.title = config.title;
|
|
83
|
-
}
|
|
72
|
+
/**
|
|
73
|
+
* 构造函数
|
|
74
|
+
* @param {object} config 配置参数
|
|
75
|
+
* @param {object} parent 父项
|
|
76
|
+
*/
|
|
77
|
+
constructor(config, parent) {
|
|
78
|
+
super({ ...Template.config, ...config }, parent);
|
|
79
|
+
}
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
Template.prototype.Drive = Drive;
|
|
87
83
|
|
|
88
84
|
/**
|
|
89
85
|
* 解压模板
|
|
90
|
-
* @param {
|
|
86
|
+
* @param {string} file 模板压缩文件
|
|
87
|
+
* @returns {object} 解压后的文件对象
|
|
91
88
|
*/
|
|
92
89
|
Template.prototype.unzip = async function(file) {
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
var done = await compressing.zip.uncompress(file, '/static/template'.fullname());
|
|
91
|
+
return done;
|
|
95
92
|
};
|
|
96
93
|
|
|
97
94
|
/**
|
|
@@ -107,7 +104,7 @@ Template.prototype.get = function(key) {
|
|
|
107
104
|
* 主题模板模板池
|
|
108
105
|
*/
|
|
109
106
|
if (!$.pool.template) {
|
|
110
|
-
|
|
107
|
+
$.pool.template = {};
|
|
111
108
|
}
|
|
112
109
|
|
|
113
110
|
/**
|
|
@@ -117,25 +114,25 @@ if (!$.pool.template) {
|
|
|
117
114
|
* @returns {object} 返回一个缓存类
|
|
118
115
|
*/
|
|
119
116
|
function templateAdmin(scope, title) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
var sc = scope || $.val.scope + '';
|
|
118
|
+
var obj = $.pool.template[sc];
|
|
119
|
+
if (!obj) {
|
|
120
|
+
$.pool.template[sc] = new Template({
|
|
121
|
+
name: sc,
|
|
122
|
+
title: title
|
|
123
|
+
});
|
|
124
|
+
obj = $.pool.template[sc];
|
|
125
|
+
}
|
|
126
|
+
return obj;
|
|
130
127
|
}
|
|
131
128
|
|
|
132
129
|
/**
|
|
133
130
|
* @module 导出模板管理器
|
|
134
131
|
*/
|
|
135
132
|
if ($.admin) {
|
|
136
|
-
|
|
133
|
+
$.admin.template = templateAdmin;
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
module.exports = {
|
|
140
|
-
|
|
137
|
+
Template
|
|
141
138
|
};
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
/**
|
|
6
6
|
* 中间件初始化
|
|
7
|
-
* @param {object}
|
|
7
|
+
* @param {object} adapter 适配器
|
|
8
8
|
* @param {object} eventer 事件处理器
|
|
9
9
|
*/
|
|
10
|
-
async _init(
|
|
10
|
+
async _init(adapter, eventer) {
|
|
11
11
|
var event = $.admin.event('api', 'API事件');
|
|
12
12
|
// await event.call('update', 'app/');
|
|
13
13
|
await event.do('init');
|