|
|
@@ -1285,7 +1285,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
|
|
|
showRankDialog() {
|
|
|
- if (this.modeType === 2 || this.modeType === 3) {
|
|
|
+ if ((this.modeType === 2&&!this.isCanBack) || (this.modeType === 3&&!this.isCanBack)) {
|
|
|
//动作面板
|
|
|
DialogHelper.showBottomSheetDialog({
|
|
|
title: "请选择排序模式",
|
|
|
@@ -1294,9 +1294,11 @@ export struct LocalMusic {
|
|
|
sheets: [
|
|
|
{ value: '按名称升序', fontColor: $r('app.color.text_color') },
|
|
|
{ value: '按名称降序', fontColor: $r('app.color.text_color') },
|
|
|
+ { value: '按数量升序', fontColor: $r('app.color.text_color') },
|
|
|
+ { value: '按数量降序', fontColor: $r('app.color.text_color') },
|
|
|
],
|
|
|
backgroundColor: $r('app.color.bg_card'),
|
|
|
- height: '30%',
|
|
|
+ height: '45%',
|
|
|
transition: AnimationHelper.transitionInDown(555),
|
|
|
onAction: (index) => {
|
|
|
switch (index) {
|
|
|
@@ -1306,6 +1308,45 @@ export struct LocalMusic {
|
|
|
case 1:
|
|
|
Utility.doSortListDescending(this.videoLocalList,this.isShowFileName)
|
|
|
break;
|
|
|
+ case 2:
|
|
|
+ this.videoLocalList.sort((a: VideoItem, b: VideoItem): number => {
|
|
|
+ // 1. Sort by type first
|
|
|
+ const typeOrder: number = getTypeOrder(a.type) - getTypeOrder(b.type);
|
|
|
+ if (typeOrder !== 0) {
|
|
|
+ return typeOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. Then sort by artist count (numeric comparison)
|
|
|
+ let sortMap:Map<string, VideoItem[]>= new Map<string, VideoItem[]>();
|
|
|
+ if(this.modeType === 2){
|
|
|
+ sortMap = this.artistMap
|
|
|
+ }else{
|
|
|
+ sortMap = this.albumMap
|
|
|
+ }
|
|
|
+ const aArtistCount: number = sortMap.get(a.name)?.length || 0;
|
|
|
+ const bArtistCount: number = sortMap.get(b.name)?.length || 0;
|
|
|
+ return aArtistCount - bArtistCount;
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ this.videoLocalList.sort((a: VideoItem, b: VideoItem): number => {
|
|
|
+ // 1. Sort by type first
|
|
|
+ const typeOrder: number = getTypeOrder(a.type) - getTypeOrder(b.type);
|
|
|
+ if (typeOrder !== 0) {
|
|
|
+ return typeOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ let sortMap:Map<string, VideoItem[]>= new Map<string, VideoItem[]>();
|
|
|
+ if(this.modeType === 2){
|
|
|
+ sortMap = this.artistMap
|
|
|
+ }else{
|
|
|
+ sortMap = this.albumMap
|
|
|
+ }
|
|
|
+ const aArtistCount: number = sortMap.get(a.name)?.length || 0;
|
|
|
+ const bArtistCount: number = sortMap.get(b.name)?.length || 0;
|
|
|
+ return bArtistCount - aArtistCount;
|
|
|
+ });
|
|
|
+ break;
|
|
|
}
|
|
|
this.updateListData(this.videoLocalList)
|
|
|
}
|
|
|
@@ -3238,17 +3279,19 @@ export struct LocalMusic {
|
|
|
})
|
|
|
.onClick(() => {
|
|
|
// ToastUtil.showToast('当前的手机的折叠状态 ='+DisplayUtil.getFoldStatus())
|
|
|
- if (this.modeType === 0) {
|
|
|
- if (ArrayUtil.isNotEmpty(this.getCurFileList())) {
|
|
|
- this.doPlay(this.getCurFileList()[0])
|
|
|
+ if (this.modeType === 0) {
|
|
|
+ const playList = this.getCurFileList();
|
|
|
+ const item = Utility.getPlayItem(playList, this.playType);
|
|
|
+ if (item) { // 显式检查undefined
|
|
|
+ this.doPlay(item);
|
|
|
}
|
|
|
} else {
|
|
|
- if (ArrayUtil.isNotEmpty(this.mediaKuList)) {
|
|
|
- this.doPlay(this.mediaKuList[0])
|
|
|
+ const item = Utility.getPlayItem(this.mediaKuList, this.playType);
|
|
|
+ if (item) {
|
|
|
+ this.doPlay(item);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
})
|
|
|
|
|
|
Row() {
|
|
|
@@ -4866,6 +4909,7 @@ export struct LocalMusic {
|
|
|
}
|
|
|
|
|
|
private doPlay(item: VideoItem, index?: number, isFromSonPlayList?: boolean,isOpen?:boolean) {
|
|
|
+
|
|
|
switch (item.type) {
|
|
|
case CommonConstants.TYPE_IS_DIR:
|
|
|
// 进入歌单前安全保存当前滚动偏移量,支持列表和网格
|