当播放顺序改变,播放列表也会改变(这个可以做成ui选项而不是固定这样)

pull/2369/head
QiuLiang-99 2025-05-03 17:31:08 +08:00
parent e32f6ef871
commit 5ded7c7e19
2 changed files with 17 additions and 15 deletions

View File

@ -16,25 +16,26 @@
<script setup>
import { ref, computed } from 'vue'
import {
// musicInfo,
// isPlay,
// playMusicInfo, playInfo,
tempPlayList,
} from '@renderer/store/player/state'
// import { togglePlay, playNext, playPrev } from '@renderer/core/player'
import { tempPlayList, currentPlaybackOrder } from '@renderer/store/player/state'
const emit = defineEmits(['close'])
// todo item
// todo item
const playlist = ref(tempPlayList)
const songs = computed(() =>
playlist.value.map(music => ({
title: music.musicInfo.name,
artist: music.musicInfo.singer,
album: music.musicInfo.meta.albumName,
})),
)
const songs = computed(() => {
let showlist = []
for (const index of currentPlaybackOrder.value) {
const playMusicInfo = playlist.value[index]
showlist.push({
title: playMusicInfo.musicInfo.name,
artist: playMusicInfo.musicInfo.singer,
album: playMusicInfo.musicInfo.meta.albumName,
})
}
return showlist
},
)
const emitClose = () => {
emit('close')
}
@ -60,7 +61,7 @@ const emitClose = () => {
font-size: 18px;
font-weight: bold;
text-align: center;
}
}p
.close-button {
position: absolute;

View File

@ -32,6 +32,7 @@ export default () => {
const N = tempPlayList.length
const prevPlayIndex = currentPlaybackOrder.value[currentPlayIndex.value]
if (mode === 'random') {
currentPlayIndex.value = 0
const allIndexes = Array.from({ length: N }, (_, i) => i).filter(i => i !== prevPlayIndex)
for (let i = allIndexes.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))