mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
修复player随机播放的bug
This commit is contained in:
parent
fff224a0bf
commit
6ce6f6b167
5 changed files with 58 additions and 30 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue