|
|
@ -1,6 +1,5 @@
|
|
|
|
'use client';
|
|
|
|
'use client';
|
|
|
|
// import { useEffect, useState } from 'react';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import dynamic from 'next/dynamic';
|
|
|
|
import dynamic from 'next/dynamic';
|
|
|
|
import { useShallow } from 'zustand/react/shallow';
|
|
|
|
import { useShallow } from 'zustand/react/shallow';
|
|
|
@ -11,13 +10,15 @@ import PlayerCard from './PlayerCard';
|
|
|
|
import useAudioStore from '@/store/audio';
|
|
|
|
import useAudioStore from '@/store/audio';
|
|
|
|
|
|
|
|
|
|
|
|
const PlayerBar = ({ className }: { className?: string }) => {
|
|
|
|
const PlayerBar = ({ className }: { className?: string }) => {
|
|
|
|
const { audioId, order, playQueue, showCard, switchSongByDiff, setOrder, setShowCard } = useAudioStore(
|
|
|
|
const { show, audioId, order, playQueue, showCard, setShow, setOrder, setShowCard } = useAudioStore(
|
|
|
|
useShallow((state) => {
|
|
|
|
useShallow((state) => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
|
|
|
|
show: state.show,
|
|
|
|
audioId: state.audioId,
|
|
|
|
audioId: state.audioId,
|
|
|
|
order: state.order,
|
|
|
|
order: state.order,
|
|
|
|
playQueue: state.playQueue,
|
|
|
|
playQueue: state.playQueue,
|
|
|
|
showCard: state.showCard,
|
|
|
|
showCard: state.showCard,
|
|
|
|
|
|
|
|
setShow: state.setShow,
|
|
|
|
setOrder: state.setOrder,
|
|
|
|
setOrder: state.setOrder,
|
|
|
|
switchSongByDiff: state.switchSongByDiff,
|
|
|
|
switchSongByDiff: state.switchSongByDiff,
|
|
|
|
setShowCard: state.setShowCard,
|
|
|
|
setShowCard: state.setShowCard,
|
|
|
@ -29,35 +30,23 @@ const PlayerBar = ({ className }: { className?: string }) => {
|
|
|
|
setShowCard(!showCard);
|
|
|
|
setShowCard(!showCard);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// let oldScrollY: number = 0;
|
|
|
|
let timer: NodeJS.Timeout;
|
|
|
|
// function handleScroll() {
|
|
|
|
|
|
|
|
// if (window.scrollY > oldScrollY) {
|
|
|
|
|
|
|
|
// // 向下滚动
|
|
|
|
|
|
|
|
// // if (oldScrollY < 0) return;
|
|
|
|
|
|
|
|
// setPositionBottom(-130);
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// // 向上滚动
|
|
|
|
|
|
|
|
// // if (oldScrollY > 0) return;
|
|
|
|
|
|
|
|
// setPositionBottom(0);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// oldScrollY = window.scrollY;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
function handleScroll() {
|
|
|
|
// window.addEventListener('scroll', handleScroll);
|
|
|
|
clearInterval(timer);
|
|
|
|
// return () => {
|
|
|
|
setShow(false);
|
|
|
|
// window.removeEventListener('scroll', handleScroll);
|
|
|
|
timer = setTimeout(() => {
|
|
|
|
// };
|
|
|
|
setShow(true);
|
|
|
|
}, []);
|
|
|
|
}, 800);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
// window.addEventListener('scroll', handleScroll);
|
|
|
|
window.addEventListener('scroll', handleScroll);
|
|
|
|
// return () => {
|
|
|
|
return () => {
|
|
|
|
// window.removeEventListener('scroll', handleScroll);
|
|
|
|
window.removeEventListener('scroll', handleScroll);
|
|
|
|
// };
|
|
|
|
clearInterval(timer);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
// const [positionBottom, setPositionBottom] = useState<number>(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
// 注释为高斯模糊效果
|
|
|
|
// 注释为高斯模糊效果
|
|
|
@ -65,12 +54,12 @@ const PlayerBar = ({ className }: { className?: string }) => {
|
|
|
|
// className={`fixed w-[100vw] h-[130px] bg-[#000] bg-opacity-50 shadow-lg shadow-black-[0_0_10px] z-10 ${className} backdrop-blur-[4px]`}
|
|
|
|
// className={`fixed w-[100vw] h-[130px] bg-[#000] bg-opacity-50 shadow-lg shadow-black-[0_0_10px] z-10 ${className} backdrop-blur-[4px]`}
|
|
|
|
// style={{ bottom: 0 }}
|
|
|
|
// style={{ bottom: 0 }}
|
|
|
|
// >
|
|
|
|
// >
|
|
|
|
|
|
|
|
<div className={`fixed w-[100vw] h-[130px] bg-[#fff] shadow-lg shadow-black-[0_0_10px] z-10 ${className}`}>
|
|
|
|
|
|
|
|
{/* 播放器 */}
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
className={`fixed w-[100vw] h-[130px] bg-[#fff] shadow-lg shadow-black-[0_0_10px] z-10 ${className}`}
|
|
|
|
className="fixed bottom-0 w-[100vw] h-[130px] m-auto bg-[#fff] shadow-lg z-10 transition-bottom duration-600"
|
|
|
|
style={{ bottom: 0 }}
|
|
|
|
style={{ bottom: show && audioId ? 0 : -130 }}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{/* 播放器 */}
|
|
|
|
|
|
|
|
<div className="fixed bottom-0 w-[100vw] h-[130px] m-auto bg-[#fff] z-10">
|
|
|
|
|
|
|
|
<Player className="m-auto" onSwitchShowCard={handleSwitchShowCard} />
|
|
|
|
<Player className="m-auto" onSwitchShowCard={handleSwitchShowCard} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/* 单曲卡片 */}
|
|
|
|
{/* 单曲卡片 */}
|
|
|
|