refactor: version 2.0 (React)

This commit is contained in:
qier222 2022-03-13 14:40:38 +08:00
parent 7dad7d810a
commit 950f72d4e8
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
356 changed files with 7901 additions and 29547 deletions

View file

@ -0,0 +1,51 @@
import request from '@/utils/request'
export enum ArtistApiNames {
FETCH_ARTIST = 'fetchArtist',
FETCH_ARTIST_ALBUMS = 'fetchArtistAlbums',
}
// 歌手详情
export interface FetchArtistParams {
id: number
}
interface FetchArtistResponse {
code: number
more: boolean
artist: Artist
hotSongs: Track[]
}
export function fetchArtist(
params: FetchArtistParams,
noCache: boolean
): Promise<FetchArtistResponse> {
const otherParams: { timestamp?: number } = {}
if (noCache) otherParams.timestamp = new Date().getTime()
return request({
url: '/artists',
method: 'get',
params: { ...params, ...otherParams },
})
}
// 获取歌手的专辑列表
export interface FetchArtistAlbumsParams {
id: number
limit?: number // default: 50
offset?: number // default: 0
}
interface FetchArtistAlbumsResponse {
code: number
hotAlbums: Album[]
more: boolean
artist: Artist
}
export function fetchArtistAlbums(
params: FetchArtistAlbumsParams
): Promise<FetchArtistAlbumsResponse> {
return request({
url: 'artist/album',
method: 'get',
params,
})
}