当播放顺序改变,播放列表也会改变(这个可以做成ui选项而不是固定这样)
parent
e32f6ef871
commit
5ded7c7e19
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue