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 ---
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[]) => {