mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-21 22:48:13 +00:00
调整enka的请求参数,优化请求错误时的日志记录
This commit is contained in:
parent
2ab90de918
commit
4654d99f7a
@ -9,7 +9,9 @@ export default new ProfileServ({
|
||||
|
||||
// 处理请求参数
|
||||
async request (api) {
|
||||
let params = { headers: { 'User-Agent': this.getCfg('userAgent') } }
|
||||
let params = {
|
||||
headers: { 'User-Agent': this.getCfg('userAgent') }
|
||||
}
|
||||
let proxy = this.getCfg('proxyAgent')
|
||||
if (proxy) {
|
||||
let { HttpsProxyAgent } = await Data.import('https-proxy-agent')
|
||||
@ -21,6 +23,9 @@ export default new ProfileServ({
|
||||
// 处理服务返回
|
||||
async response (data, req) {
|
||||
if (!data.playerInfo) {
|
||||
if(data.error) {
|
||||
console.log(`Enka ReqErr: ${data.error}`)
|
||||
}
|
||||
return req.err('error', 60)
|
||||
}
|
||||
let details = data.avatarInfoList
|
||||
|
@ -66,9 +66,19 @@ export default class ProfileReq extends Base {
|
||||
let data = {}
|
||||
try {
|
||||
let params = reqParam.params || {}
|
||||
params.timeout = params.timeout || 1000 * 10
|
||||
params.timeout = params.timeout || 1000 * 20
|
||||
let req = await fetch(reqParam.url, params)
|
||||
data = await req.json()
|
||||
data = await req.text()
|
||||
if(data[0] === '<'){
|
||||
let titleRet = /<title>(.+)<\/title>/.exec(data)
|
||||
if(titleRet && titleRet[1]) {
|
||||
data = { error: titleRet[1] }
|
||||
} else {
|
||||
return this.err('error', 60)
|
||||
}
|
||||
} else {
|
||||
data = JSON.parse(data)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('面板请求错误', e)
|
||||
data = {}
|
||||
|
@ -49,7 +49,7 @@ export default class ProfileServ extends Base {
|
||||
|
||||
return {
|
||||
url: param.api || api,
|
||||
param: param.config || {}
|
||||
params: param.params || {}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user