优化请求,修复加载bug

This commit is contained in:
lyswhut
2019-08-29 13:41:44 +08:00
parent aa973ea984
commit 1786376a9e
16 changed files with 48 additions and 27 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'
const api_messoer = {
getMusicUrl(songInfo, type) {
+1 -1
View File
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'
const api_messoer = {
getMusicUrl(songInfo, type) {
+3 -9
View File
@@ -1,24 +1,18 @@
import { httpFatch } from '../../request'
import { headers, timeout } from '../options'
const api_temp = {
getMusicUrl(songInfo, type) {
const requestObj = httpFatch(`http://45.32.53.128:3002/m/kw/u/${songInfo.songmid}/${type}`, {
method: 'get',
headers,
timeout,
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 0 ? Promise.resolve({ type, url: body.data }) : Promise.reject(new Error(body.msg))
})
return requestObj
},
getPic(songInfo) {
const requestObj = httpFatch(`http://45.32.53.128:3002/m/kw/i/${songInfo.songmid}`, {
method: 'get',
})
requestObj.promise = requestObj.promise.then(({ body }) => {
return body.code === 0 ? Promise.resolve(body.data) : Promise.reject(new Error(body.msg))
})
return requestObj
},
}
export default api_temp
+2 -1
View File
@@ -4,6 +4,7 @@ import musicSearch from './musicSearch'
import { formatSinger } from './util'
import leaderboard from './leaderboard'
import lyric from './lyric'
import pic from './pic'
import api_source from '../api-source'
const kw = {
@@ -91,7 +92,7 @@ const kw = {
},
getPic(songInfo) {
return api_source('kw').getPic(songInfo)
return pic.getPic(songInfo)
},
}
+9
View File
@@ -0,0 +1,9 @@
import { httpFatch } 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}`)
requestObj.promise = requestObj.promise.then(({ body }) => body)
return requestObj
},
}
@@ -6,4 +6,4 @@ export const headers = {
}
export const timeout = 10000
export const timeout = 15000
+1 -1
View File
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'
const api_messoer = {
getMusicUrl(songInfo, type) {
+1 -1
View File
@@ -1,6 +1,6 @@
import { httpFatch } from '../../request'
import { requestMsg } from '../../message'
import { headers, timeout } from '../messoer'
import { headers, timeout } from '../options'
const api_messoer = {
getMusicUrl(songInfo, type) {
+1 -1
View File
@@ -2,7 +2,7 @@ import request from 'request'
// import progress from 'request-progress'
import { debugRequest } from './env'
import { requestMsg } from './message'
import { bHh } from './music/messoer'
import { bHh } from './music/options'
// import fs from 'fs'
const headers = {