Skip to content

Commit bb85cb5

Browse files
authored
Merge pull request #643 from imsyy/dev-perf
🎈 perf: 优化歌单对于单曲循环的自动切换
2 parents 662a649 + fe20aea commit bb85cb5

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/composables/List/useListActions.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
import type { SongType } from "@/types/main";
22
import { usePlayerController } from "@/core/player/PlayerController";
3+
import { useStatusStore } from "@/stores";
34

45
/**
56
* 列表操作逻辑
67
*/
78
export const useListActions = () => {
89
const player = usePlayerController();
10+
const statusStore = useStatusStore();
911

1012
/**
1113
* 播放全部歌曲
1214
*/
13-
const playAllSongs = (songs: SongType[], playListId?: number) => {
15+
const playAllSongs = async (songs: SongType[], playListId?: number) => {
1416
if (!songs?.length) return;
15-
player.updatePlayList(songs, undefined, playListId);
17+
// 如果是单曲循环模式,自动切换为顺序播放
18+
if (statusStore.playSongMode === "repeat-once") {
19+
await player.togglePlayMode("repeat");
20+
}
21+
await player.updatePlayList(songs, undefined, playListId);
1622
};
1723

1824
return {

0 commit comments

Comments
 (0)