import { resizeImage } from '@/web/utils/common'
import { player } from '@/web/store'
import { State as PlayerState } from '@/web/utils/player'
import { useSnapshot } from 'valtio'
import useTracks from '@/web/api/hooks/useTracks'
import { css, cx } from '@emotion/css'
import { AnimatePresence, motion } from 'framer-motion'
import Image from './Image'
import Wave from './Wave'
import Icon from '@/web/components/Icon'
import { useVirtualizer } from '@tanstack/react-virtual'
import { useRef } from 'react'
import { useWindowSize } from 'react-use'
import { playerWidth, topbarHeight } from '@/web/utils/const'
const Header = () => {
return (
)
}
const Track = ({
track,
index,
playingTrackIndex,
state,
}: {
track?: Track
index: number
playingTrackIndex: number
state: PlayerState
}) => {
return (
{
if (e.detail === 2 && track?.id) player.playTrack(track.id)
}}
>
{/* Cover */}
{/* Track info */}
{track?.name}
{track?.ar.map(a => a.name).join(', ')}
{/* Wave icon */}
{playingTrackIndex === index ? (
) : (
{String(index + 1).padStart(2, '0')}
)}
)
}
const TrackList = ({ className }: { className?: string }) => {
const { trackList, trackIndex, state } = useSnapshot(player)
const { data: tracksRaw } = useTracks({ ids: trackList })
const tracks = tracksRaw?.songs || []
const parentRef = useRef(null)
const { height } = useWindowSize()
const listHeight = height - topbarHeight - playerWidth - 24 - 20 // 24是封面与底部间距,20是list与封面间距
const rowVirtualizer = useVirtualizer({
count: tracks.length,
getScrollElement: () => parentRef.current,
estimateSize: () => 76,
overscan: 10,
})
return (
<>
{rowVirtualizer.getVirtualItems().map((row: any) => (
))}
{/* 底部渐变遮罩 */}
>
)
}
const PlayingNext = ({ className }: { className?: string }) => {
return (
<>
>
)
}
export default PlayingNext