Skip to content

Commit 4606856

Browse files
authored
Merge pull request #701 from awsl1414/dev
fix: 🐛 修复本地播放模式逻辑
2 parents 1532601 + 1fdb9dc commit 4606856

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/core/player/PlayerController.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,13 +951,23 @@ class PlayerController {
951951
/**
952952
* 切换随机模式
953953
* @param mode 可选,直接设置目标模式。如果不传则按 Off -> On -> Heartbeat -> Off 顺序轮转
954+
* @note 当播放列表包含本地歌曲时,跳过心动模式,只在 Off 和 On 之间切换
954955
*/
955956
public async toggleShuffle(mode?: ShuffleModeType) {
957+
const dataStore = useDataStore();
956958
const statusStore = useStatusStore();
957959
const currentMode = statusStore.shuffleMode;
958960

961+
// 检查播放列表是否包含本地歌曲
962+
const hasLocalSongs = dataStore.playList.some((song) => song.path);
963+
959964
// 预判下一个模式
960-
const nextMode = mode ?? this.playModeManager.calculateNextShuffleMode(currentMode);
965+
let nextMode = mode ?? this.playModeManager.calculateNextShuffleMode(currentMode);
966+
967+
// 如果播放列表包含本地歌曲,跳过心动模式
968+
if (hasLocalSongs && nextMode === "heartbeat") {
969+
nextMode = "off";
970+
}
961971

962972
// 已经是心动模式,再次触发心动模式并播放
963973
if (currentMode === "heartbeat" && nextMode === "heartbeat") {

0 commit comments

Comments
 (0)