From 02505b72d41fd08485f3e1c8f1ed8d043ab91be8 Mon Sep 17 00:00:00 2001 From: overwriter <9856mmm@gmail.com> Date: Sat, 13 Jul 2024 17:35:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20e=5Fr=E5=9C=A8=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E5=89=8D=E6=8F=92=E5=85=A5data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/option.js | 1 + util/request.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/util/option.js b/util/option.js index 3768ead..ae0bd2e 100644 --- a/util/option.js +++ b/util/option.js @@ -5,6 +5,7 @@ const createOption = (query, crypto = '') => { ua: query.ua || '', proxy: query.proxy, realIP: query.realIP, + e_r: query.e_r || undefined, } } module.exports = createOption diff --git a/util/request.js b/util/request.js index 319b04c..db13a3a 100644 --- a/util/request.js +++ b/util/request.js @@ -143,9 +143,14 @@ const createRequest = (method, uri, data = {}, options) => { let eapi = () => { // 使用eapi加密 data.header = header + data.e_r = + options.e_r != undefined + ? options.e_r + : data.e_r != undefined + ? data.e_r + : APP_CONF.encryptResponse // 用于加密接口返回值 encryptData = encrypt.eapi(uri, data) url = APP_CONF.apiDomain + '/eapi/' + uri.substr(5) - data.e_r = data.e_r != undefined ? data.e_r : APP_CONF.encryptResponse // 用于加密接口返回值 } let api = () => { // 不使用任何加密 @@ -232,7 +237,8 @@ const createRequest = (method, uri, data = {}, options) => { body.toString('hex').toUpperCase(), ) } else { - answer.body = JSON.parse(body.toString()) + answer.body = + typeof body == 'object' ? body : JSON.parse(body.toString()) } if (answer.body.code) {