1 parent
7805931355
commit
3798e1d1d8
5 files changed
+351
-97
No files matched your search
+5
-6
@@ -1,7 +1,6 @@
|
||||
let wpsInstance = null;
|
||||
|
||||
|
||||
|
||||
function InvokeFromXbot(param) {
|
||||
// 1. 解析参数, 如果不是字符串, 则转换为字符串, 并用json解析, 解析失败直接retrun
|
||||
if (typeof param !== 'string') {
|
||||
@@ -27,7 +26,7 @@ function InvokeFromXbot(param) {
|
||||
args = JSON.parse(param.args);
|
||||
} catch (e) {
|
||||
args = {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log("method:", method);
|
||||
@@ -47,19 +46,19 @@ function InvokeFromXbot(param) {
|
||||
|
||||
// 5. 判断是否有 wpsInstance, 如果没有直接return
|
||||
if (!wpsInstance) {
|
||||
return {msg: '未注入', code: -3};
|
||||
return { msg: '未注入', code: -3 };
|
||||
}
|
||||
|
||||
// 6. 判断 wpsInstance 是否有 method 方法, 如果没有直接return
|
||||
if (!wpsInstance[method]) {
|
||||
return {msg: '方法不存在', code: -4};
|
||||
return { msg: '方法不存在', code: -4 };
|
||||
}
|
||||
|
||||
// 7. 执行 wpsInstance 的 method 方法, 并返回结果
|
||||
try {
|
||||
const result = wpsInstance[method](args ?? null);
|
||||
return {msg: '执行成功', code: 0, data: result};
|
||||
return { msg: '执行成功', code: 0, data: result };
|
||||
} catch (e) {
|
||||
return {msg: '执行失败', code: -5};
|
||||
return { msg: '执行失败', code: -5 };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user