chore: 用esbuild代替vite来打包main

This commit is contained in:
qier222 2022-03-29 16:52:53 +08:00
parent b4590c3c34
commit c4219afd3d
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
152 changed files with 669 additions and 747 deletions

View file

@ -0,0 +1,39 @@
import { fetchPlaylist } from '@/api/playlist'
import { PlaylistApiNames } from '@/api/playlist'
import type { FetchPlaylistParams, FetchPlaylistResponse } from '@/api/playlist'
import reactQueryClient from '@/utils/reactQueryClient'
const fetch = (params: FetchPlaylistParams, noCache?: boolean) => {
return fetchPlaylist(params, !!noCache)
}
export default function usePlaylist(
params: FetchPlaylistParams,
noCache?: boolean
) {
return useQuery(
[PlaylistApiNames.FETCH_PLAYLIST, params],
() => fetch(params, noCache),
{
enabled: !!(params.id && params.id > 0 && !isNaN(Number(params.id))),
refetchOnWindowFocus: true,
// placeholderData: (): FetchPlaylistResponse | undefined =>
// window.ipcRenderer.sendSync('getApiCacheSync', {
// api: 'playlist/detail',
// query: {
// id: params.id,
// },
// }),
}
)
}
export async function prefetchPlaylist(params: FetchPlaylistParams) {
await reactQueryClient.prefetchQuery(
[PlaylistApiNames.FETCH_PLAYLIST, params],
() => fetch(params),
{
staleTime: 3600000,
}
)
}