import useIsMobile from '@/web/hooks/useIsMobile' import useAppleMusicArtist from '@/web/api/hooks/useAppleMusicArtist' import { cx, css } from '@emotion/css' import { useTranslation } from 'react-i18next' import { useState } from 'react' import DescriptionViewer from '@/web/components/DescriptionViewer' const ArtistInfo = ({ artist, isLoading }: { artist?: Artist; isLoading: boolean }) => { const { t, i18n } = useTranslation() const isMobile = useIsMobile() const { data: artistFromApple, isLoading: isLoadingArtistFromApple } = useAppleMusicArtist( artist?.id || 0 ) const [isOpenDescription, setIsOpenDescription] = useState(false) const description = artistFromApple?.artistBio?.[i18n.language.replace('-', '_')] || (i18n.language === 'zh-CN' && artist?.briefDesc) || artistFromApple?.artistBio?.en_US return (
{/* Name */} {isLoading ? (
PLACEHOLDER
) : (
{artist?.name}
)} {/* Type */} {isLoading ? (
Artist
) : (
Artist
)} {/* Counts */} {isLoading ? (
PLACEHOLDER12345
) : (
{t('common.track-with-count', { count: artist?.musicSize })} ·{' '} {t('common.album-with-count', { count: artist?.albumSize })} ·{' '} {t('common.video-with-count', { count: artist?.mvSize })}
)} {/* Description */} {!isMobile && (isLoading || isLoadingArtistFromApple ? (
PLACEHOLDER1234567890
) : (
setIsOpenDescription(true)} dangerouslySetInnerHTML={{ __html: description }} >
))} setIsOpenDescription(false)} title={artist?.name || ''} />
) } export default ArtistInfo