Skip to content

Commit 6bce76e

Browse files
authored
fix(SongMenu): 「下一首播放」的显示未按预期 (#997)
`index` 应该是歌曲在**歌曲列表**中的,而不是**播放列表**中的,这里却用这个 `index` 去和播放列表里的 `playIndex` 比较,是完全错误的
1 parent 57f567a commit 6bce76e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/composables/useSongMenu.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ export const useSongMenu = () => {
149149
}
150150
};
151151

152+
// 判断两首歌是否相同
153+
const isSameSong = (song1: SongType, song2: SongType): boolean => {
154+
if (song1.id != null && song2.id != null) {
155+
return song1.id === song2.id;
156+
}
157+
if (song1.path && song2.path) {
158+
return song1.path === song2.path;
159+
}
160+
return false;
161+
};
162+
152163
// 生成菜单选项
153164
const getMenuOptions = (
154165
song: SongType,
@@ -165,7 +176,7 @@ export const useSongMenu = () => {
165176
const isCloud = router.currentRoute.value.name === "cloud";
166177
const isLocal = !!song?.path;
167178
const isLoginNormal = isLogin() === 1;
168-
const isCurrent = statusStore.playIndex === index;
179+
const isCurrent = isSameSong(musicStore.playSong, song);
169180
const isLocalPlaylist = localStore.isLocalPlaylist(playListId);
170181
const isUserPlaylist =
171182
(!!playListId && userPlaylistsData.some((pl) => pl.id === playListId)) || isLocalPlaylist;

0 commit comments

Comments
 (0)