mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
feat: 支持收藏歌单和专辑
This commit is contained in:
parent
db5730dfdd
commit
49bb849982
12 changed files with 242 additions and 46 deletions
|
|
@ -16,6 +16,8 @@ import {
|
|||
scrollToTop,
|
||||
} from '@/utils/common'
|
||||
import useTracks from '@/hooks/useTracks'
|
||||
import useUserAlbums, { useMutationLikeAAlbum } from '@/hooks/useUserAlbums'
|
||||
import useUser from '@/hooks/useUser'
|
||||
|
||||
const PlayButton = ({
|
||||
album,
|
||||
|
|
@ -79,6 +81,13 @@ const Header = ({
|
|||
|
||||
const [isCoverError, setCoverError] = useState(false)
|
||||
|
||||
const { data: userAlbums } = useUserAlbums()
|
||||
const isThisAlbumLiked = useMemo(() => {
|
||||
if (!album) return false
|
||||
return !!userAlbums?.data?.find(a => a.id === album.id)
|
||||
}, [album, userAlbums?.data])
|
||||
const mutationLikeAAlbum = useMutationLikeAAlbum()
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Header background */}
|
||||
|
|
@ -189,11 +198,16 @@ const Header = ({
|
|||
|
||||
<Button
|
||||
color={ButtonColor.Gray}
|
||||
iconColor={ButtonColor.Gray}
|
||||
iconColor={
|
||||
isThisAlbumLiked ? ButtonColor.Primary : ButtonColor.Gray
|
||||
}
|
||||
isSkelton={isLoading}
|
||||
onClick={() => toast('施工中...')}
|
||||
onClick={() => album?.id && mutationLikeAAlbum.mutate(album)}
|
||||
>
|
||||
<SvgIcon name='heart-outline' className='h-6 w-6' />
|
||||
<SvgIcon
|
||||
name={isThisAlbumLiked ? 'heart' : 'heart-outline'}
|
||||
className='h-6 w-6'
|
||||
/>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue