fix: 完善 player store setPlaylist 签名 & 类型修复

This commit is contained in:
QZMusic Dev
2026-06-18 17:52:25 +00:00
parent 351235484c
commit c4c3c6b5a2

View File

@@ -149,12 +149,16 @@ export const usePlayerStore = defineStore('player', () => {
// --- Actions --- // --- Actions ---
const setPlaylist = async (list: any[], startIndex = 0) => { const setPlaylist = async (list: Song[], startIndex = 0) => {
playlist.value = list; if (!Array.isArray(list) || list.length === 0) {
currentIndex.value = startIndex; playlist.value = [];
if (list.length > 0 && startIndex >= 0 && startIndex < list.length) { currentIndex.value = -1;
await playSong(list[startIndex]); 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[]) => { const playFromList = async (song: Song, contextList: Song[]) => {