Add files via upload
This commit is contained in:
parent
a87ce169b6
commit
60c954f59a
@ -79,9 +79,44 @@ const getIntv = (musicInfo: LX.Music.MusicInfo) => {
|
||||
* @param localeId 排序语言
|
||||
* @returns
|
||||
*/
|
||||
export const sortListMusicInfo = async(list: LX.Music.MusicInfo[], sortType: 'up' | 'down', fieldName: 'name' | 'singer' | 'albumName' | 'interval' | 'source', localeId: string) => {
|
||||
export const sortListMusicInfo = async(list: LX.Music.MusicInfo[], sortType: 'up' | 'down' | 'disorder', fieldName: 'name' | 'singer' | 'albumName' | 'interval' | 'source', localeId: string) => {
|
||||
// console.log(sortType, fieldName, localeId)
|
||||
// const locale = new Intl.Locale(localeId)
|
||||
if (sortType == 'disorder' && (fieldName =='name' || fieldName == 'singer' || fieldName =='albumName' || fieldName =='interval' || fieldName =='source')){
|
||||
|
||||
let change_num:number[]=[]
|
||||
|
||||
for(let i:number = 0;i<list.length;i++){
|
||||
if(change_num.length == 0){
|
||||
let r_num:number = Math.floor(Math.random()*list.length)
|
||||
change_num.push(r_num)
|
||||
}
|
||||
else{
|
||||
let sign:boolean = false
|
||||
do{
|
||||
let r_num:number = Math.floor(Math.random()*list.length)
|
||||
for(let j:number = 0 ; j<change_num.length; j++){
|
||||
if(change_num[j] == r_num){
|
||||
break;
|
||||
}
|
||||
if (j == change_num.length-1){
|
||||
change_num.push(r_num)
|
||||
sign = true
|
||||
}
|
||||
}
|
||||
}while(!sign)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let list2:LX.Music.MusicInfo[]=[]
|
||||
for(let k:number = 0;k<change_num.length;k++){
|
||||
list2.push(list[change_num[k]])
|
||||
}
|
||||
return list2
|
||||
}
|
||||
else{
|
||||
if (sortType == 'up') {
|
||||
if (fieldName == 'interval') {
|
||||
list.sort((a, b) => {
|
||||
@ -138,6 +173,9 @@ export const sortListMusicInfo = async(list: LX.Music.MusicInfo[], sortType: 'up
|
||||
}
|
||||
}
|
||||
return list
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const variantRxp = /(\(|().+(\)|))/g
|
||||
|
||||
Loading…
Reference in New Issue
Block a user