当播放顺序改变,播放列表也会改变(这个可以做成ui选项而不是固定这样)
parent
e32f6ef871
commit
5ded7c7e19
|
@ -16,25 +16,26 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import {
|
import { tempPlayList, currentPlaybackOrder } from '@renderer/store/player/state'
|
||||||
// musicInfo,
|
|
||||||
// isPlay,
|
|
||||||
// playMusicInfo, playInfo,
|
|
||||||
tempPlayList,
|
|
||||||
} from '@renderer/store/player/state'
|
|
||||||
// import { togglePlay, playNext, playPrev } from '@renderer/core/player'
|
|
||||||
const emit = defineEmits(['close'])
|
const emit = defineEmits(['close'])
|
||||||
// todo 点击item切换歌曲
|
// todo 点击item切换歌曲
|
||||||
// todo 当前播放歌曲的item高亮
|
// todo 当前播放歌曲的item高亮
|
||||||
const playlist = ref(tempPlayList)
|
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 = () => {
|
const emitClose = () => {
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,7 @@ const emitClose = () => {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}p
|
||||||
|
|
||||||
.close-button {
|
.close-button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default () => {
|
||||||
const N = tempPlayList.length
|
const N = tempPlayList.length
|
||||||
const prevPlayIndex = currentPlaybackOrder.value[currentPlayIndex.value]
|
const prevPlayIndex = currentPlaybackOrder.value[currentPlayIndex.value]
|
||||||
if (mode === 'random') {
|
if (mode === 'random') {
|
||||||
|
currentPlayIndex.value = 0
|
||||||
const allIndexes = Array.from({ length: N }, (_, i) => i).filter(i => i !== prevPlayIndex)
|
const allIndexes = Array.from({ length: N }, (_, i) => i).filter(i => i !== prevPlayIndex)
|
||||||
for (let i = allIndexes.length - 1; i > 0; i--) {
|
for (let i = allIndexes.length - 1; i > 0; i--) {
|
||||||
const j = Math.floor(Math.random() * (i + 1))
|
const j = Math.floor(Math.random() * (i + 1))
|
||||||
|
|
Loading…
Reference in New Issue