import Button, { Color as ButtonColor } from '@/components/Button' import SvgIcon from '@/components/SvgIcon' import Cover from '@/components/Cover' import useArtist from '@/hooks/useArtist' import useArtistAlbums from '@/hooks/useArtistAlbums' import { resizeImage } from '@/utils/common' import dayjs from 'dayjs' import TracksGrid from '@/components/TracksGrid' import CoverRow, { Subtitle } from '@/components/CoverRow' import Skeleton from '@/components/Skeleton' import { Fragment } from 'react' import useTracks from '@/hooks/useTracks' const Artist = () => { const params = useParams() const { data: artist, isLoading } = useArtist({ id: Number(params.id) || 0, }) const { data: albumsRaw, isLoading: isLoadingAlbum } = useArtistAlbums({ id: Number(params.id) || 0, limit: 1000, }) const { data: tracks, isLoading: isLoadingTracks } = useTracks({ ids: artist?.hotSongs?.slice(0, 10)?.map(t => t.id) ?? [], }) const albums = useMemo(() => { if (!albumsRaw?.hotAlbums) return [] const albums: Album[] = [] albumsRaw.hotAlbums.forEach(album => { if (album.type !== '专辑') return false if (['混音版', '精选集', 'Remix'].includes(album.subType)) return false // No singles if (album.size <= 1) return false // No remixes if ( /(\(|\[)(.*)(Remix|remix)(.*)(\)|\])/.test( album.name.toLocaleLowerCase() ) ) { return false } // If have same name album only keep the Explicit version const sameNameAlbumIndex = albums.findIndex(a => a.name === album.name) if (sameNameAlbumIndex !== -1) { if (album.mark === 1056768) albums[sameNameAlbumIndex] = album return } albums.push(album) }) return albums }, [albumsRaw?.hotAlbums]) const singles = useMemo(() => { if (!albumsRaw?.hotAlbums) return [] const albumsIds = albums.map(album => album.id) return albumsRaw.hotAlbums.filter( album => albumsIds.includes(album.id) === false ) }, [albums, albumsRaw?.hotAlbums]) const latestAlbum = useMemo(() => { if (!albumsRaw || !albumsRaw.hotAlbums) return return albumsRaw.hotAlbums[0] }, [albumsRaw]) const coverImage = resizeImage(artist?.artist?.img1v1Url || '', 'md') return (
{coverImage && ( )}
{/* Header */}
{artist?.artist.name}
{/* Latest release */}
最新发行
{isLoadingAlbum ? ( ) : ( )}
{latestAlbum?.name}
{latestAlbum?.type} ·{' '} {dayjs(latestAlbum?.publishTime || 0).year()}
{/* Popular tracks */}
热门歌曲
{/* Albums */} {albums.length !== 0 && (
专辑
)} {/* Singles/EP */}
单曲和EP
) } export default Artist