mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-13 02:52:08 +08:00
24 lines
750 B
JavaScript
24 lines
750 B
JavaScript
import { httpFetch } from '../../request'
|
|
import { requestMsg } from '../../message'
|
|
import { headers, timeout } from '../options'
|
|
|
|
const api_ikun = {
|
|
getMusicUrl(songInfo, type) {
|
|
const requestObj = httpFetch(`http://110.42.41.81:1314/url/kw/${songInfo.songmid}/${type}`, {
|
|
method: 'get',
|
|
timeout,
|
|
headers,
|
|
family: 4,
|
|
})
|
|
requestObj.promise = requestObj.promise.then(({ statusCode, body }) => {
|
|
if (statusCode == 429) return Promise.reject(new Error(requestMsg.tooManyRequests))
|
|
switch (body.code) {
|
|
case 0: return Promise.resolve({ type, url: body.data })
|
|
default: return Promise.reject(new Error(requestMsg.fail))
|
|
}
|
|
})
|
|
return requestObj
|
|
},
|
|
}
|
|
|
|
export default api_ikun |