|
@@ -540,35 +540,37 @@ export struct LocalMusic {
|
|
|
|
|
|
|
|
Logger.info('heanup LocalMusic', `onModeChange: 切换模式 modeType=${this.modeType}`);
|
|
Logger.info('heanup LocalMusic', `onModeChange: 切换模式 modeType=${this.modeType}`);
|
|
|
|
|
|
|
|
- // 模式切换时重置分页状态并加载第一页
|
|
|
|
|
- await this.resetAndLoadFirstPage();
|
|
|
|
|
|
|
|
|
|
switch (this.modeType) {
|
|
switch (this.modeType) {
|
|
|
case 0:
|
|
case 0:
|
|
|
// 首页模式已在 resetAndLoadFirstPage 中处理
|
|
// 首页模式已在 resetAndLoadFirstPage 中处理
|
|
|
|
|
+ // 切换模式时加载对应的排序类型
|
|
|
|
|
+ this.sortType = this.loadSortTypeForCurrentMode()
|
|
|
break
|
|
break
|
|
|
case 1:
|
|
case 1:
|
|
|
this.rightTopImage = $r('sys.symbol.sort')
|
|
this.rightTopImage = $r('sys.symbol.sort')
|
|
|
this.titleName = Utility.resourceToString(this.context,$r('app.string.media_ku'))
|
|
this.titleName = Utility.resourceToString(this.context,$r('app.string.media_ku'))
|
|
|
|
|
+ // 切换模式时加载对应的排序类型
|
|
|
|
|
+ this.sortType = this.loadSortTypeForCurrentMode()
|
|
|
break
|
|
break
|
|
|
case 2:
|
|
case 2:
|
|
|
this.rightTopImage = $r('sys.symbol.sort')
|
|
this.rightTopImage = $r('sys.symbol.sort')
|
|
|
- if (this.sortType === 4) {
|
|
|
|
|
- this.sortType = 9
|
|
|
|
|
- PreferencesUtil.putSync(SettingPage.SORT_TYPE, 9)
|
|
|
|
|
- }
|
|
|
|
|
this.titleName = Utility.resourceToString(this.context,$r('app.string.artist'))
|
|
this.titleName = Utility.resourceToString(this.context,$r('app.string.artist'))
|
|
|
|
|
+ // 切换到艺术家模式时,加载艺术家模式的排序类型(默认按数量降序)
|
|
|
|
|
+ this.sortType = this.loadSortTypeForCurrentMode()
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
case 3:
|
|
case 3:
|
|
|
this.rightTopImage = $r('sys.symbol.sort')
|
|
this.rightTopImage = $r('sys.symbol.sort')
|
|
|
- if (this.sortType === 4) {
|
|
|
|
|
- this.sortType = 9
|
|
|
|
|
- PreferencesUtil.putSync(SettingPage.SORT_TYPE, 9)
|
|
|
|
|
- }
|
|
|
|
|
this.titleName = Utility.resourceToString(this.context,$r('app.string.album'))
|
|
this.titleName = Utility.resourceToString(this.context,$r('app.string.album'))
|
|
|
|
|
+ // 切换到专辑模式时,加载专辑模式的排序类型(默认按数量降序)
|
|
|
|
|
+ this.sortType = this.loadSortTypeForCurrentMode()
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
|
|
|
+ // 模式切换时重置分页状态并加载第一页
|
|
|
|
|
+ await this.resetAndLoadFirstPage();
|
|
|
|
|
+
|
|
|
|
|
+ Logger.info('heanup onModeChange', `doSortType: 切换排序方式 sortType=${this.sortType}, mode=${this.modeType}`);
|
|
|
}
|
|
}
|
|
|
// @Consume currentSong: VideoItem | undefined;
|
|
// @Consume currentSong: VideoItem | undefined;
|
|
|
@StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
|
|
@StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
|
|
@@ -2099,7 +2101,8 @@ export struct LocalMusic {
|
|
|
pageIndex,
|
|
pageIndex,
|
|
|
pageSize: this.pageSize,
|
|
pageSize: this.pageSize,
|
|
|
sortType: this.sortType,
|
|
sortType: this.sortType,
|
|
|
- searchKeyword: this.isSearchMode ? this.searchText : undefined
|
|
|
|
|
|
|
+ searchKeyword: this.isSearchMode ? this.searchText : undefined,
|
|
|
|
|
+ isShowFileName: this.isShowFileName
|
|
|
});
|
|
});
|
|
|
if (result.items.length === 0) {
|
|
if (result.items.length === 0) {
|
|
|
break;
|
|
break;
|
|
@@ -2225,12 +2228,45 @@ export struct LocalMusic {
|
|
|
Logger.info('heanup LocalMusic', `doSortType: 切换排序方式 sortType=${index}, mode=${this.modeType}`);
|
|
Logger.info('heanup LocalMusic', `doSortType: 切换排序方式 sortType=${index}, mode=${this.modeType}`);
|
|
|
|
|
|
|
|
this.sortType = index;
|
|
this.sortType = index;
|
|
|
- PreferencesUtil.putSync(SettingPage.SORT_TYPE, index);
|
|
|
|
|
|
|
+ this.saveSortTypeForCurrentMode(index);
|
|
|
|
|
|
|
|
// 分页模式下,排序需要重新从数据库查询
|
|
// 分页模式下,排序需要重新从数据库查询
|
|
|
await this.resetAndLoadFirstPage();
|
|
await this.resetAndLoadFirstPage();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据当前模式保存排序类型到不同的存储键
|
|
|
|
|
+ */
|
|
|
|
|
+ private saveSortTypeForCurrentMode(sortType: number): void {
|
|
|
|
|
+ let storageKey = SettingPage.SORT_TYPE;
|
|
|
|
|
+ if (this.modeType === 2) {
|
|
|
|
|
+ storageKey = 'SORT_TYPE_ARTIST';
|
|
|
|
|
+ } else if (this.modeType === 3) {
|
|
|
|
|
+ storageKey = 'SORT_TYPE_ALBUM';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ storageKey = SettingPage.SORT_TYPE;
|
|
|
|
|
+ }
|
|
|
|
|
+ PreferencesUtil.putSync(storageKey, sortType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据当前模式加载排序类型
|
|
|
|
|
+ */
|
|
|
|
|
+ private loadSortTypeForCurrentMode(): number {
|
|
|
|
|
+ let storageKey = SettingPage.SORT_TYPE;
|
|
|
|
|
+ let defaultSortType = 4;
|
|
|
|
|
+
|
|
|
|
|
+ if (this.modeType === 2) {
|
|
|
|
|
+ storageKey = 'SORT_TYPE_ARTIST';
|
|
|
|
|
+ defaultSortType = 9; // 艺术家模式默认按数量降序
|
|
|
|
|
+ } else if (this.modeType === 3) {
|
|
|
|
|
+ storageKey = 'SORT_TYPE_ALBUM';
|
|
|
|
|
+ defaultSortType = 9; // 专辑模式默认按数量降序
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return PreferencesUtil.getNumberSync(storageKey, defaultSortType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
showSheelDialog() {
|
|
showSheelDialog() {
|
|
|
// if(PreferencesUtil.getBooleanSync('isFirstMusic',true)) {
|
|
// if(PreferencesUtil.getBooleanSync('isFirstMusic',true)) {
|
|
|
// this.showTips()
|
|
// this.showTips()
|
|
@@ -3353,7 +3389,8 @@ export struct LocalMusic {
|
|
|
pageIndex: 0,
|
|
pageIndex: 0,
|
|
|
pageSize: this.totalCount,
|
|
pageSize: this.totalCount,
|
|
|
sortType: this.sortType,
|
|
sortType: this.sortType,
|
|
|
- searchKeyword: this.isSearchMode ? this.searchText : undefined
|
|
|
|
|
|
|
+ searchKeyword: this.isSearchMode ? this.searchText : undefined,
|
|
|
|
|
+ isShowFileName: this.isShowFileName
|
|
|
};
|
|
};
|
|
|
if (this.modeType === 0) {
|
|
if (this.modeType === 0) {
|
|
|
options.parentPath = this.currentPath;
|
|
options.parentPath = this.currentPath;
|
|
@@ -3483,7 +3520,8 @@ export struct LocalMusic {
|
|
|
pageIndex: 0,
|
|
pageIndex: 0,
|
|
|
pageSize: this.totalCount,
|
|
pageSize: this.totalCount,
|
|
|
sortType: this.sortType,
|
|
sortType: this.sortType,
|
|
|
- searchKeyword: this.isSearchMode ? this.searchText : undefined
|
|
|
|
|
|
|
+ searchKeyword: this.isSearchMode ? this.searchText : undefined,
|
|
|
|
|
+ isShowFileName: this.isShowFileName
|
|
|
})
|
|
})
|
|
|
let alphabetSet = new Set<string>()
|
|
let alphabetSet = new Set<string>()
|
|
|
for (let song of result.items) {
|
|
for (let song of result.items) {
|
|
@@ -6632,7 +6670,7 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
let mList = this.artistMap.get(item.name)
|
|
let mList = this.artistMap.get(item.name)
|
|
|
if (mList === undefined || ArrayUtil.isEmpty(mList)) {
|
|
if (mList === undefined || ArrayUtil.isEmpty(mList)) {
|
|
|
- mList = await this.table.querySongsByArtist(item.name, this.sortType);
|
|
|
|
|
|
|
+ mList = await this.table.querySongsByArtist(item.name, this.sortType, this.isShowFileName);
|
|
|
if (ArrayUtil.isNotEmpty(mList)) {
|
|
if (ArrayUtil.isNotEmpty(mList)) {
|
|
|
this.artistMap.set(item.name, mList);
|
|
this.artistMap.set(item.name, mList);
|
|
|
}
|
|
}
|
|
@@ -6704,7 +6742,7 @@ export struct LocalMusic {
|
|
|
}
|
|
}
|
|
|
let albumList = this.albumMap.get(item.name)
|
|
let albumList = this.albumMap.get(item.name)
|
|
|
if (albumList === undefined || ArrayUtil.isEmpty(albumList)) {
|
|
if (albumList === undefined || ArrayUtil.isEmpty(albumList)) {
|
|
|
- albumList = await this.table.querySongsByAlbum(item.name, this.sortType);
|
|
|
|
|
|
|
+ albumList = await this.table.querySongsByAlbum(item.name, this.sortType, this.isShowFileName);
|
|
|
if (ArrayUtil.isNotEmpty(albumList)) {
|
|
if (ArrayUtil.isNotEmpty(albumList)) {
|
|
|
this.albumMap.set(item.name, albumList);
|
|
this.albumMap.set(item.name, albumList);
|
|
|
}
|
|
}
|
|
@@ -7094,7 +7132,8 @@ export struct LocalMusic {
|
|
|
pageIndex: pageIndex,
|
|
pageIndex: pageIndex,
|
|
|
pageSize: this.pageSize,
|
|
pageSize: this.pageSize,
|
|
|
sortType: this.sortType,
|
|
sortType: this.sortType,
|
|
|
- searchKeyword: this.isSearchMode ? this.searchText : undefined
|
|
|
|
|
|
|
+ searchKeyword: this.isSearchMode ? this.searchText : undefined,
|
|
|
|
|
+ isShowFileName: this.isShowFileName
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 根据 modeType 补充查询条件
|
|
// 根据 modeType 补充查询条件
|
|
@@ -7215,7 +7254,8 @@ export struct LocalMusic {
|
|
|
pageIndex: nextPage,
|
|
pageIndex: nextPage,
|
|
|
pageSize: this.pageSize,
|
|
pageSize: this.pageSize,
|
|
|
sortType: this.sortType,
|
|
sortType: this.sortType,
|
|
|
- searchKeyword: this.isSearchMode ? this.searchText : undefined
|
|
|
|
|
|
|
+ searchKeyword: this.isSearchMode ? this.searchText : undefined,
|
|
|
|
|
+ isShowFileName: this.isShowFileName
|
|
|
};
|
|
};
|
|
|
let result: PageQueryResult = { items: [], totalCount: 0, hasMore: false };
|
|
let result: PageQueryResult = { items: [], totalCount: 0, hasMore: false };
|
|
|
if (this.modeType === 2) {
|
|
if (this.modeType === 2) {
|