|
|
@@ -167,7 +167,7 @@ export struct LocalMusic {
|
|
|
@State artistMap: Map<string, VideoItem[]> = new Map(); //艺术家Map
|
|
|
@State albumList: Array<VideoItem> = []; //专辑文件
|
|
|
@State albumMap: Map<string, VideoItem[]> = new Map(); //专辑Map
|
|
|
- private albumScrollMap: Map<string, number> = new Map(); // 专辑名->滚动index
|
|
|
+ private mScrollMap: Map<string, number> = new Map(); // 艺术家、专辑名->滚动index
|
|
|
@State imageOpacities: number[] = [];
|
|
|
@Consume isCanBack: boolean
|
|
|
@Consume @Watch('onModeChange') modeType: number; // 0首页,1媒体库,2艺术家,3专辑
|
|
|
@@ -386,13 +386,24 @@ export struct LocalMusic {
|
|
|
this.titleBarModel.setLeftIconMain($r('app.media.menu'))
|
|
|
// 返回专辑列表时恢复滚动偏移量,支持列表和网格
|
|
|
setTimeout(() => {
|
|
|
- if (this.isGridMusic) {
|
|
|
- let lastOffset = this.albumScrollMap.get('lastGridScrollOffset') ?? 0
|
|
|
- this.scroller.scrollTo({ xOffset: 0, yOffset: lastOffset })
|
|
|
- } else {
|
|
|
- let lastOffset = this.albumScrollMap.get('lastListScrollOffset') ?? 0
|
|
|
- this.listScroller.scrollTo({ xOffset: 0, yOffset: lastOffset })
|
|
|
+ if(this.modeType ==2){
|
|
|
+ if (this.isGridMusic) {
|
|
|
+ let lastOffset = this.mScrollMap.get('lastGridArtistScrollOffset') ?? 0
|
|
|
+ this.scroller.scrollTo({ xOffset: 0, yOffset: lastOffset })
|
|
|
+ } else {
|
|
|
+ let lastOffset = this.mScrollMap.get('lastListArtistScrollOffset') ?? 0
|
|
|
+ this.listScroller.scrollTo({ xOffset: 0, yOffset: lastOffset })
|
|
|
+ }
|
|
|
+ }else if(this.modeType ==3){
|
|
|
+ if (this.isGridMusic) {
|
|
|
+ let lastOffset = this.mScrollMap.get('lastGridAlBumScrollOffset') ?? 0
|
|
|
+ this.scroller.scrollTo({ xOffset: 0, yOffset: lastOffset })
|
|
|
+ } else {
|
|
|
+ let lastOffset = this.mScrollMap.get('lastListAlBumScrollOffset') ?? 0
|
|
|
+ this.listScroller.scrollTo({ xOffset: 0, yOffset: lastOffset })
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}, 200)
|
|
|
return
|
|
|
}
|
|
|
@@ -3802,6 +3813,25 @@ export struct LocalMusic {
|
|
|
}
|
|
|
break;
|
|
|
case CommonConstants.TYPE_IS_ARTIST:
|
|
|
+ // 进入专辑前安全保存当前滚动偏移量,支持列表和网格
|
|
|
+ let offsetA = 0
|
|
|
+ if (this.isGridMusic) {
|
|
|
+ if (this.scroller && typeof this.scroller.currentOffset === 'function') {
|
|
|
+ let cur = this.scroller.currentOffset()
|
|
|
+ if (cur && typeof cur.yOffset === 'number') {
|
|
|
+ offsetA = cur.yOffset
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.mScrollMap.set('lastGridArtistScrollOffset', offsetA)
|
|
|
+ } else {
|
|
|
+ if (this.listScroller && typeof this.listScroller.currentOffset === 'function') {
|
|
|
+ let cur = this.listScroller.currentOffset()
|
|
|
+ if (cur && typeof cur.yOffset === 'number') {
|
|
|
+ offsetA = cur.yOffset
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.mScrollMap.set('lastListArtistScrollOffset', offsetA)
|
|
|
+ }
|
|
|
let mList = this.artistMap.get(item.name)
|
|
|
if (mList !== undefined && ArrayUtil.isNotEmpty(mList)) {
|
|
|
Utility.doSortListAscending(mList)
|
|
|
@@ -3822,7 +3852,7 @@ export struct LocalMusic {
|
|
|
offset = cur.yOffset
|
|
|
}
|
|
|
}
|
|
|
- this.albumScrollMap.set('lastGridScrollOffset', offset)
|
|
|
+ this.mScrollMap.set('lastGridAlBumScrollOffset', offset)
|
|
|
} else {
|
|
|
if (this.listScroller && typeof this.listScroller.currentOffset === 'function') {
|
|
|
let cur = this.listScroller.currentOffset()
|
|
|
@@ -3830,7 +3860,7 @@ export struct LocalMusic {
|
|
|
offset = cur.yOffset
|
|
|
}
|
|
|
}
|
|
|
- this.albumScrollMap.set('lastListScrollOffset', offset)
|
|
|
+ this.mScrollMap.set('lastListAlBumScrollOffset', offset)
|
|
|
}
|
|
|
let albumList = this.albumMap.get(item.name)
|
|
|
if (albumList !== undefined && ArrayUtil.isNotEmpty(albumList)) {
|
|
|
@@ -3839,7 +3869,7 @@ export struct LocalMusic {
|
|
|
this.titleBarModel.setTitleName(item.name)
|
|
|
this.updateListData(albumList)
|
|
|
this.titleBarModel.setLeftIconMain($r('app.media.left_back_white'))
|
|
|
- this.albumScrollMap.set(item.name, this.selectedIndex)
|
|
|
+ this.mScrollMap.set(item.name, this.selectedIndex)
|
|
|
}
|
|
|
|
|
|
break;
|