fix: 切换歌曲时多次弹窗

This commit is contained in:
imsyy
2023-05-09 17:57:06 +08:00
parent 40ed0dada1
commit c78f94ae86
4 changed files with 11 additions and 5 deletions

View File

@@ -43,6 +43,7 @@
- [ ] 发表评论
- [ ] `i18n` 支持
- [ ] 重构(写成屎山了) 🤣
## 😍 Screenshots

View File

@@ -93,9 +93,12 @@ const playListShow = ref(false);
// 改变播放索引
const changeIndex = (index) => {
try {
music.persistData.playSongIndex = index;
if (music.persistData.playSongIndex !== index) {
setSeek($player, 0);
music.persistData.playSongIndex = index;
music.isLoadingSong = true;
music.setPlayState(true);
}
} catch (err) {
console.error("切换失败:" + err);
$message.error("切换失败,请刷新后重试");

View File

@@ -387,7 +387,8 @@ const songChange = debounce(500, (val) => {
window.document.title =
sessionStorage.getItem("siteTitle") ?? import.meta.env.VITE_SITE_TITLE;
}
// 清除播放地址
// 清除当前状态
setSeek($player, 0);
soundUnload();
// 加载数据
getPlaySongData(val);

View File

@@ -422,6 +422,7 @@ const useMusicDataStore = defineStore("musicData", {
) {
console.log("播放歌曲与上一次不一致");
// soundUnload();
this.isLoadingSong = true;
setSeek($player, 0);
}
} catch (error) {
@@ -433,7 +434,7 @@ const useMusicDataStore = defineStore("musicData", {
this.persistData.playlists.push(value);
this.persistData.playSongIndex = this.persistData.playlists.length - 1;
}
play ? (this.playState = true) : null;
play ? this.setPlayState(true) : null;
},
// 在当前播放歌曲后添加
addSongToNext(value) {