|
|
@ -15,31 +15,31 @@ interface Props {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function JournalItem({ listId, songList, className }: Props) {
|
|
|
|
export default function JournalItem({ listId, songList, className }: Props) {
|
|
|
|
const { setPlayList, audioIndex, playListId, setAudioIndex } = useAudioStore(
|
|
|
|
const { setPlayList, setAudioId, playListId, audioId } = useAudioStore(
|
|
|
|
useShallow((state) => ({
|
|
|
|
useShallow((state) => ({
|
|
|
|
setplayList: state.setPlayList,
|
|
|
|
setplayList: state.setPlayList,
|
|
|
|
audioIndex: state.audioIndex,
|
|
|
|
setAudioId: state.setAudioId,
|
|
|
|
setAudioIndex: state.setAudioIndex,
|
|
|
|
audioId: state.audioId,
|
|
|
|
playList: state.playList,
|
|
|
|
playList: state.playList,
|
|
|
|
setPlayList: state.setPlayList,
|
|
|
|
setPlayList: state.setPlayList,
|
|
|
|
playListId: state.playListId,
|
|
|
|
playListId: state.playListId,
|
|
|
|
})),
|
|
|
|
})),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const handlePlayList = (index: number) => {
|
|
|
|
const handlePlayList = (id: string) => {
|
|
|
|
// 正在播放当前歌单
|
|
|
|
// 正在播放当前歌单
|
|
|
|
if (playListId !== listId) {
|
|
|
|
if (playListId !== listId) {
|
|
|
|
setPlayList({ id: listId, list: songList });
|
|
|
|
setPlayList({ id: listId, list: songList });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 正在播放其他歌单
|
|
|
|
// 正在播放其他歌单
|
|
|
|
setAudioIndex(index);
|
|
|
|
setAudioId(id);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className={`${className}`}>
|
|
|
|
<div className={`${className}`}>
|
|
|
|
{songList.map((song: SongInfo, index: number) => (
|
|
|
|
{songList.map((song: SongInfo) => (
|
|
|
|
<SongCard key={song.id} {...song} onPlay={() => handlePlayList(index)} />
|
|
|
|
<SongCard key={song.id} {...song} onPlay={(audioId: string) => handlePlayList(audioId)} />
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|