mm_expand 2.2.4 → 2.2.6
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 +22 -18
- package/lib/event.js +2 -2
- package/package.json +1 -1
package/lib/base.js
CHANGED
|
@@ -296,7 +296,16 @@ Base.prototype._doCheckPhase = async function (method, ctx) {
|
|
|
296
296
|
*/
|
|
297
297
|
Base.prototype._doMainMethod = async function (method, ctx) {
|
|
298
298
|
if (!ctx.result) {
|
|
299
|
-
|
|
299
|
+
// 触发启动中事件
|
|
300
|
+
result = await this.emitWait(`${method}:main`, ctx);
|
|
301
|
+
if (result) {
|
|
302
|
+
ctx.result = result;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (!ctx.result) {
|
|
306
|
+
// 调用子类实现的启动逻辑
|
|
307
|
+
ctx.result = await this[method](...ctx.params);
|
|
308
|
+
}
|
|
300
309
|
}
|
|
301
310
|
};
|
|
302
311
|
|
|
@@ -366,7 +375,6 @@ Base.prototype.doEasy = async function (method, ...params) {
|
|
|
366
375
|
} catch (error) {
|
|
367
376
|
// 简单错误处理
|
|
368
377
|
this.log('error', `快速执行方法${method}出错:`, error);
|
|
369
|
-
throw error;
|
|
370
378
|
}
|
|
371
379
|
};
|
|
372
380
|
|
|
@@ -412,13 +420,23 @@ Base.prototype._hasEventListeners = function (method) {
|
|
|
412
420
|
this.listenerCount(method + ':after') > 0;
|
|
413
421
|
};
|
|
414
422
|
|
|
423
|
+
/**
|
|
424
|
+
* 主方法执行 - 内部实现
|
|
425
|
+
* @private
|
|
426
|
+
* @param {...object} params 参数列表
|
|
427
|
+
* @returns {object} 返回执行结果
|
|
428
|
+
*/
|
|
429
|
+
Base.prototype._main = async function (...params) {
|
|
430
|
+
console.log('main', ...params);
|
|
431
|
+
return null;
|
|
432
|
+
};
|
|
433
|
+
|
|
415
434
|
/**
|
|
416
435
|
* 主要执行方法
|
|
417
436
|
* @param {...any} params 参数列表
|
|
418
437
|
*/
|
|
419
438
|
Base.prototype.main = async function (...params) {
|
|
420
|
-
|
|
421
|
-
return null;
|
|
439
|
+
return await this._main(...params);
|
|
422
440
|
};
|
|
423
441
|
|
|
424
442
|
/**
|
|
@@ -430,20 +448,6 @@ Base.prototype.run = async function (...params) {
|
|
|
430
448
|
return await this.do('main', ...params);
|
|
431
449
|
};
|
|
432
450
|
|
|
433
|
-
/**
|
|
434
|
-
* 执行方法
|
|
435
|
-
* @param {string} method 方法名称
|
|
436
|
-
* @param {...any} params 参数列表
|
|
437
|
-
* @returns
|
|
438
|
-
*/
|
|
439
|
-
Base.prototype.exec = async function (method, ...params) {
|
|
440
|
-
const ret = await this._do(method, ...params);
|
|
441
|
-
if (ret.error) {
|
|
442
|
-
throw ret.error;
|
|
443
|
-
}
|
|
444
|
-
return ret.result;
|
|
445
|
-
};
|
|
446
|
-
|
|
447
451
|
/**
|
|
448
452
|
* 执行指令(主要)
|
|
449
453
|
* @param {string} command 指令
|
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.6",
|
|
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": {
|