如何解决保存大数据时预期的本地存储大小问题
iam使用django开发音乐站点并做出反应,您可以保存您的歌曲和播放列表,我想保存刷新之前正在播放的播放列表... iam仅保存当前歌曲(名称,文件,id,图像)在本地存储中 所以问题是,将所有播放列表保存在本地存储中会不会有问题?还是有另一种处理方式?
const handleEnd=()=>{
let songId=props.currentSong.id || localStorage.getItem('id')
let currentIndex=props.songs.findIndex(track=>track.id===songId)
if (props.songs[currentIndex] === props.songs.length-1 ){
currentIndex=0
props.setCurrentSong(props.songs[currentIndex].id)
}
else{
const next=currentIndex+1
if(next >= props.songs.length-1){
currentIndex=-1
}
else{
props.setCurrentSong(props.songs[next].id)
}
}
}
const handleNextPrev=(np)=>{
let songId=props.currentSong.id || localStorage.getItem('id')
let currentIndex=props.songs.findIndex(song=>song.id===songId)
if(np==='next')
{
if (currentIndex === props.songs.length-1 )
{
currentIndex=0
props.setCurrentSong(props.songs[currentIndex].id)
}else{
const next=currentIndex+1
props.setCurrentSong(props.songs[next].id)
}
}
else if(np==='prev')
{
if (currentIndex === 0 )
{
console.log(currentIndex);
props.setCurrentSong(props.songs[props.songs.length-1].id)
}
else
{
console.log(currentIndex);
const previous=currentIndex-1
props.setCurrentSong(props.songs[previous].id)
}
}
}
如果刷新,我会使用这两个功能在播放列表中循环播放,我会丢失所有数据,但只会丢失当前曲目
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。