From c4c3c6b5a245106f110616a130b060a7bd7fc364 Mon Sep 17 00:00:00 2001 From: QZMusic Dev Date: Thu, 18 Jun 2026 17:52:25 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=20player=20store=20se?= =?UTF-8?q?tPlaylist=20=E7=AD=BE=E5=90=8D=20&=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/player.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/stores/player.ts b/src/stores/player.ts index 9d82fe1..e3e46e9 100644 --- a/src/stores/player.ts +++ b/src/stores/player.ts @@ -149,12 +149,16 @@ export const usePlayerStore = defineStore('player', () => { // --- Actions --- - const setPlaylist = async (list: any[], startIndex = 0) => { - playlist.value = list; - currentIndex.value = startIndex; - if (list.length > 0 && startIndex >= 0 && startIndex < list.length) { - await playSong(list[startIndex]); + const setPlaylist = async (list: Song[], startIndex = 0) => { + if (!Array.isArray(list) || list.length === 0) { + playlist.value = []; + currentIndex.value = -1; + return; } + const safeStart = Math.max(0, Math.min(startIndex, list.length - 1)); + playlist.value = list; + currentIndex.value = safeStart; + await playSong(list[safeStart]); }; const playFromList = async (song: Song, contextList: Song[]) => {