增加列表中歌曲随机乱序排列,修复专辑名排序无效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:
brstlig
2023-07-11 15:04:13 +08:00
committed by GitHub
co-authored by lyswhut
parent 6423066cb2
commit d97a27307c
7 changed files with 105 additions and 60 deletions
+20
View File
@@ -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
}