fix(qdreader): parse wrapped Autman response data
This commit is contained in:
+24
-11
@@ -4,7 +4,7 @@
|
||||
//[author: Hermes]
|
||||
//[service: BOSS]
|
||||
//[class: 工具类]
|
||||
// [version: 2.15.4]
|
||||
// [version: 2.15.5]
|
||||
// [platform: web,qq,wx,tg,tb,fs,we]
|
||||
// [public: false]
|
||||
// [price: 0]
|
||||
@@ -302,7 +302,7 @@ function contentText() {
|
||||
}
|
||||
function usage() {
|
||||
return [
|
||||
"启点读书签到插件 v2.15.3",
|
||||
"启点读书签到插件 v2.15.5",
|
||||
"【一级菜单】",
|
||||
"账号管理:启点账号",
|
||||
"执行查询:启点查询",
|
||||
@@ -368,11 +368,11 @@ function parseResp(res) {
|
||||
if (res === undefined || res === null) return null
|
||||
var body = null
|
||||
if (res && typeof res === "object") {
|
||||
if (res.body !== undefined) body = res.body
|
||||
else if (res.data !== undefined) body = res.data
|
||||
else if (res.content !== undefined) body = res.content
|
||||
else if (res.responseText !== undefined) body = res.responseText
|
||||
else if (res.statusCode !== undefined || res.status !== undefined || res.headers !== undefined) body = ""
|
||||
if (res.body !== undefined && res.body !== null && String(res.body) !== "") body = res.body
|
||||
else if (res.data !== undefined && res.data !== null && String(res.data) !== "") body = res.data
|
||||
else if (res.content !== undefined && res.content !== null && String(res.content) !== "") body = res.content
|
||||
else if (res.responseText !== undefined && res.responseText !== null && String(res.responseText) !== "") body = res.responseText
|
||||
else if (res.statusCode !== undefined || res.status !== undefined || res.headers !== undefined) body = res.data !== undefined ? res.data : ""
|
||||
else body = res
|
||||
} else {
|
||||
body = res
|
||||
@@ -431,6 +431,7 @@ function qidianRequest(path, method, data, cookie) {
|
||||
return out
|
||||
}
|
||||
function resultCode(obj) {
|
||||
obj = responseEnvelope(obj)
|
||||
if (!obj) return undefined
|
||||
var keys = ["Result", "result", "Code", "code", "retcode", "RetCode"]
|
||||
for (var i = 0; i < keys.length; i++) if (obj[keys[i]] !== undefined) return obj[keys[i]]
|
||||
@@ -439,13 +440,15 @@ function resultCode(obj) {
|
||||
return undefined
|
||||
}
|
||||
function resultOk(obj) {
|
||||
var code = resultCode(obj)
|
||||
var status = obj && (obj.status || obj.Status)
|
||||
var env = responseEnvelope(obj)
|
||||
var code = resultCode(env)
|
||||
var status = env && (env.status || env.Status)
|
||||
return code === undefined || code === 0 || code === "0" || code === 200 || code === "200" || status === "ok" || status === "success"
|
||||
}
|
||||
function resultMsg(obj) {
|
||||
obj = responseEnvelope(obj)
|
||||
if (!obj) return ""
|
||||
return obj.Message || obj.Msg || obj.message || obj.msg || obj.toast || (obj.data && (obj.data.message || obj.data.msg || obj.data.toast)) || (obj.Data && (obj.Data.message || obj.Data.msg || obj.Data.toast)) || ""
|
||||
return obj.Message || obj.Msg || obj.message || obj.msg || obj.toast || (obj.data && (obj.data.message || obj.data.msg || obj.data.toast || obj.data.Message || obj.data.Msg)) || (obj.Data && (obj.Data.message || obj.Data.msg || obj.Data.toast || obj.Data.Message || obj.Data.Msg)) || ""
|
||||
}
|
||||
function successLikeMsg(msg) {
|
||||
msg = String(msg || "")
|
||||
@@ -618,7 +621,17 @@ function nested(obj, path) {
|
||||
}
|
||||
return cur
|
||||
}
|
||||
function payloadData(obj) { return (obj && (obj.Data || obj.data)) || {} }
|
||||
function responseEnvelope(obj) {
|
||||
if (!obj || typeof obj !== "object") return obj
|
||||
if ((obj.statusCode !== undefined || obj.status !== undefined || obj.headers !== undefined) && obj.data && typeof obj.data === "object") return obj.data
|
||||
return obj
|
||||
}
|
||||
function payloadData(obj) {
|
||||
obj = responseEnvelope(obj)
|
||||
var data = obj && (obj.Data || obj.data || obj.ResultData || obj.resultData)
|
||||
if (data && typeof data === "object" && (data.Data || data.data || data.ResultData || data.resultData) && (data.Result !== undefined || data.result !== undefined || data.Code !== undefined || data.code !== undefined || data.Message !== undefined || data.message !== undefined)) return data.Data || data.data || data.ResultData || data.resultData
|
||||
return data || {}
|
||||
}
|
||||
function looksLikeVideoTask(task) { return isObject(task) && !!taskIdOf(task) && (task["IsFinished"] !== undefined || task["IsReceived"] !== undefined || task["Title"] !== undefined || task["TaskName"] !== undefined) }
|
||||
function taskArrayScore(list, kind) {
|
||||
if (!Array.isArray(list) || !list.length) return 0
|
||||
|
||||
Reference in New Issue
Block a user