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