修正fetch单词的拼写错误
parent
58e61e0bda
commit
bebf1906a2
|
@ -1,13 +0,0 @@
|
|||
### 新增
|
||||
|
||||
- 新增音乐**聚合搜索**,目前支持酷我、酷狗、百度源搜索
|
||||
- 新增代理功能
|
||||
|
||||
### 优化
|
||||
|
||||
- 优化从《梦里嫦娥》皮肤切换到其他皮肤时侧栏动画的切换效果
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复试听列表没有歌曲时会显示列表加载中的Bug
|
||||
- 修复切换歌单列表详情时的UI Bug
|
|
@ -7,7 +7,7 @@ const tasks = []
|
|||
mainOn('request', (event, options) => {
|
||||
// console.log(args)
|
||||
if (!options) return
|
||||
let index = fatchData(options, (err, resp) => {
|
||||
let index = fetchData(options, (err, resp) => {
|
||||
tasks[index] = null
|
||||
if (err) {
|
||||
console.log(err)
|
||||
|
@ -27,7 +27,7 @@ mainOn('cancelRequest', (event, index) => {
|
|||
tasks[index] = null
|
||||
})
|
||||
|
||||
const fatchData = (options, callback) => pushTask(tasks, request(options.url, {
|
||||
const fetchData = (options, callback) => pushTask(tasks, request(options.url, {
|
||||
method: options.method,
|
||||
headers: options.headers,
|
||||
Origin: options.origin,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_test = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/url/bd/${songInfo.songmid}/${type}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/url/bd/${songInfo.songmid}/${type}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
|
|
@ -2,7 +2,7 @@ import leaderboard from './leaderboard'
|
|||
import api_source from '../api-source'
|
||||
import musicInfo from './musicInfo'
|
||||
import songList from './songList'
|
||||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import musicSearch from './musicSearch'
|
||||
|
||||
const bd = {
|
||||
|
@ -19,7 +19,7 @@ const bd = {
|
|||
},
|
||||
getLyric(songInfo) {
|
||||
const requestObj = this.getMusicInfo(songInfo)
|
||||
requestObj.promise = requestObj.promise.then(info => httpFatch(info.lrclink).promise.then(resp => resp.body))
|
||||
requestObj.promise = requestObj.promise.then(info => httpFetch(info.lrclink).promise.then(resp => resp.body))
|
||||
return requestObj
|
||||
},
|
||||
// getLyric(songInfo) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
// import { formatPlayTime } from '../../index'
|
||||
// import jshtmlencode from 'js-htmlencode'
|
||||
|
||||
|
@ -66,7 +66,7 @@ export default {
|
|||
requestObj: null,
|
||||
getData(url) {
|
||||
if (this.requestObj) this.requestObj.cancelHttp()
|
||||
this.requestObj = httpFatch(url)
|
||||
this.requestObj = httpFetch(url)
|
||||
return this.requestObj.promise
|
||||
},
|
||||
filterData(rawList) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
|
||||
export default {
|
||||
cache: {},
|
||||
|
@ -6,7 +6,7 @@ export default {
|
|||
if (this.cache[songmid]) {
|
||||
return { promise: Promise.resolve(this.cache[songmid]) }
|
||||
}
|
||||
const requestObj = httpFatch(`https://musicapi.qianqian.com/v1/restserver/ting?method=baidu.ting.song.getSongLink&format=json&from=bmpc&version=1.0.0&version_d=11.1.6.0&songid=${songmid}&type=1&res=1&s_protocol=1&aac=2&project=tpass`)
|
||||
const requestObj = httpFetch(`https://musicapi.qianqian.com/v1/restserver/ting?method=baidu.ting.song.getSongLink&format=json&from=bmpc&version=1.0.0&version_d=11.1.6.0&songid=${songmid}&type=1&res=1&s_protocol=1&aac=2&project=tpass`)
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
// console.log(body)
|
||||
if (body.error_code == 22000) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// import '../../polyfill/array.find'
|
||||
// import jshtmlencode from 'js-htmlencode'
|
||||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { formatPlayTime } from '../../index'
|
||||
// import { debug } from '../../utils/env'
|
||||
// import { formatSinger } from './util'
|
||||
|
@ -13,7 +13,7 @@ export default {
|
|||
allPage: 1,
|
||||
musicSearch(str, page) {
|
||||
if (searchRequest && searchRequest.cancelHttp) searchRequest.cancelHttp()
|
||||
searchRequest = httpFatch(`http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=5.6.5.6&method=baidu.ting.search.merge&format=json&query=${encodeURIComponent(str)}&page_no=${page}&page_size=${this.limit}&type=0&data_source=0&use_cluster=1`)
|
||||
searchRequest = httpFetch(`http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=5.6.5.6&method=baidu.ting.search.merge&format=json&query=${encodeURIComponent(str)}&page_no=${page}&page_size=${this.limit}&type=0&data_source=0&use_cluster=1`)
|
||||
return searchRequest.promise.then(({ body }) => body)
|
||||
},
|
||||
handleResult(rawData) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { formatPlayTime, toMD5 } from '../../index'
|
||||
import CryptoJS from 'crypto-js'
|
||||
|
||||
|
@ -110,7 +110,7 @@ export default {
|
|||
// 获取标签
|
||||
getTags() {
|
||||
if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
|
||||
this._requestObj_tags = httpFatch(this.getTagsUrl())
|
||||
this._requestObj_tags = httpFetch(this.getTagsUrl())
|
||||
return this._requestObj_tags.promise.then(({ body }) => {
|
||||
if (body.error_code !== this.successCode) return this.getTags()
|
||||
return {
|
||||
|
@ -143,7 +143,7 @@ export default {
|
|||
// 获取列表数据
|
||||
getList(sortId, tagId, page) {
|
||||
if (this._requestObj_list) this._requestObj_list.cancelHttp()
|
||||
this._requestObj_list = httpFatch(
|
||||
this._requestObj_list = httpFetch(
|
||||
this.getListUrl(sortId, tagId, page)
|
||||
)
|
||||
return this._requestObj_list.promise.then(({ body }) => {
|
||||
|
@ -187,7 +187,7 @@ export default {
|
|||
if (this._requestObj_listDetail) {
|
||||
this._requestObj_listDetail.cancelHttp()
|
||||
}
|
||||
this._requestObj_listDetail = httpFatch(this.getListDetailUrl(id, page))
|
||||
this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page))
|
||||
return this._requestObj_listDetail.promise.then(({ body }) => {
|
||||
if (body.error_code !== this.successCode) return this.getListDetail(id, page)
|
||||
let listData = this.filterData(body.result.songlist)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_test = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/url/kg/${songInfo._types[type].hash}/${type}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/url/kg/${songInfo._types[type].hash}/${type}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
@ -15,7 +15,7 @@ const api_test = {
|
|||
return requestObj
|
||||
},
|
||||
getPic(songInfo) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/pic/kg/${songInfo.hash}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/pic/kg/${songInfo.hash}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
@ -26,7 +26,7 @@ const api_test = {
|
|||
return requestObj
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/lrc/kg/${songInfo.hash}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/lrc/kg/${songInfo.hash}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// import '../../polyfill/array.find'
|
||||
// import jshtmlencode from 'js-htmlencode'
|
||||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { formatPlayTime, sizeFormate } from '../../index'
|
||||
// import { debug } from '../../utils/env'
|
||||
// import { formatSinger } from './util'
|
||||
|
@ -13,7 +13,7 @@ export default {
|
|||
allPage: 1,
|
||||
musicSearch(str, page) {
|
||||
if (searchRequest && searchRequest.cancelHttp) searchRequest.cancelHttp()
|
||||
searchRequest = httpFatch(`http://ioscdn.kugou.com/api/v3/search/song?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${this.limit}&showtype=10&plat=2&version=7910&tag=1&correct=1&privilege=1&sver=5`)
|
||||
searchRequest = httpFetch(`http://ioscdn.kugou.com/api/v3/search/song?keyword=${encodeURIComponent(str)}&page=${page}&pagesize=${this.limit}&showtype=10&plat=2&version=7910&tag=1&correct=1&privilege=1&sver=5`)
|
||||
return searchRequest.promise.then(({ body }) => body)
|
||||
},
|
||||
handleResult(rawData) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { formatPlayTime, sizeFormate } from '../../index'
|
||||
|
||||
export default {
|
||||
|
@ -89,7 +89,7 @@ export default {
|
|||
|
||||
getSongList(sortId, tagId, page) {
|
||||
if (this._requestObj_list) this._requestObj_list.cancelHttp()
|
||||
this._requestObj_list = httpFatch(
|
||||
this._requestObj_list = httpFetch(
|
||||
this.getSongListUrl(sortId, tagId, page)
|
||||
)
|
||||
return this._requestObj_list.promise.then(({ body }) => {
|
||||
|
@ -99,7 +99,7 @@ export default {
|
|||
},
|
||||
getSongListRecommend() {
|
||||
if (this._requestObj_listRecommend) this._requestObj_listRecommend.cancelHttp()
|
||||
this._requestObj_listRecommend = httpFatch(
|
||||
this._requestObj_listRecommend = httpFetch(
|
||||
'http://everydayrec.service.kugou.com/guess_special_recommend',
|
||||
{
|
||||
method: 'post',
|
||||
|
@ -140,7 +140,7 @@ export default {
|
|||
|
||||
getListDetail(id, page) { // 获取歌曲列表内的音乐
|
||||
if (this._requestObj_listDetail) this._requestObj_listDetail.cancelHttp()
|
||||
this._requestObj_listDetail = httpFatch(this.getSongListDetailUrl(id))
|
||||
this._requestObj_listDetail = httpFetch(this.getSongListDetailUrl(id))
|
||||
return this._requestObj_listDetail.promise.then(({ body }) => {
|
||||
let listData = body.match(this.regExps.listData)
|
||||
if (listData) listData = this.filterData(JSON.parse(RegExp.$1))
|
||||
|
@ -211,7 +211,7 @@ export default {
|
|||
// 获取列表信息
|
||||
getListInfo(tagId) {
|
||||
if (this._requestObj_listInfo) this._requestObj_listInfo.cancelHttp()
|
||||
this._requestObj_listInfo = httpFatch(this.getInfoUrl(tagId))
|
||||
this._requestObj_listInfo = httpFetch(this.getInfoUrl(tagId))
|
||||
return this._requestObj_listInfo.promise.then(({ body }) => {
|
||||
if (body.status !== 1) return this.getListInfo(tagId)
|
||||
return {
|
||||
|
@ -248,7 +248,7 @@ export default {
|
|||
// 获取标签
|
||||
getTags() {
|
||||
if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
|
||||
this._requestObj_tags = httpFatch(this.getInfoUrl())
|
||||
this._requestObj_tags = httpFetch(this.getInfoUrl())
|
||||
return this._requestObj_tags.promise.then(({ body }) => {
|
||||
if (body.status !== 1) return this.getTags()
|
||||
return {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_temp = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`http://tm.tempmusic.tk/url/kw/${songInfo.songmid}/${type}`, {
|
||||
const requestObj = httpFetch(`http://tm.tempmusic.tk/url/kw/${songInfo.songmid}/${type}`, {
|
||||
method: 'get',
|
||||
headers,
|
||||
timeout,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_test = {
|
||||
// getMusicUrl(songInfo, type) {
|
||||
// const requestObj = httpFatch(`http://45.32.53.128:3002/m/kw/u/${songInfo.songmid}/${type}`, {
|
||||
// const requestObj = httpFetch(`http://45.32.53.128:3002/m/kw/u/${songInfo.songmid}/${type}`, {
|
||||
// method: 'get',
|
||||
// headers,
|
||||
// timeout,
|
||||
|
@ -15,7 +15,7 @@ const api_test = {
|
|||
// return requestObj
|
||||
// },
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/url/kw/${songInfo.songmid}/${type}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/url/kw/${songInfo.songmid}/${type}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
|
||||
export default {
|
||||
formatTime(time) {
|
||||
|
@ -10,7 +10,7 @@ export default {
|
|||
return `[ti:${songinfo.songName}]\n[ar:${songinfo.artist}]\n[al:${songinfo.album}]\n[by:]\n[offset:0]\n${lrclist ? lrclist.map(l => `[${this.formatTime(l.time)}]${l.lineLyric}\n`).join('') : '暂无歌词'}`
|
||||
},
|
||||
getLyric(songId) {
|
||||
const requestObj = httpFatch(`http://m.kuwo.cn/newh5/singles/songinfoandlrc?musicId=${songId}`)
|
||||
const requestObj = httpFetch(`http://m.kuwo.cn/newh5/singles/songinfoandlrc?musicId=${songId}`)
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => {
|
||||
return this.transformLrc(body.data)
|
||||
})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
|
||||
export default {
|
||||
getPic({ songmid }) {
|
||||
const requestObj = httpFatch(`http://artistpicserver.kuwo.cn/pic.web?corp=kuwo&type=rid_pic&pictype=500&size=500&rid=${songmid}`)
|
||||
const requestObj = httpFetch(`http://artistpicserver.kuwo.cn/pic.web?corp=kuwo&type=rid_pic&pictype=500&size=500&rid=${songmid}`)
|
||||
requestObj.promise = requestObj.promise.then(({ body }) => body)
|
||||
return requestObj
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { formatPlayTime, decodeName } from '../../index'
|
||||
import { formatSinger } from './util'
|
||||
|
||||
|
@ -40,7 +40,7 @@ export default {
|
|||
// 获取标签
|
||||
getTag() {
|
||||
if (this._requestObj_tags) this._requestObj_tags.cancelHttp()
|
||||
this._requestObj_tags = httpFatch(this.tagsUrl)
|
||||
this._requestObj_tags = httpFetch(this.tagsUrl)
|
||||
return this._requestObj_tags.promise.then(({ body }) => {
|
||||
if (body.code !== this.successCode) return this.getTag()
|
||||
return this.filterTagInfo(body.data)
|
||||
|
@ -49,7 +49,7 @@ export default {
|
|||
// 获取标签
|
||||
getHotTag() {
|
||||
if (this._requestObj_hotTags) this._requestObj_hotTags.cancelHttp()
|
||||
this._requestObj_hotTags = httpFatch(this.hotTagUrl)
|
||||
this._requestObj_hotTags = httpFetch(this.hotTagUrl)
|
||||
return this._requestObj_hotTags.promise.then(({ body }) => {
|
||||
if (body.code !== this.successCode) return this.getHotTag()
|
||||
return this.filterInfoHotTag(body.data[0].data)
|
||||
|
@ -87,7 +87,7 @@ export default {
|
|||
} else {
|
||||
id = null
|
||||
}
|
||||
this._requestObj_list = httpFatch(this.getListUrl({ sortId, id, type, page }))
|
||||
this._requestObj_list = httpFetch(this.getListUrl({ sortId, id, type, page }))
|
||||
return this._requestObj_list.promise.then(({ body }) => {
|
||||
if (!id || type == '10000') {
|
||||
if (body.code !== this.successCode) return this.getListUrl({ sortId, id, type, page })
|
||||
|
@ -157,7 +157,7 @@ export default {
|
|||
if (this._requestObj_listDetail) {
|
||||
this._requestObj_listDetail.cancelHttp()
|
||||
}
|
||||
this._requestObj_listDetail = httpFatch(this.getListDetailUrl(id, page))
|
||||
this._requestObj_listDetail = httpFetch(this.getListDetailUrl(id, page))
|
||||
return this._requestObj_listDetail.promise.then(({ body }) => {
|
||||
if (body.result !== 'ok') return this.getListDetail(id, page)
|
||||
return {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../messoer'
|
||||
|
||||
const api_messoer = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`https://v1.itooi.cn/tencent/url?id=${songInfo.strMediaMid}&quality=${type.replace(/k$/, '')}`, {
|
||||
const requestObj = httpFetch(`https://v1.itooi.cn/tencent/url?id=${songInfo.strMediaMid}&quality=${type.replace(/k$/, '')}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { b64DecodeUnicode } from '../../index'
|
||||
|
||||
export default {
|
||||
|
@ -6,7 +6,7 @@ export default {
|
|||
matchLrc: /.+"lyric":"([\w=+/]*)".+/,
|
||||
},
|
||||
getLyric(songmid) {
|
||||
const requestObj = httpFatch(`https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?songmid=${songmid}&g_tk=2001461048&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8&platform=yqq`, {
|
||||
const requestObj = httpFetch(`https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?songmid=${songmid}&g_tk=2001461048&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8&platform=yqq`, {
|
||||
headers: {
|
||||
Referer: 'https://y.qq.com/portal/player.html',
|
||||
},
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { httpFatch } from '../../request'
|
||||
import { httpFetch } from '../../request'
|
||||
import { requestMsg } from '../../message'
|
||||
import { headers, timeout } from '../options'
|
||||
|
||||
const api_test = {
|
||||
getMusicUrl(songInfo, type) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/url/wy/${songInfo.songmid}/${type}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/url/wy/${songInfo.songmid}/${type}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
@ -15,7 +15,7 @@ const api_test = {
|
|||
return requestObj
|
||||
},
|
||||
getPic(songInfo) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/pic/wy/${songInfo.songmid}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/pic/wy/${songInfo.songmid}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
@ -26,7 +26,7 @@ const api_test = {
|
|||
return requestObj
|
||||
},
|
||||
getLyric(songInfo) {
|
||||
const requestObj = httpFatch(`http://ts.tempmusic.tk/lrc/wy/${songInfo.songmid}`, {
|
||||
const requestObj = httpFetch(`http://ts.tempmusic.tk/lrc/wy/${songInfo.songmid}`, {
|
||||
method: 'get',
|
||||
timeout,
|
||||
headers,
|
||||
|
|
|
@ -22,7 +22,7 @@ const buildHttpPromose = (url, options) => {
|
|||
const p = new Promise((resolve, reject) => {
|
||||
cancelFn = reject
|
||||
debugRequest && console.log(`\n---send request------${url}------------`)
|
||||
requestObj = fatchData(url, options.method, options, (err, resp, body) => {
|
||||
requestObj = fetchData(url, options.method, options, (err, resp, body) => {
|
||||
// options.isShowProgress && window.api.hideProgress()
|
||||
debugRequest && console.log(`\n---response------${url}------------`)
|
||||
debugRequest && console.log(JSON.stringify(body))
|
||||
|
@ -31,7 +31,7 @@ const buildHttpPromose = (url, options) => {
|
|||
if (err) {
|
||||
console.log(err.code)
|
||||
if (err.code === 'ETIMEDOUT' || err.code == 'ESOCKETTIMEDOUT') {
|
||||
const { promise, cancelHttp } = httpFatch(url, options)
|
||||
const { promise, cancelHttp } = httpFetch(url, options)
|
||||
obj.cancelHttp = cancelHttp
|
||||
promise.then()
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ const buildHttpPromose = (url, options) => {
|
|||
* @param {*} url
|
||||
* @param {*} options
|
||||
*/
|
||||
export const httpFatch = (url, options = { method: 'get' }) => {
|
||||
export const httpFetch = (url, options = { method: 'get' }) => {
|
||||
const requestObj = buildHttpPromose(url, options)
|
||||
requestObj.promise = requestObj.promise.catch(err => {
|
||||
if (err.code === 'ETIMEDOUT' || err.code == 'ESOCKETTIMEDOUT') {
|
||||
const { promise, cancelHttp } = httpFatch(url, options)
|
||||
const { promise, cancelHttp } = httpFetch(url, options)
|
||||
requestObj.cancelHttp()
|
||||
requestObj.cancelHttp = cancelHttp
|
||||
return promise
|
||||
|
@ -106,7 +106,7 @@ export const http = (url, options, cb) => {
|
|||
if (options.method == null) options.method = 'get'
|
||||
|
||||
debugRequest && console.log(`\n---send request------${url}------------`)
|
||||
return fatchData(url, options.method, options, (err, resp, body) => {
|
||||
return fetchData(url, options.method, options, (err, resp, body) => {
|
||||
// options.isShowProgress && window.api.hideProgress()
|
||||
debugRequest && console.log(`\n---response------${url}------------`)
|
||||
debugRequest && console.log(JSON.stringify(body))
|
||||
|
@ -135,7 +135,7 @@ export const httpGet = (url, options, callback) => {
|
|||
// })
|
||||
|
||||
debugRequest && console.log(`\n---send request-------${url}------------`)
|
||||
return fatchData(url, 'get', options, function(err, resp, body) {
|
||||
return fetchData(url, 'get', options, function(err, resp, body) {
|
||||
// options.isShowProgress && window.api.hideProgress()
|
||||
debugRequest && console.log(`\n---response------${url}------------`)
|
||||
debugRequest && console.log(JSON.stringify(body))
|
||||
|
@ -166,7 +166,7 @@ export const httpPost = (url, data, options, callback) => {
|
|||
options.data = data
|
||||
|
||||
debugRequest && console.log(`\n---send request-------${url}------------`)
|
||||
return fatchData(url, 'post', options, function(err, resp, body) {
|
||||
return fetchData(url, 'post', options, function(err, resp, body) {
|
||||
// options.isShowProgress && window.api.hideProgress()
|
||||
debugRequest && console.log(`\n---response------${url}------------`)
|
||||
debugRequest && console.log(JSON.stringify(body))
|
||||
|
@ -203,7 +203,7 @@ export const http_jsonp = (url, options, callback) => {
|
|||
// })
|
||||
|
||||
debugRequest && console.log(`\n---send request-------${url}------------`)
|
||||
return fatchData(url, 'get', options, function(err, resp, body) {
|
||||
return fetchData(url, 'get', options, function(err, resp, body) {
|
||||
// options.isShowProgress && window.api.hideProgress()
|
||||
debugRequest && console.log(`\n---response------${url}------------`)
|
||||
debugRequest && console.log(JSON.stringify(body))
|
||||
|
@ -221,7 +221,7 @@ const getProxyInfo = () => window.globalObj.proxy.enable
|
|||
? `http://${window.globalObj.proxy.username}:${window.globalObj.proxy.password}@${window.globalObj.proxy.host}:${window.globalObj.proxy.port};`
|
||||
: undefined
|
||||
|
||||
const fatchData = (url, method, options, callback) => {
|
||||
const fetchData = (url, method, options, callback) => {
|
||||
// console.log(url, options)
|
||||
console.log('---start---', url)
|
||||
if (options.headers && options.headers[bHh]) {
|
||||
|
|
Loading…
Reference in New Issue