feat: updates

This commit is contained in:
qier222 2022-08-03 23:48:39 +08:00
parent 47e41dea9b
commit ebebf2a733
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
160 changed files with 4148 additions and 2001 deletions

View file

@ -0,0 +1,31 @@
import { fetchMV, fetchMVUrl } from '@/web/api/mv'
import { IpcChannels } from '@/shared/IpcChannels'
import { APIs } from '@/shared/CacheAPIs'
import {
MVApiNames,
FetchMVParams,
FetchMVResponse,
FetchMVUrlParams,
} from '@/shared/api/MV'
import { useQuery } from '@tanstack/react-query'
export default function useMV(params: FetchMVParams) {
return useQuery([MVApiNames.FetchMV, params], () => fetchMV(params), {
enabled: !!params.mvid && params.mvid > 0 && !isNaN(Number(params.mvid)),
staleTime: 5 * 60 * 1000, // 5 mins
// placeholderData: (): FetchMVResponse =>
// window.ipcRenderer?.sendSync(IpcChannels.GetApiCacheSync, {
// api: APIs.SimilarArtist,
// query: {
// id: params.id,
// },
// }),
})
}
export function useMVUrl(params: FetchMVUrlParams) {
return useQuery([MVApiNames.FetchMVUrl, params], () => fetchMVUrl(params), {
enabled: !!params.id && params.id > 0 && !isNaN(Number(params.id)),
staleTime: 60 * 60 * 1000, // 60 mins
})
}