From 8817318a53121f824b9b232ec60092e7e03977c8 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sun, 18 Aug 2019 22:48:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86http=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/utils/request.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/renderer/utils/request.js b/src/renderer/utils/request.js index c22d29d6..40214d00 100644 --- a/src/renderer/utils/request.js +++ b/src/renderer/utils/request.js @@ -8,7 +8,7 @@ const headers = { } const fatchData = (url, method, options, callback) => { - console.log(url, options) + // console.log(url, options) // console.log('---start---', url) return request(url, { method, @@ -18,10 +18,7 @@ const fatchData = (url, method, options, callback) => { timeout: options.timeout || 10000, json: options.format === undefined || options.format === 'json', }, (err, resp, body) => { - if (err) { - if (err.message === 'socket hang up') window.globalObj.apiSource = 'temp' - return callback(err, null) - } + if (err) return callback(err, null) // console.log('---end---', url) callback(null, resp, body) @@ -85,7 +82,10 @@ export const httpFatch = (url, options = { method: 'get' }) => { requestObj.cancelHttp = cancelHttp return promise } - if (err.message === 'socket hang up') return Promise.reject(new Error('哦No😱...接口挂了!已帮你切换到临时接口,重试下看能不能播放吧~')) + if (err.message === 'socket hang up') { + window.globalObj.apiSource = 'temp' + return Promise.reject(new Error('哦No😱...接口无法访问了!已帮你切换到临时接口,重试下看能不能播放吧~')) + } if (err.code === 'ENOTFOUND') return Promise.reject(new Error('无法连接网络')) return Promise.reject(err) })