|
|
@@ -167,6 +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
|
|
|
@State imageOpacities: number[] = [];
|
|
|
@Consume isCanBack: boolean
|
|
|
@Consume @Watch('onModeChange') modeType: number; // 0首页,1媒体库,2艺术家,3专辑
|
|
|
@@ -383,6 +384,11 @@ export struct LocalMusic {
|
|
|
this.onModeChange()
|
|
|
this.isCanBack = false
|
|
|
this.titleBarModel.setLeftIconMain($r('app.media.menu'))
|
|
|
+ // 返回专辑列表时恢复滚动偏移量
|
|
|
+ setTimeout(() => {
|
|
|
+ let lastOffset = this.albumScrollMap.get('lastScrollOffset') ?? 0
|
|
|
+ this.listScroller.scrollTo({ xOffset: 0, yOffset: lastOffset })
|
|
|
+ }, 200)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -1609,7 +1615,7 @@ export struct LocalMusic {
|
|
|
FileUtil.unlink(filePath)
|
|
|
.catch((error: BusinessError) => {
|
|
|
console.error(error.message);
|
|
|
- // 可以根据 error.code 判断是否为“文件不存在”,如需特殊处理
|
|
|
+ // 可以根据 error.code 判断是否为"文件不存在",如需特殊处理
|
|
|
})
|
|
|
.finally(() => {
|
|
|
this.videoLocalList.splice(Number(index), 1)
|
|
|
@@ -3723,7 +3729,7 @@ export struct LocalMusic {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- //这个方法没隐藏bottomBar,只隐藏topBar
|
|
|
+ //这个方法没隐藏bottomBar,只隐藏topbar
|
|
|
setBarHeightHide2(offset: number){
|
|
|
if (offset > 0 && !this.hideDone) {
|
|
|
this.currentYOffset += offset;
|
|
|
@@ -3793,6 +3799,15 @@ export struct LocalMusic {
|
|
|
|
|
|
break;
|
|
|
case CommonConstants.TYPE_IS_ALBUM:
|
|
|
+ // 进入专辑前安全保存当前滚动偏移量,防止currentOffset为undefined导致崩溃
|
|
|
+ let offset = 0
|
|
|
+ if (this.listScroller && typeof this.listScroller.currentOffset === 'function') {
|
|
|
+ let cur = this.listScroller.currentOffset()
|
|
|
+ if (cur && typeof cur.yOffset === 'number') {
|
|
|
+ offset = cur.yOffset
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.albumScrollMap.set('lastScrollOffset', offset)
|
|
|
let albumList = this.albumMap.get(item.name)
|
|
|
if (albumList !== undefined && ArrayUtil.isNotEmpty(albumList)) {
|
|
|
Utility.doSortListAscending(albumList)
|
|
|
@@ -3800,6 +3815,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)
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
@@ -4553,7 +4569,6 @@ export struct LocalMusic {
|
|
|
this.TimeClose()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
.width('100%')
|
|
|
.height('100%')
|
|
|
}
|
|
|
@@ -4626,10 +4641,6 @@ export struct LocalMusic {
|
|
|
.width('100%')
|
|
|
.padding(16)
|
|
|
}
|
|
|
-
|
|
|
- // .width('100%')
|
|
|
- // .height('100%')
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 获取显示文本
|