mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 21:58:03 +00:00
feat: updates
This commit is contained in:
parent
9a52681687
commit
840a5b8e9b
104 changed files with 1645 additions and 13494 deletions
|
|
@ -65,7 +65,7 @@ export function fetchAudioSourceWithReactQuery(params: FetchAudioSourceParams) {
|
|||
return fetchAudioSource(params)
|
||||
},
|
||||
{
|
||||
retry: 3,
|
||||
retry: 1,
|
||||
staleTime: 0, // TODO: Web版1小时缓存
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { UserApiNames, FetchUserAccountResponse } from '@/shared/api/User'
|
|||
import { CacheAPIs } from '@/shared/CacheAPIs'
|
||||
import { IpcChannels } from '@/shared/IpcChannels'
|
||||
import { useMutation, useQuery } from '@tanstack/react-query'
|
||||
import { logout } from '../auth'
|
||||
import { logout as logoutAPI } from '../auth'
|
||||
import { removeAllCookies } from '@/web/utils/cookie'
|
||||
import reactQueryClient from '@/web/utils/reactQueryClient'
|
||||
|
||||
|
|
@ -31,12 +31,19 @@ export default function useUser() {
|
|||
)
|
||||
}
|
||||
|
||||
export const useMutationLogout = () => {
|
||||
const { refetch } = useUser()
|
||||
return useMutation(async () => {
|
||||
await logout()
|
||||
removeAllCookies()
|
||||
await window.ipcRenderer?.invoke(IpcChannels.Logout)
|
||||
await refetch()
|
||||
})
|
||||
export const useIsLoggedIn = () => {
|
||||
const { data, isLoading } = useUser()
|
||||
if (isLoading) return true
|
||||
return !!data?.profile?.userId
|
||||
}
|
||||
|
||||
export const logout = async () => {
|
||||
await logoutAPI()
|
||||
removeAllCookies()
|
||||
await window.ipcRenderer?.invoke(IpcChannels.Logout)
|
||||
await reactQueryClient.refetchQueries([UserApiNames.FetchUserAccount])
|
||||
}
|
||||
|
||||
export const useMutationLogout = () => {
|
||||
return useMutation(logout)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue