feat: updates

This commit is contained in:
qier222 2022-07-12 22:42:50 +08:00
parent 222fb02355
commit 47e41dea9b
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
24 changed files with 380 additions and 130 deletions

View file

@ -1,4 +1,3 @@
import { IpcChannels } from '@/shared/IpcChannels'
import axios from 'axios'
import { useQuery } from 'react-query'
@ -6,25 +5,14 @@ export default function useVideoCover(props: {
id?: number
name?: string
artist?: string
enabled?: boolean
}) {
const { id, name, artist } = props
const { id, name, artist, enabled = true } = props
return useQuery(
['useVideoCover', props],
async () => {
if (!id || !name || !artist) return
const fromMainProcess = await window.ipcRenderer?.invoke(
IpcChannels.GetVideoCover,
{
id,
name,
artist,
}
)
if (fromMainProcess) {
return fromMainProcess
}
const fromRemote = await axios.get('/yesplaymusic/video-cover', {
params: props,
})
@ -33,7 +21,7 @@ export default function useVideoCover(props: {
}
},
{
enabled: !!id && !!name && !!artist,
enabled: !!id && !!name && !!artist && enabled,
refetchOnWindowFocus: false,
refetchInterval: false,
}