1import PluginManager from '@/core/pluginManager'; 2import {useEffect, useState} from 'react'; 3 4export default function useAlbumMusicList(albumItem: IAlbum.IAlbumItem | null) { 5 const [musicList, setMusicList] = useState<IMusic.IMusicItem[] | null>( 6 null, 7 ); 8 9 useEffect(() => { 10 if (albumItem === null) { 11 return; 12 } 13 PluginManager.getByMedia(albumItem) 14 ?.methods?.getAlbumInfo?.(albumItem) 15 ?.then(_ => { 16 setMusicList(_?.musicList ?? []); 17 }) 18 ?.catch(); 19 }, []); 20 return musicList; 21} 22