保存大数据时预期的本地存储大小问题

问题描述

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 (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...