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
|
@@ -37,11 +37,11 @@ class App extends Drive {
|
|
|
37
37
|
'author': 'qww',
|
|
38
38
|
'scope': 'server',
|
|
39
39
|
'dir': '',
|
|
40
|
-
// 游戏配置,非游戏模块不需要配置
|
|
41
|
-
'game': {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
40
|
+
// // 游戏配置,非游戏模块不需要配置
|
|
41
|
+
// 'game': {
|
|
42
|
+
// // 游戏类型
|
|
43
|
+
// 'type': 'card_game'
|
|
44
|
+
// },
|
|
45
45
|
'dependencies': [],
|
|
46
46
|
// // 压缩目录
|
|
47
47
|
// 'zip_dir': './static/file/zip',
|
|
@@ -183,12 +183,12 @@ App.prototype._initManager = async function () {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
// 并行执行所有管理器的初始化操作
|
|
186
|
-
var
|
|
186
|
+
var list = [];
|
|
187
187
|
for (var j = 0; j < managers.length; j++) {
|
|
188
|
-
|
|
188
|
+
list.push(managers[j].do('init'));
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
await Promise.all(
|
|
191
|
+
await Promise.all(list);
|
|
192
192
|
// console.timeEnd('[TIMING] App._initManager');
|
|
193
193
|
};
|
|
194
194
|
|
|
@@ -216,29 +216,16 @@ App.prototype._loadSources = async function () {
|
|
|
216
216
|
* 初始化路由相关模块
|
|
217
217
|
*/
|
|
218
218
|
App.prototype._initRouteMod = async function () {
|
|
219
|
-
// console.time('[TIMING] App._initRouteMod');
|
|
220
|
-
|
|
221
|
-
// console.time('[TIMING] App._initRouteMod/store+view+model');
|
|
222
219
|
await Promise.all([
|
|
223
220
|
this.manager.store.runAll('init', this.sql, this.cache, this.getLogger()),
|
|
224
221
|
this.manager.view.runAll('init', this.getLogger()),
|
|
225
222
|
this.manager.model.runAll('init', this.getEventer(), this.getLogger())
|
|
226
223
|
]);
|
|
227
|
-
// console.timeEnd('[TIMING] App._initRouteMod/store+view+model');
|
|
228
|
-
|
|
229
|
-
// console.time('[TIMING] App._initRouteMod/service');
|
|
230
224
|
await this.manager.service.runAll('init', this.model, this.getEventer(), this.getLogger());
|
|
231
|
-
// console.timeEnd('[TIMING] App._initRouteMod/service');
|
|
232
|
-
|
|
233
|
-
// console.time('[TIMING] App._initRouteMod/controller+handler');
|
|
234
|
-
|
|
235
225
|
await Promise.all([
|
|
236
226
|
this.manager.controller.runAll('init', this.model, this.service, this.view, this.getEventer(), this.getLogger()),
|
|
237
227
|
this.manager.handler.runAll('init', this, this.getEventer(), this.getLogger())
|
|
238
228
|
]);
|
|
239
|
-
// console.timeEnd('[TIMING] App._initRouteMod/controller+handler');
|
|
240
|
-
|
|
241
|
-
// console.timeEnd('[TIMING] App._initRouteMod');
|
|
242
229
|
};
|
|
243
230
|
|
|
244
231
|
/**
|
|
@@ -246,15 +233,8 @@ App.prototype._initRouteMod = async function () {
|
|
|
246
233
|
* @returns {Promise<void>} 初始化完成
|
|
247
234
|
*/
|
|
248
235
|
App.prototype._initSources = async function () {
|
|
249
|
-
// console.time('[TIMING] App._initSources');
|
|
250
|
-
|
|
251
|
-
// console.time('[TIMING] App._initSources/plugin');
|
|
252
|
-
// await this.manager.plugin.runWait('init', this, this.getEventer(), this.getLogger());
|
|
253
|
-
await this.manager.plugin.runAll('init', this, this.getEventer(), this.getLogger());
|
|
254
|
-
// console.timeEnd('[TIMING] App._initSources/plugin');
|
|
255
|
-
|
|
256
236
|
await this._initRouteMod();
|
|
257
|
-
|
|
237
|
+
await this.manager.plugin.runWait('init', this, this.getEventer(), this.getLogger());
|
|
258
238
|
};
|
|
259
239
|
|
|
260
240
|
/**
|
|
@@ -265,7 +245,7 @@ App.prototype._initSources = async function () {
|
|
|
265
245
|
* @private
|
|
266
246
|
*/
|
|
267
247
|
App.prototype._initCore = async function (server, eventer, logger) {
|
|
268
|
-
|
|
248
|
+
if (logger) {
|
|
269
249
|
this.setLogger(logger);
|
|
270
250
|
}
|
|
271
251
|
if (eventer) {
|
|
@@ -358,32 +338,6 @@ App.prototype._validateDep = function () {
|
|
|
358
338
|
}
|
|
359
339
|
};
|
|
360
340
|
|
|
361
|
-
/**
|
|
362
|
-
* 记录初始化结果
|
|
363
|
-
* @param {Array} results 初始化结果数组
|
|
364
|
-
* @private
|
|
365
|
-
*/
|
|
366
|
-
App.prototype._logInitResults = function (results) {
|
|
367
|
-
var success = 0;
|
|
368
|
-
var error = 0;
|
|
369
|
-
var error_modules = [];
|
|
370
|
-
|
|
371
|
-
for (var result of results) {
|
|
372
|
-
if (result.result && result.result.error_count > 0) {
|
|
373
|
-
error += result.result.error_count;
|
|
374
|
-
error_modules.push(result.name);
|
|
375
|
-
} else {
|
|
376
|
-
success++;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (error > 0) {
|
|
381
|
-
this.log('warn', `资源初始化完成,成功: ${success}, 失败: ${error}, 失败模块: ${error_modules.join(', ')}`);
|
|
382
|
-
} else {
|
|
383
|
-
this.log('info', `所有资源初始化成功,共 ${success} 个模块`);
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
|
-
|
|
387
341
|
/**
|
|
388
342
|
* 压缩插件
|
|
389
343
|
* @param {string} name 插件名称
|
package/core/app/index.js
CHANGED
|
@@ -3,24 +3,6 @@ const {
|
|
|
3
3
|
Manager,
|
|
4
4
|
Drive
|
|
5
5
|
} = require('mm_machine');
|
|
6
|
-
const {
|
|
7
|
-
Controller
|
|
8
|
-
} = require('../controller/index.js');
|
|
9
|
-
const {
|
|
10
|
-
View
|
|
11
|
-
} = require('../view/index.js');
|
|
12
|
-
const {
|
|
13
|
-
Handler
|
|
14
|
-
} = require('../handler/index.js');
|
|
15
|
-
const {
|
|
16
|
-
Service
|
|
17
|
-
} = require('../service/index.js');
|
|
18
|
-
const {
|
|
19
|
-
Model
|
|
20
|
-
} = require('../model/index.js');
|
|
21
|
-
const {
|
|
22
|
-
Store
|
|
23
|
-
} = require('../store/index.js');
|
|
24
6
|
const {
|
|
25
7
|
Plugin
|
|
26
8
|
} = require('../plugin/index.js');
|
|
@@ -94,21 +76,6 @@ class App extends Drive {
|
|
|
94
76
|
// 管理器集合
|
|
95
77
|
this.manager = {};
|
|
96
78
|
|
|
97
|
-
/** == 业务类 == */
|
|
98
|
-
// MVC 架构
|
|
99
|
-
// 控制器集合
|
|
100
|
-
this.controller = {};
|
|
101
|
-
// 视图集合
|
|
102
|
-
this.view = {};
|
|
103
|
-
// 操作器集合
|
|
104
|
-
this.handler = {};
|
|
105
|
-
// 领域服务
|
|
106
|
-
this.service = {};
|
|
107
|
-
// 富血模型
|
|
108
|
-
this.model = {};
|
|
109
|
-
// 仓储
|
|
110
|
-
this.store = {};
|
|
111
|
-
|
|
112
79
|
// 插件,用于功能扩展
|
|
113
80
|
this.plugin = {};
|
|
114
81
|
}
|
|
@@ -163,12 +130,6 @@ App.prototype._initManager = async function () {
|
|
|
163
130
|
// console.time('[TIMING] App._initManager');
|
|
164
131
|
// 管理器配置列表
|
|
165
132
|
var mgr_configs = [
|
|
166
|
-
{ name: 'store', title: '仓储', Module: Store },
|
|
167
|
-
{ name: 'model', title: '模型', Module: Model },
|
|
168
|
-
{ name: 'service', title: '服务', Module: Service },
|
|
169
|
-
{ name: 'handler', title: '操作器', Module: Handler },
|
|
170
|
-
{ name: 'view', title: '视图', Module: View },
|
|
171
|
-
{ name: 'controller', title: '控制器', Module: Controller },
|
|
172
133
|
{ name: 'plugin', title: '插件', Module: Plugin }
|
|
173
134
|
];
|
|
174
135
|
|
|
@@ -197,35 +158,7 @@ App.prototype._initManager = async function () {
|
|
|
197
158
|
* @returns {Promise<void>} 加载完成
|
|
198
159
|
*/
|
|
199
160
|
App.prototype._loadSources = async function () {
|
|
200
|
-
|
|
201
|
-
// 加载无需依赖关系,所以可以同时加载,内部并行执行
|
|
202
|
-
let loadPromises = [
|
|
203
|
-
this.manager.store.runAll('load'),
|
|
204
|
-
this.manager.model.runAll('load'),
|
|
205
|
-
this.manager.service.runAll('load'),
|
|
206
|
-
this.manager.handler.runAll('load'),
|
|
207
|
-
this.manager.view.runAll('load'),
|
|
208
|
-
this.manager.controller.runAll('load'),
|
|
209
|
-
this.manager.plugin.runAll('load')
|
|
210
|
-
];
|
|
211
|
-
await Promise.all(loadPromises);
|
|
212
|
-
// console.timeEnd('[TIMING] App._loadSources');
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* 初始化路由相关模块
|
|
217
|
-
*/
|
|
218
|
-
App.prototype._initRouteMod = async function () {
|
|
219
|
-
await Promise.all([
|
|
220
|
-
this.manager.store.runAll('init', this.sql, this.cache, this.getLogger()),
|
|
221
|
-
this.manager.view.runAll('init', this.getLogger()),
|
|
222
|
-
this.manager.model.runAll('init', this.getEventer(), this.getLogger())
|
|
223
|
-
]);
|
|
224
|
-
await this.manager.service.runAll('init', this.model, this.getEventer(), this.getLogger());
|
|
225
|
-
await Promise.all([
|
|
226
|
-
this.manager.controller.runAll('init', this.model, this.service, this.view, this.getEventer(), this.getLogger()),
|
|
227
|
-
this.manager.handler.runAll('init', this, this.getEventer(), this.getLogger())
|
|
228
|
-
]);
|
|
161
|
+
await this.manager.plugin.runAll('load');
|
|
229
162
|
};
|
|
230
163
|
|
|
231
164
|
/**
|
|
@@ -233,8 +166,7 @@ App.prototype._initRouteMod = async function () {
|
|
|
233
166
|
* @returns {Promise<void>} 初始化完成
|
|
234
167
|
*/
|
|
235
168
|
App.prototype._initSources = async function () {
|
|
236
|
-
await this.
|
|
237
|
-
await this.manager.plugin.runWait('init', this, this.getEventer(), this.getLogger());
|
|
169
|
+
await this.manager.plugin.runAll('init', this, this.getEventer(), this.getLogger());
|
|
238
170
|
};
|
|
239
171
|
|
|
240
172
|
/**
|
|
@@ -245,7 +177,7 @@ App.prototype._initSources = async function () {
|
|
|
245
177
|
* @private
|
|
246
178
|
*/
|
|
247
179
|
App.prototype._initCore = async function (server, eventer, logger) {
|
|
248
|
-
|
|
180
|
+
if (logger) {
|
|
249
181
|
this.setLogger(logger);
|
|
250
182
|
}
|
|
251
183
|
if (eventer) {
|
|
@@ -301,16 +233,7 @@ App.prototype._initBase = async function () {
|
|
|
301
233
|
* 启动资源
|
|
302
234
|
*/
|
|
303
235
|
App.prototype._startSources = async function () {
|
|
304
|
-
|
|
305
|
-
let startPromises = [
|
|
306
|
-
this.manager.handler.runAll('start'),
|
|
307
|
-
this.manager.service.runAll('start'),
|
|
308
|
-
this.manager.store.runAll('start'),
|
|
309
|
-
this.manager.plugin.runAll('start')
|
|
310
|
-
];
|
|
311
|
-
|
|
312
|
-
// 等待其他管理器启动完成
|
|
313
|
-
await Promise.all(startPromises);
|
|
236
|
+
await this.manager.plugin.runAll('start');
|
|
314
237
|
};
|
|
315
238
|
|
|
316
239
|
/**
|
|
@@ -329,7 +252,7 @@ App.prototype._startCore = async function () {
|
|
|
329
252
|
* @private
|
|
330
253
|
*/
|
|
331
254
|
App.prototype._validateDep = function () {
|
|
332
|
-
var required_managers = ['
|
|
255
|
+
var required_managers = ['plugin'];
|
|
333
256
|
|
|
334
257
|
for (var name of required_managers) {
|
|
335
258
|
if (!this.manager[name]) {
|
package/core/channel/index.js
CHANGED
package/core/controller/index.js
CHANGED
|
@@ -335,9 +335,7 @@ Controller.prototype._after = async function (req, res, result) {
|
|
|
335
335
|
/**
|
|
336
336
|
* 格式化响应
|
|
337
337
|
* 优化:复用响应对象,减少GC压力
|
|
338
|
-
* @param {
|
|
339
|
-
* @param {string} message 响应消息
|
|
340
|
-
* @param {object} data 响应数据
|
|
338
|
+
* @param {object} result 响应数据
|
|
341
339
|
* @returns {object} 格式化后的响应对象
|
|
342
340
|
*/
|
|
343
341
|
Controller.prototype._formatResponse = function (result) {
|
package/core/game/bat/world.js
CHANGED
package/core/game/index.js
CHANGED
package/core/middleware/index.js
CHANGED
|
@@ -34,12 +34,12 @@ Middleware.prototype.getTplDir = function () {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* 初始化核心
|
|
37
|
-
* @param {object}
|
|
37
|
+
* @param {object} adapter 适配器
|
|
38
38
|
* @param {object} eventer 事件总线
|
|
39
39
|
* @param {object} logger 日志管理器
|
|
40
40
|
* @returns {Promise<void>}
|
|
41
41
|
*/
|
|
42
|
-
Middleware.prototype._initCore = async function (
|
|
42
|
+
Middleware.prototype._initCore = async function (adapter, eventer, logger) {
|
|
43
43
|
// 初始化依赖项
|
|
44
44
|
if (logger) {
|
|
45
45
|
this.setLogger(logger);
|
|
@@ -49,9 +49,9 @@ Middleware.prototype._initCore = async function (apapter, eventer, logger) {
|
|
|
49
49
|
return eventer;
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
-
if (
|
|
52
|
+
if (adapter) {
|
|
53
53
|
this.getAdapter = function () {
|
|
54
|
-
return
|
|
54
|
+
return adapter[this.config.type];
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
this._register();
|
|
@@ -4,11 +4,11 @@
|
|
|
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(
|
|
11
|
-
this.log('debug', 'middleware _init 被调用', {
|
|
10
|
+
async _init(adapter, eventer) {
|
|
11
|
+
this.log('debug', 'middleware _init 被调用', { adapter, eventer });
|
|
12
12
|
// 初始化代码写在这
|
|
13
13
|
// 可在这里注入其他中间件
|
|
14
14
|
},
|
package/core/plugin/index.js
CHANGED
|
@@ -108,51 +108,109 @@ Plugin.prototype._initOptions = function () {
|
|
|
108
108
|
this.backupOptions();
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* 转换数字类型值
|
|
113
|
+
* @param {*} value 原始值
|
|
114
|
+
* @returns {number} 转换后的值
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
Plugin.prototype._convertNumber = function (value) {
|
|
118
|
+
if (value === 'null') return 0;
|
|
119
|
+
return Number(value || '0');
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 转换布尔类型值
|
|
124
|
+
* @param {*} value 原始值
|
|
125
|
+
* @returns {boolean} 转换后的值
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
Plugin.prototype._convertBoolean = function (value) {
|
|
129
|
+
if (!value) return false;
|
|
130
|
+
if (typeof value === 'boolean') return value;
|
|
131
|
+
if (typeof value === 'string') {
|
|
132
|
+
return value === '1' || value === 'true';
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 转换对象类型值
|
|
139
|
+
* @param {*} value 原始值
|
|
140
|
+
* @returns {object} 转换后的值
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
Plugin.prototype._convertObject = function (value) {
|
|
144
|
+
if (value === 'null') return {};
|
|
145
|
+
return value.toJSON ? value.toJSON() : {};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 转换数组类型值
|
|
150
|
+
* @param {*} value 原始值
|
|
151
|
+
* @returns {Array} 转换后的值
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
Plugin.prototype._convertArray = function (value) {
|
|
155
|
+
if (value === 'null') return [];
|
|
156
|
+
return value.toJSON ? value.toJSON() : [];
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 转换字符串类型值
|
|
161
|
+
* @param {*} value 原始值
|
|
162
|
+
* @returns {string} 转换后的值
|
|
163
|
+
* @private
|
|
164
|
+
*/
|
|
165
|
+
Plugin.prototype._convertString = function (value) {
|
|
166
|
+
if (value === 'null') return null;
|
|
167
|
+
return value || '';
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 转换单个配置项的值
|
|
172
|
+
* @param {object} option 配置项
|
|
173
|
+
* @returns {*} 转换后的值
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
Plugin.prototype._convertOptionValue = function (option) {
|
|
177
|
+
var val = option.value;
|
|
178
|
+
if (val === 'null') return null;
|
|
179
|
+
|
|
180
|
+
var type = option.type;
|
|
181
|
+
switch (type) {
|
|
182
|
+
case 'number':
|
|
183
|
+
return this._convertNumber(val);
|
|
184
|
+
case 'boolean':
|
|
185
|
+
return this._convertBoolean(val);
|
|
186
|
+
case 'object':
|
|
187
|
+
return this._convertObject(val);
|
|
188
|
+
case 'array':
|
|
189
|
+
return this._convertArray(val);
|
|
190
|
+
case 'string':
|
|
191
|
+
return this._convertString(val);
|
|
192
|
+
default:
|
|
193
|
+
return val;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
111
197
|
/**
|
|
112
198
|
* 获取配置参数
|
|
113
|
-
* @
|
|
199
|
+
* @returns {object} 返回配置参数
|
|
114
200
|
*/
|
|
115
201
|
Plugin.prototype.getConfigOptions = function () {
|
|
116
202
|
var op = this.config.options || [];
|
|
117
203
|
var dict = {};
|
|
118
204
|
for (var i = 0; i < op.length; i++) {
|
|
119
205
|
var o = op[i];
|
|
120
|
-
|
|
121
|
-
var val = o.value === 'null' ? '0' : o.value;
|
|
122
|
-
dict[o.name] = Number(val || '0');
|
|
123
|
-
} else if (o.type === "boolean") {
|
|
124
|
-
var val = false;
|
|
125
|
-
if (o.value) {
|
|
126
|
-
if (typeof (o.value) == "string") {
|
|
127
|
-
if (o.value == '1' || o.value == 'true') {
|
|
128
|
-
val = true;
|
|
129
|
-
}
|
|
130
|
-
} else if (typeof (o.value) == "boolean") {
|
|
131
|
-
val = o.value;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
dict[o.name] = val;
|
|
135
|
-
} else if (o.type === "object") {
|
|
136
|
-
var val = o.value === 'null' ? '{}' : o.value;
|
|
137
|
-
dict[o.name] = o.value.toJSON();
|
|
138
|
-
} else if (o.type === "array") {
|
|
139
|
-
var val = o.value === 'null' ? '[]' : o.value;
|
|
140
|
-
dict[o.name] = o.value.toJSON();
|
|
141
|
-
} else if (o.value === "null") {
|
|
142
|
-
dict[o.name] = null;
|
|
143
|
-
} else if (o.type === "string") {
|
|
144
|
-
dict[o.name] = o.value || "";
|
|
145
|
-
} else {
|
|
146
|
-
dict[o.name] = o.value;
|
|
147
|
-
}
|
|
206
|
+
dict[o.name] = this._convertOptionValue(o);
|
|
148
207
|
}
|
|
149
208
|
return dict;
|
|
150
209
|
};
|
|
151
210
|
|
|
152
211
|
/**
|
|
153
212
|
* 设计配置
|
|
154
|
-
* @param {
|
|
155
|
-
* @return {Object} 返回配置参数
|
|
213
|
+
* @param {object} body 配置参数
|
|
156
214
|
*/
|
|
157
215
|
Plugin.prototype.designOptions = function (body) {
|
|
158
216
|
var cg = this.config;
|
|
@@ -174,6 +232,7 @@ Plugin.prototype.designOptions = function (body) {
|
|
|
174
232
|
|
|
175
233
|
/**
|
|
176
234
|
* 保存配置
|
|
235
|
+
* @param {object} options 配置参数
|
|
177
236
|
*/
|
|
178
237
|
Plugin.prototype.saveOptions = function (options) {
|
|
179
238
|
this.options = options;
|
|
@@ -192,7 +251,8 @@ Plugin.prototype.backupOptions = function () {
|
|
|
192
251
|
|
|
193
252
|
/**
|
|
194
253
|
* 合并配置
|
|
195
|
-
* @param {
|
|
254
|
+
* @param {object} options 配置参数
|
|
255
|
+
* @returns {object} 返回配置参数
|
|
196
256
|
*/
|
|
197
257
|
Plugin.prototype.mergeOptions = function (options) {
|
|
198
258
|
var file = this._getCacheOptionsFile();
|
|
@@ -208,10 +268,6 @@ Plugin.prototype.mergeOptions = function (options) {
|
|
|
208
268
|
* @returns {string} 缓存配置文件
|
|
209
269
|
*/
|
|
210
270
|
Plugin.prototype._getCacheOptionsFile = function () {
|
|
211
|
-
// let app = this.getApp();
|
|
212
|
-
// let app_name = app.config.name;
|
|
213
|
-
// let plugin_name = this.config.name;
|
|
214
|
-
var l = $.slash;
|
|
215
271
|
let plugin_name = this.config.name;
|
|
216
272
|
let app_name = this.getApp().config.name;
|
|
217
273
|
var file = `/cache/${app_name}/${plugin_name}/config.json`.fullname();
|
|
@@ -234,7 +290,7 @@ Drive.prototype.getModel = function (type) {
|
|
|
234
290
|
model.app = app_name;
|
|
235
291
|
model.plugin = plugin_name;
|
|
236
292
|
model.name = model.name || name;
|
|
237
|
-
model.path =
|
|
293
|
+
model.path = '/' + app_name + '/' + name;
|
|
238
294
|
return model;
|
|
239
295
|
};
|
|
240
296
|
|
package/core/room/room.js
CHANGED
|
@@ -21,7 +21,7 @@ class Room {
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* 房间类构造函数
|
|
24
|
-
* @param {
|
|
24
|
+
* @param {object} config 房间配置对象
|
|
25
25
|
*/
|
|
26
26
|
constructor(config) {
|
|
27
27
|
// 房间ID
|
|
@@ -42,7 +42,7 @@ class Room {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* 设置房间配置
|
|
45
|
-
* @param {
|
|
45
|
+
* @param {object} config 房间配置对象
|
|
46
46
|
*/
|
|
47
47
|
Room.prototype.setConfig = function (config) {
|
|
48
48
|
Object.assign(this.config, config);
|
package/core/scene/index.js
CHANGED
package/core/zone/bat/index.js
CHANGED
|
@@ -88,6 +88,7 @@ class Zone extends Drive {
|
|
|
88
88
|
* @param {number} config.diy_cache 自定义缓存
|
|
89
89
|
* @param {object} config.sql sql 配置
|
|
90
90
|
* @param {object} config.cache 缓存配置
|
|
91
|
+
* @param {object} parent 父分区对象
|
|
91
92
|
*/
|
|
92
93
|
constructor(config, parent) {
|
|
93
94
|
super({ ...Zone.config, ...config }, parent);
|
|
@@ -198,6 +199,7 @@ Zone.prototype._initBase = async function () {
|
|
|
198
199
|
* @param {object} app 游戏应用
|
|
199
200
|
* @param {object} eventer 事件总线
|
|
200
201
|
* @param {object} logger 日志管理器
|
|
202
|
+
* @returns {object} 返回分区对象
|
|
201
203
|
*/
|
|
202
204
|
Zone.prototype._initCore = async function (app, eventer, logger) {
|
|
203
205
|
// 初始化依赖项
|
package/core/zone/index.js
CHANGED
|
@@ -94,6 +94,7 @@ class Zone extends Drive {
|
|
|
94
94
|
* @param {number} config.diy_cache 自定义缓存
|
|
95
95
|
* @param {object} config.sql sql 配置
|
|
96
96
|
* @param {object} config.cache 缓存配置
|
|
97
|
+
* @param {object} parent 父分区对象
|
|
97
98
|
*/
|
|
98
99
|
constructor(config, parent) {
|
|
99
100
|
super({ ...Zone.config, ...config }, parent);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_os",
|
|
3
3
|
"description": "MM_OS服务端架构,用于快速构建应用程序,支持网站建设、小程序后台、AI应用、物联网(IOT/AIOT)、游戏服务端等多种场景。",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.9",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"AI",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"js-beautify": "^1.15.4",
|
|
32
32
|
"koa": "^3.2.1",
|
|
33
33
|
"koa-body": "^8.0.0",
|
|
34
|
-
"koa-compress": "^5.2.
|
|
34
|
+
"koa-compress": "^5.2.2",
|
|
35
35
|
"koa-send": "^5.0.1",
|
|
36
36
|
"koa-websocket": "^7.0.0",
|
|
37
37
|
"markdown": "^0.5.0",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"mm_statics": "^1.8.4",
|
|
53
53
|
"mm_xml": "^1.1.7",
|
|
54
54
|
"mqtt": "^5.15.1",
|
|
55
|
-
"openai": "^6.
|
|
55
|
+
"openai": "^6.44.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/jest": "^30.0.0",
|
|
59
59
|
"eslint-formatter-table": "^7.32.1",
|
|
60
|
-
"eslint-plugin-jsdoc": "^63.0.
|
|
60
|
+
"eslint-plugin-jsdoc": "^63.0.6",
|
|
61
61
|
"jest": "^30.4.2",
|
|
62
|
-
"mm_eslint": "^1.7.
|
|
62
|
+
"mm_eslint": "^1.7.5"
|
|
63
63
|
},
|
|
64
64
|
"repository": {
|
|
65
65
|
"type": "git",
|
|
@@ -81,4 +81,4 @@
|
|
|
81
81
|
"tcp.js",
|
|
82
82
|
"software.js"
|
|
83
83
|
]
|
|
84
|
-
}
|
|
84
|
+
}
|
package/server.js
CHANGED
|
@@ -75,7 +75,7 @@ class Server {
|
|
|
75
75
|
expire: 0,
|
|
76
76
|
max: 0,
|
|
77
77
|
persist: false, // 是否启用持久化
|
|
78
|
-
|
|
78
|
+
save_interval: 60000 // 保存间隔(毫秒)
|
|
79
79
|
},
|
|
80
80
|
// 缓存配置
|
|
81
81
|
redis: {
|
|
@@ -88,7 +88,7 @@ class Server {
|
|
|
88
88
|
// 数据库
|
|
89
89
|
database: 0,
|
|
90
90
|
// 前缀
|
|
91
|
-
prefix:
|
|
91
|
+
prefix: 'mm_',
|
|
92
92
|
// 连接超时时间(ms)
|
|
93
93
|
connect_timeout: 5000,
|
|
94
94
|
// 重试次数
|
|
@@ -160,7 +160,7 @@ class Server {
|
|
|
160
160
|
// 是否开启gzip压缩
|
|
161
161
|
gzip: false,
|
|
162
162
|
// 静态文件根目录
|
|
163
|
-
root:
|
|
163
|
+
root: './static',
|
|
164
164
|
// 编译vue文件,启动后会将vue转为js,可让前端通过 import xxx from './xxx.vue' 引入
|
|
165
165
|
compile_vue: true,
|
|
166
166
|
// 编译markdown文件,启动后会将markdown转为html
|
|
@@ -414,6 +414,7 @@ Server.prototype._stop = async function () {
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* 运行
|
|
417
|
+
* @returns {object} 服务器实例
|
|
417
418
|
*/
|
|
418
419
|
Server.prototype.run = async function () {
|
|
419
420
|
// 初始化
|