import CoverRow, { Subtitle } from '@/renderer/components/CoverRow' import SvgIcon from '@/renderer/components/SvgIcon' import useUserAlbums from '@/renderer/hooks/useUserAlbums' import useLyric from '@/renderer/hooks/useLyric' import usePlaylist from '@/renderer/hooks/usePlaylist' import useUser from '@/renderer/hooks/useUser' import useUserPlaylists from '@/renderer/hooks/useUserPlaylists' import { player } from '@/renderer/store' import { resizeImage } from '@/renderer/utils/common' import { sample, chunk } from 'lodash-es' import useUserArtists from '@/renderer/hooks/useUserArtists' const LikedTracksCard = ({ className }: { className?: string }) => { const navigate = useNavigate() const { data: playlists } = useUserPlaylists() const { data: likedSongsPlaylist } = usePlaylist({ id: playlists?.playlist?.[0].id ?? 0, }) // Lyric const [trackID, setTrackID] = useState(0) useEffect(() => { if (trackID === 0) { setTrackID( sample(likedSongsPlaylist?.playlist.trackIds?.map(t => t.id) ?? []) ?? 0 ) } }, [likedSongsPlaylist?.playlist.trackIds, trackID]) const { data: lyric } = useLyric({ id: trackID, }) const lyricLines = useMemo(() => { return ( sample( chunk( lyric?.lrc.lyric ?.split('\n') ?.map(l => l.split(']').pop()?.trim()) ?.filter( l => l && !l.includes('作词') && !l.includes('作曲') && !l.includes('纯音乐,请欣赏') ), 3 ) ) ?? [] ) }, [lyric]) const handlePlay = useCallback( (e: React.MouseEvent) => { e.stopPropagation() if (!likedSongsPlaylist?.playlist.id) { toast('无法播放歌单') return } player.playPlaylist(likedSongsPlaylist.playlist.id) }, [likedSongsPlaylist?.playlist.id] ) return (
likedSongsPlaylist?.playlist.id && navigate(`/playlist/${likedSongsPlaylist.playlist.id}`) } className={classNames( 'relative flex h-full w-full flex-col justify-between rounded-2xl bg-brand-50 py-5 px-6 text-brand-600 dark:bg-brand-800 dark:text-brand-50', className )} >
{lyricLines.map((line, index) => (
{line}
))}
我喜欢的音乐
{likedSongsPlaylist?.playlist.trackCount ?? 0} 首歌
) } const OtherCard = ({ name, icon, className, }: { name: string icon: string className?: string }) => { return (
{name}
) } const Playlists = () => { const { data: playlists } = useUserPlaylists() return (
) } const Albums = () => { const { data: albums } = useUserAlbums({ limit: 1000, }) return (
) } const Artists = () => { const { data: artists } = useUserArtists() return (
) } const MVs = () => { return
施工中
} const Podcasts = () => { return
施工中
} interface TabsType { playlist: string album: string artist: string mv: string podcast: string } const TabHeader = ({ activeTab, tabs, setActiveTab, }: { activeTab: keyof TabsType tabs: TabsType setActiveTab: (tab: keyof TabsType) => void }) => { return (
{Object.entries(tabs).map(([id, name]) => (
setActiveTab(id as keyof TabsType)} className={classNames( 'btn-pressed-animation mr-3 rounded-lg px-3.5 py-1.5 font-medium', activeTab === id ? 'bg-black/[.04] dark:bg-white/10' : 'btn-hover-animation after:bg-black/[.04] dark:after:bg-white/10' )} > {name}
))}
) } const Tabs = () => { const tabs = { playlist: '全部歌单', album: '专辑', artist: '艺人', mv: 'MV', podcast: '播客', } const [activeTab, setActiveTab] = useState('playlist') return ( <>
{activeTab === 'playlist' && } {activeTab === 'album' && } {activeTab === 'artist' && } {activeTab === 'mv' && } {activeTab === 'podcast' && }
) } const Library = () => { const { data: user } = useUser() const avatarUrl = useMemo( () => resizeImage(user?.profile?.avatarUrl ?? '', 'sm'), [user?.profile?.avatarUrl] ) return (
{user?.profile?.nickname}的音乐库
) } export default Library