增加列表中歌曲随机乱序排列,修复专辑名排序无效bug (#1440)
* Update zh-cn.json * Update ListSortModal.vue * Add files via upload * Update ListSortModal.vue 修复无法按专辑名排序bug,因变量名不一致导致 * 完善&优化 * 添加更新日志 --------- Co-authored-by: lyswhut <lyswhut@qq.com>
This commit is contained in:
@@ -225,3 +225,23 @@ export const arrPushByPosition = <T>(list: T[], newList: T[], position: number)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
|
||||
// https://stackoverflow.com/a/2450976
|
||||
export const arrShuffle = <T>(array: T[]) => {
|
||||
let currentIndex = array.length
|
||||
let randomIndex
|
||||
|
||||
// While there remain elements to shuffle.
|
||||
while (currentIndex != 0) {
|
||||
// Pick a remaining element.
|
||||
randomIndex = Math.floor(Math.random() * currentIndex)
|
||||
currentIndex--;
|
||||
|
||||
// And swap it with the current element.
|
||||
[array[currentIndex], array[randomIndex]] = [
|
||||
array[randomIndex], array[currentIndex]]
|
||||
}
|
||||
|
||||
return array
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user