2022-05-12 02:45:43 +08:00
|
|
|
import request from '@/web/utils/request'
|
2022-04-16 21:14:03 +08:00
|
|
|
import {
|
|
|
|
FetchPlaylistParams,
|
|
|
|
FetchPlaylistResponse,
|
|
|
|
FetchRecommendedPlaylistsParams,
|
|
|
|
FetchRecommendedPlaylistsResponse,
|
|
|
|
FetchDailyRecommendPlaylistsResponse,
|
|
|
|
LikeAPlaylistParams,
|
|
|
|
LikeAPlaylistResponse,
|
|
|
|
} from '@/shared/api/Playlists'
|
2022-03-13 14:40:38 +08:00
|
|
|
|
|
|
|
// 歌单详情
|
|
|
|
export function fetchPlaylist(
|
|
|
|
params: FetchPlaylistParams,
|
|
|
|
noCache: boolean
|
|
|
|
): Promise<FetchPlaylistResponse> {
|
|
|
|
const otherParams: { timestamp?: number } = {}
|
|
|
|
if (noCache) otherParams.timestamp = new Date().getTime()
|
|
|
|
if (!params.s) params.s = 0 // 网易云默认返回8个收藏者,这里设置为0,减少返回的JSON体积
|
|
|
|
return request({
|
|
|
|
url: '/playlist/detail',
|
|
|
|
method: 'get',
|
|
|
|
params: {
|
|
|
|
...params,
|
|
|
|
...otherParams,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 推荐歌单
|
|
|
|
export function fetchRecommendedPlaylists(
|
|
|
|
params: FetchRecommendedPlaylistsParams
|
|
|
|
): Promise<FetchRecommendedPlaylistsResponse> {
|
|
|
|
return request({
|
|
|
|
url: '/personalized',
|
|
|
|
method: 'get',
|
|
|
|
params,
|
|
|
|
})
|
|
|
|
}
|
2022-03-21 02:03:25 +08:00
|
|
|
|
|
|
|
// 每日推荐歌单(需要登录)
|
|
|
|
export function fetchDailyRecommendPlaylists(): Promise<FetchDailyRecommendPlaylistsResponse> {
|
|
|
|
return request({
|
|
|
|
url: '/recommend/resource',
|
|
|
|
method: 'get',
|
2022-04-30 02:08:25 +08:00
|
|
|
params: {
|
|
|
|
timestamp: Date.now(),
|
|
|
|
},
|
2022-03-21 02:03:25 +08:00
|
|
|
})
|
|
|
|
}
|
2022-04-05 21:23:55 +08:00
|
|
|
|
|
|
|
export function likeAPlaylist(
|
|
|
|
params: LikeAPlaylistParams
|
|
|
|
): Promise<LikeAPlaylistResponse> {
|
|
|
|
return request({
|
|
|
|
url: '/playlist/subscribe',
|
|
|
|
method: 'post',
|
|
|
|
params: {
|
|
|
|
...params,
|
|
|
|
timestamp: Date.now(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|