feat: 增加歌手页面

This commit is contained in:
qier222 2022-03-23 01:21:22 +08:00
parent 7d20e6c5de
commit 36603dc3a0
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
16 changed files with 247 additions and 28 deletions

View file

@ -1,14 +1,24 @@
import { fetchArtist } from '@/api/artist'
import { ArtistApiNames } from '@/api/artist'
import type { FetchArtistParams } from '@/api/artist'
import type { FetchArtistParams, FetchArtistResponse } from '@/api/artist'
export default function useArtist(params: FetchArtistParams, noCache: boolean) {
export default function useArtist(
params: FetchArtistParams,
noCache?: boolean
) {
return useQuery(
[ArtistApiNames.FETCH_ARTIST, params],
() => fetchArtist(params, noCache),
() => fetchArtist(params, !!noCache),
{
enabled: !!params.id && params.id > 0 && !isNaN(Number(params.id)),
staleTime: 3600000,
staleTime: 5 * 60 * 1000, // 5 mins
placeholderData: (): FetchArtistResponse =>
window.ipcRenderer.sendSync('getApiCacheSync', {
api: 'artists',
query: {
id: params.id,
},
}),
}
)
}