修复player随机播放的bug

This commit is contained in:
qier222 2020-10-17 22:16:44 +08:00
parent fff224a0bf
commit 6ce6f6b167
5 changed files with 58 additions and 30 deletions

View file

@ -38,3 +38,16 @@ export function randomNum(minNum, maxNum) {
return 0;
}
}
export function shuffleAList(list) {
let sortsList = list.map((t) => t.sort);
for (let i = 1; i < sortsList.length; i++) {
const random = Math.floor(Math.random() * (i + 1));
[sortsList[i], sortsList[random]] = [sortsList[random], sortsList[i]];
}
let newSorts = {};
list.map((track) => {
newSorts[track.id] = sortsList.pop();
});
return newSorts;
}