diff --git a/src/components/Journal/JournalCard.tsx b/src/components/Journal/JournalCard.tsx index 18c7c94..3a48659 100644 --- a/src/components/Journal/JournalCard.tsx +++ b/src/components/Journal/JournalCard.tsx @@ -18,7 +18,6 @@ export default function JournalCard({ image, title, journalNo, - showPlay = false, scale = false, children, className, @@ -26,7 +25,6 @@ export default function JournalCard({ image: string; journalNo: string; title?: string; - showPlay?: boolean; scale?: boolean; children?: React.ReactNode; className?: string; @@ -51,10 +49,6 @@ export default function JournalCard({

{title}

)} - {/* 播放按钮 */} - {showPlay && ( -
- )} {children}
); diff --git a/src/components/Journal/JournalList/VolListCoverCard.tsx b/src/components/Journal/JournalList/VolListCoverCard.tsx index 76559a0..eacd4ca 100644 --- a/src/components/Journal/JournalList/VolListCoverCard.tsx +++ b/src/components/Journal/JournalList/VolListCoverCard.tsx @@ -1,3 +1,5 @@ +import CardPlayButton from '@/components/Journal/widget/CardPlayButton'; + import styles from '../index.module.css'; import { JournalCard } from '@/components'; @@ -8,7 +10,10 @@ export default function CoverCard({ title, img, no }: { title: string; img: stri

{title}

-
+ ); } diff --git a/src/components/Journal/VolPlayButton.tsx b/src/components/Journal/VolPlayButton.tsx index 0a52e99..b770f82 100644 --- a/src/components/Journal/VolPlayButton.tsx +++ b/src/components/Journal/VolPlayButton.tsx @@ -1,5 +1,8 @@ 'use client'; +import { useEffect } from 'react'; + +import { useSearchParams } from 'next/navigation'; import { useShallow } from 'zustand/react/shallow'; import { PlayButton } from '@/components'; @@ -14,6 +17,8 @@ export default function VolPlayButton({ songList: SongInfo[]; className?: string; }) { + const searchParams = useSearchParams(); + const { playListInfo, playState, setPlayState, setPlayListInfo, setPlayList, setAudioId } = useAudioStore( useShallow((state) => { return { @@ -31,6 +36,7 @@ export default function VolPlayButton({ const isCurrentVol = playListInfo.type === 'vol' && playListInfo.id === journalInfo.id; const handlePlay = (state: boolean) => { + // 未在播放当前歌单 if (state && !isCurrentVol) { const res = setPlayListInfo({ type: 'vol', @@ -41,9 +47,18 @@ export default function VolPlayButton({ setAudioId(songList[0].id); } + // 如果正在播放当前歌单,则直接改变播放状态 setPlayState(!playState); }; + useEffect(() => { + // 如果路径中有 autoPlay 参数,则播放 + const autoPlay = searchParams.get('autoPlay'); + if (autoPlay) { + handlePlay(true); + } + }, []); + return ( { + e.preventDefault(); + router.push(`/vol/${no}?autoPlay=1`); + }; + + return ( +
+ ); +}