mm_expand 2.2.4 → 2.2.5
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/lib/base.js +38 -3
- package/lib/event.js +2 -2
- package/package.json +1 -1
package/lib/base.js
CHANGED
|
@@ -288,6 +288,22 @@ Base.prototype._doCheckPhase = async function (method, ctx) {
|
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
290
|
|
|
291
|
+
/**
|
|
292
|
+
* 执行方法
|
|
293
|
+
* @param {string} method 方法名称
|
|
294
|
+
* @param {...object} params 参数列表
|
|
295
|
+
* @returns {object} 返回执行结果
|
|
296
|
+
*/
|
|
297
|
+
Base.prototype._exec = async function (method, ...params) {
|
|
298
|
+
if (this[method]) {
|
|
299
|
+
try {
|
|
300
|
+
return await this[method](...params);
|
|
301
|
+
} catch (error) {
|
|
302
|
+
this.log('error', `[${this.config.name}] ${method}方法执行失败!`, error);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
291
307
|
/**
|
|
292
308
|
* 主方法执行
|
|
293
309
|
* @param {string} method 方法名称
|
|
@@ -296,7 +312,16 @@ Base.prototype._doCheckPhase = async function (method, ctx) {
|
|
|
296
312
|
*/
|
|
297
313
|
Base.prototype._doMainMethod = async function (method, ctx) {
|
|
298
314
|
if (!ctx.result) {
|
|
299
|
-
|
|
315
|
+
// 触发启动中事件
|
|
316
|
+
result = await this.emitWait(`${method}:main`, ctx);
|
|
317
|
+
if (result) {
|
|
318
|
+
ctx.result = result;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (!ctx.result) {
|
|
322
|
+
// 调用子类实现的启动逻辑
|
|
323
|
+
ctx.result = await this._exec(method, ...ctx.params);
|
|
324
|
+
}
|
|
300
325
|
}
|
|
301
326
|
};
|
|
302
327
|
|
|
@@ -412,13 +437,23 @@ Base.prototype._hasEventListeners = function (method) {
|
|
|
412
437
|
this.listenerCount(method + ':after') > 0;
|
|
413
438
|
};
|
|
414
439
|
|
|
440
|
+
/**
|
|
441
|
+
* 主方法执行 - 内部实现
|
|
442
|
+
* @private
|
|
443
|
+
* @param {...object} params 参数列表
|
|
444
|
+
* @returns {object} 返回执行结果
|
|
445
|
+
*/
|
|
446
|
+
Base.prototype._main = async function (...params) {
|
|
447
|
+
console.log('main', ...params);
|
|
448
|
+
return null;
|
|
449
|
+
};
|
|
450
|
+
|
|
415
451
|
/**
|
|
416
452
|
* 主要执行方法
|
|
417
453
|
* @param {...any} params 参数列表
|
|
418
454
|
*/
|
|
419
455
|
Base.prototype.main = async function (...params) {
|
|
420
|
-
|
|
421
|
-
return null;
|
|
456
|
+
return await this._main(...params);
|
|
422
457
|
};
|
|
423
458
|
|
|
424
459
|
/**
|
package/lib/event.js
CHANGED
|
@@ -555,10 +555,10 @@ class Event {
|
|
|
555
555
|
try {
|
|
556
556
|
this.#event_config.error_handler(error, event_name, args);
|
|
557
557
|
} catch (handler_error) {
|
|
558
|
-
this.
|
|
558
|
+
this.log('error', '错误处理函数执行失败:', handler_error);
|
|
559
559
|
}
|
|
560
560
|
} else {
|
|
561
|
-
this.
|
|
561
|
+
this.log('error', `事件 ${event_name} 执行失败:`, error);
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_expand",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Super Meimei Prototype Function Extension Module - Enhanced operations for string, array, object, date manipulation with error prevention and simplified business logic.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|