feat: 优化主题效果 添加展开 menu功能 优化图片清晰度 添加随机播放功能(#20)

This commit is contained in:
alger
2024-12-29 00:43:39 +08:00
parent abdb2bcd50
commit dfdf02a17f
15 changed files with 118 additions and 130 deletions
+17 -1
View File
@@ -111,6 +111,22 @@ export const audioServiceOn = (audio: typeof audioService) => {
if (store.state.playMode === 1) {
// 单曲循环模式
audio.getCurrentSound()?.play();
} else if (store.state.playMode === 2) {
// 随机播放模式
const { playList } = store.state;
if (playList.length <= 1) {
// 如果播放列表只有一首歌或为空,则重新播放当前歌曲
audio.getCurrentSound()?.play();
} else {
// 随机选择一首不同的歌
let randomIndex;
do {
randomIndex = Math.floor(Math.random() * playList.length);
} while (randomIndex === store.state.playListIndex && playList.length > 1);
store.state.playListIndex = randomIndex;
store.commit('setPlay', playList[randomIndex]);
}
} else {
// 列表循环模式
store.commit('nextPlay');
@@ -229,7 +245,7 @@ export const useLyricProgress = () => {
};
};
// 设置前播放时间
// 设置前播放时间
export const setAudioTime = (index: number) => {
const currentSound = sound.value;
if (!currentSound) return;