|
|
|
@ -20,12 +20,12 @@ interface Prop {
|
|
|
|
|
|
|
|
|
|
export default function PlayerCard({ show, className }: Prop) {
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const { audioId, playList, playQueue, playState, setShowCard, setPlayList, setPlayQueue } = useAudioStore(
|
|
|
|
|
const { audioId, playListInfo, playQueue, playState, setShowCard, setPlayList, setPlayQueue } = useAudioStore(
|
|
|
|
|
useShallow((state) => {
|
|
|
|
|
return {
|
|
|
|
|
playState: state.playState,
|
|
|
|
|
audioId: state.audioId,
|
|
|
|
|
playList: state.playList,
|
|
|
|
|
playListInfo: state.playListInfo,
|
|
|
|
|
playQueue: state.playQueue,
|
|
|
|
|
setShowCard: state.setShowCard,
|
|
|
|
|
setPlayList: state.setPlayList,
|
|
|
|
@ -36,12 +36,12 @@ export default function PlayerCard({ show, className }: Prop) {
|
|
|
|
|
const rightRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
|
|
const [lrc, setLrc] = useState<string>('');
|
|
|
|
|
const [height, setHeight] = useState<number>(100);
|
|
|
|
|
const [playListHeight, setPlayListHeight] = useState<number>(100);
|
|
|
|
|
|
|
|
|
|
const miniClass = 'translate-y-100vh'; // 缩小时的样式
|
|
|
|
|
const largeClass = 'translate-y-0'; // 放大后的样式
|
|
|
|
|
|
|
|
|
|
const audioInfo = playList.find((item) => item.id === audioId);
|
|
|
|
|
const audioInfo = playQueue.find((item) => item.id === audioId);
|
|
|
|
|
|
|
|
|
|
const getLrc = async (lrcUrl: string) => {
|
|
|
|
|
if (!lrcUrl) {
|
|
|
|
@ -59,7 +59,7 @@ export default function PlayerCard({ show, className }: Prop) {
|
|
|
|
|
const handleClearPlayQueue = () => {
|
|
|
|
|
if (audioInfo) {
|
|
|
|
|
setPlayQueue([audioInfo]);
|
|
|
|
|
setPlayList([audioInfo]);
|
|
|
|
|
if (playListInfo.type !== 'fm') setPlayList([audioInfo]);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -73,12 +73,12 @@ export default function PlayerCard({ show, className }: Prop) {
|
|
|
|
|
}, [audioInfo]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (rightRef.current?.offsetHeight) setHeight(rightRef.current?.offsetHeight - 24 - 15);
|
|
|
|
|
}, []);
|
|
|
|
|
if (rightRef.current?.offsetHeight) setPlayListHeight(rightRef.current?.offsetHeight - 24 - 15);
|
|
|
|
|
}, [show]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={`w-100vw h-100vh pb-150px bg-[#fff] transition-all duration-300 z-9 ${show ? largeClass : miniClass} ${className}`}
|
|
|
|
|
className={`w-100vw h-100vh pb-150px bg-[#fff] transition-all duration-300 z-9 overscroll-y-contain ${show ? largeClass : miniClass} ${className}`}
|
|
|
|
|
>
|
|
|
|
|
<Header type="client" />
|
|
|
|
|
|
|
|
|
@ -150,7 +150,9 @@ export default function PlayerCard({ show, className }: Prop) {
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<div className="w-full mt-15px ml-[-18px] overflow-hidden">
|
|
|
|
|
<SongList height={height} songList={playQueue} listInfo={{ type: 'playerCard', id: null }} />
|
|
|
|
|
{show && (
|
|
|
|
|
<SongList height={playListHeight} songList={playQueue} listInfo={{ type: 'playerCard', id: null }} />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|