fix: 完善 player store setPlaylist 签名 & 类型修复
This commit is contained in:
@@ -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[]) => {
|
||||
|
||||
Reference in New Issue
Block a user