@tapd/tplugin-core 1.31.0 → 1.32.0
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/package.json +2 -2
- package/src/core.js +1 -1
- package/src/tools.js +31 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapd/tplugin-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.32.0",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"description": "tplugin-core",
|
|
6
6
|
"scripts": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"src",
|
|
34
34
|
"!src/config.js"
|
|
35
35
|
],
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "f2354ca243fd36c64870ef8c8c79d27a2e754250"
|
|
37
37
|
}
|
package/src/core.js
CHANGED
|
@@ -166,7 +166,7 @@ class EventHandler {
|
|
|
166
166
|
const handlerModule = require(moduleName);
|
|
167
167
|
if (funcName in handlerModule) {
|
|
168
168
|
// 调用模块方法,并返回响应值
|
|
169
|
-
return handlerModule[funcName](this.data.data);
|
|
169
|
+
return handlerModule[funcName](this.data.data, {func, reqType, address});
|
|
170
170
|
}
|
|
171
171
|
throw new Error(`function [${funcName}] Not Found or Not Export`);
|
|
172
172
|
}
|
package/src/tools.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = {
|
|
|
4
4
|
* @param {string} text - 日志索引
|
|
5
5
|
*/
|
|
6
6
|
custom_log_1(text){
|
|
7
|
-
console._stdout.write(JSON.stringify({"CUSTOM_Index1": text})+'\n');
|
|
7
|
+
console._stdout.write(JSON.stringify({"CUSTOM_Index1": text.toString()})+'\n');
|
|
8
8
|
},
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -12,7 +12,35 @@ module.exports = {
|
|
|
12
12
|
* @param {string} text - 日志索引
|
|
13
13
|
*/
|
|
14
14
|
custom_log_2(text){
|
|
15
|
-
console._stdout.write(JSON.stringify({"CUSTOM_Index2": text})+'\n');
|
|
16
|
-
}
|
|
15
|
+
console._stdout.write(JSON.stringify({"CUSTOM_Index2": text.toString()})+'\n');
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* custom_log() 输出日志到CUSTOM_Index索引,联合索引输出
|
|
20
|
+
* @param {object} ctx - 上下文对象
|
|
21
|
+
* @param {string} rest[0] - 日志索引CUSTOM_Index1
|
|
22
|
+
* @param {string} rest[1] - 日志索引CUSTOM_Index2
|
|
23
|
+
*/
|
|
24
|
+
custom_log(ctx, ...rest) {
|
|
25
|
+
//ctx校验
|
|
26
|
+
if (typeof ctx === 'object' && ctx !== null) {
|
|
27
|
+
if (!ctx.hasOwnProperty('func')) {
|
|
28
|
+
console.log('[custom_log_fail] ctx is required. Please transfer it , you can get ctx from args e.g. module.exports.yourfunc = async (data,ctx) ');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
console.log('[custom_log_fail] ctx is required. Please transfer it , you can get ctx from args e.g. module.exports.yourfunc = async (data,ctx) ');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!rest.length) {
|
|
37
|
+
console._stdout.write(JSON.stringify({"PLUGIN_Handler": ctx.func})+'\n');
|
|
38
|
+
} else if (rest.length === 1) {
|
|
39
|
+
console._stdout.write(JSON.stringify({"PLUGIN_Handler": ctx.func, "CUSTOM_Index1": rest[0].toString()})+'\n');
|
|
40
|
+
// 在这里添加你的逻辑控制
|
|
41
|
+
} else if (rest.length >= 2) {
|
|
42
|
+
console._stdout.write(JSON.stringify({"PLUGIN_Handler": ctx.func, "CUSTOM_Index1": rest[0].toString(),"CUSTOM_Index2": rest[1].toString()})+'\n');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
17
45
|
|
|
18
46
|
};
|