Просмотр исходного кода

网格模式下长按菜单样式更改,用bindContextMenu实现,bindContextMenu实现有MenuPreviewMode.IMAGE效果:控制长按预览的显示效果。修复长按菜单之前不能读取内嵌歌词

onecold 1 год назад
Родитель
Сommit
903810b17c
2 измененных файлов с 330 добавлено и 217 удалено
  1. 329 216
      entry/src/main/ets/view/LocalMusic.ets
  2. 1 1
      entry/src/main/resources/base/element/string.json

+ 329 - 216
entry/src/main/ets/view/LocalMusic.ets

@@ -2540,8 +2540,28 @@ export struct LocalMusic {
             .alt($r('app.media.music_red'))
             .borderRadius('100%')
             .clip(true)
+            .draggable(false)
+            .interpolation(ImageInterpolation.Medium)// 用于重采样后的抗锯齿
+            .autoResize(true) // 重采样,可减少内存占用
             .opacity(this.opacityItem)// 绑定透明度
             .margin({ left: 20 })
+            .gesture(LongPressGesture()
+              .onAction(async () => {
+                //如果是专辑和艺术家的首页,不能长按
+                if((this.modeType===2||this.modeType==3)&&!this.isCanBack)
+                  return
+                //如果是我的收藏 最近播放等也不能长按
+                if(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+                  item.name === LocalMusic.STR_HISTORY_MUSIC
+                )
+                  return
+                this.longItemFilePath = item.filePath
+                this.tempLyricContent = await this.getLyricContent(item)
+                LogUtil.info('长按this.tempLyricContent = '+this.tempLyricContent)
+              })
+              .onActionEnd((event: GestureEvent) => {
+
+              }))
         }
 
 
@@ -3423,6 +3443,16 @@ export struct LocalMusic {
             this.MusicItemGrid(item, index)
           }
         }
+        .bindContextMenu(this.MenuBuilder(item, index, item.filePath), ResponseType.LongPress,
+          {
+            preview: MenuPreviewMode.IMAGE,
+            previewAnimationOptions: { scale: [0.8, 1.0] },
+          })
+        .bindContextMenu(this.MenuBuilder(item, index, item.filePath), ResponseType.RightClick,
+          {
+            preview: MenuPreviewMode.IMAGE,
+            previewAnimationOptions: { scale: [0.8, 1.0] },
+          })
         .transition(TransitionEffect.asymmetric(TransitionEffect.scale({ x: 0.8, y: 0.8 }).animation({ duration: 500 }),
           TransitionEffect.scale({ x: 0, y: 0 })))
         .clickEffect({ level: ClickEffectLevel.LIGHT })
@@ -3431,66 +3461,66 @@ export struct LocalMusic {
         .translate(this.dragItem === index ? { x: this.offsetX, y: this.offsetY } : { x: 0, y: 0 })
         .hitTestBehavior(this.isDraggable(this.videoLocalList.indexOf(item)) ? HitTestMode.Default : HitTestMode.None)
         //长按拖动代码
-        .gesture(
-          GestureGroup(GestureMode.Sequence,
-            LongPressGesture({ repeat: true })
-              .onAction(() => {
-                this.getUIContext().animateTo({ curve: Curve.Friction, duration: 300 }, () => {
-                  this.scaleItem = index;
-                })
-              })
-              .onActionEnd(() => {
-                this.getUIContext().animateTo({ curve: Curve.Friction, duration: 300 }, () => {
-                  this.scaleItem = -1;
-                })
-              }),
-            PanGesture({ fingers: 1, direction: null, distance: 0 })
-              .onActionStart(() => {
-                this.dragItem = index;
-                this.dragRefOffSetX = 0;
-                this.dragRefOffSetY = 0;
-              })
-              .onActionUpdate((event: GestureEvent) => {
-                this.offsetX = event.offsetX - this.dragRefOffSetX;
-                this.offsetY = event.offsetY - this.dragRefOffSetY;
-                this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-                  let index = this.videoLocalList.indexOf(item);
-                  if (this.offsetY >= this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)) {
-                    this.down(index);
-                  } else if (this.offsetY <= -this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)) {
-                    this.up(index);
-                  } else if (this.offsetX >= this.FIX_VP_X / 2 && (this.offsetY <= 50 && this.offsetY >= -50)) {
-                    this.right(index);
-                  } else if (this.offsetX <= -this.FIX_VP_Y / 2 && (this.offsetY <= 50 && this.offsetY >= -50)) {
-                    this.left(index);
-                  }
-                })
-
-
-                // if (this.offsetY > this.FIX_VP_Y * 0.7) {
-                //   this.scroller.scrollToIndex(index + 10, true,ScrollAlign.CENTER);
-                // }
-
-
-              })
-              .onActionEnd(() => {
-                this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-                  this.dragItem = -1;
-                })
-                this.getUIContext().animateTo({ curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150 }, () => {
-                  this.scaleItem = -1;
-                })
-              })
-          )
-            .onCancel(() => {
-              this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
-                this.dragItem = -1;
-              })
-              this.getUIContext().animateTo({ curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150 }, () => {
-                this.scaleItem = -1;
-              })
-            })
-        )
+        // .gesture(
+        //   GestureGroup(GestureMode.Sequence,
+        //     LongPressGesture({ repeat: true })
+        //       .onAction(() => {
+        //         this.getUIContext().animateTo({ curve: Curve.Friction, duration: 300 }, () => {
+        //           this.scaleItem = index;
+        //         })
+        //       })
+        //       .onActionEnd(() => {
+        //         this.getUIContext().animateTo({ curve: Curve.Friction, duration: 300 }, () => {
+        //           this.scaleItem = -1;
+        //         })
+        //       }),
+        //     PanGesture({ fingers: 1, direction: null, distance: 0 })
+        //       .onActionStart(() => {
+        //         this.dragItem = index;
+        //         this.dragRefOffSetX = 0;
+        //         this.dragRefOffSetY = 0;
+        //       })
+        //       .onActionUpdate((event: GestureEvent) => {
+        //         this.offsetX = event.offsetX - this.dragRefOffSetX;
+        //         this.offsetY = event.offsetY - this.dragRefOffSetY;
+        //         this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
+        //           let index = this.videoLocalList.indexOf(item);
+        //           if (this.offsetY >= this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)) {
+        //             this.down(index);
+        //           } else if (this.offsetY <= -this.FIX_VP_Y / 2 && (this.offsetX <= 44 && this.offsetX >= -44)) {
+        //             this.up(index);
+        //           } else if (this.offsetX >= this.FIX_VP_X / 2 && (this.offsetY <= 50 && this.offsetY >= -50)) {
+        //             this.right(index);
+        //           } else if (this.offsetX <= -this.FIX_VP_Y / 2 && (this.offsetY <= 50 && this.offsetY >= -50)) {
+        //             this.left(index);
+        //           }
+        //         })
+        //
+        //
+        //         // if (this.offsetY > this.FIX_VP_Y * 0.7) {
+        //         //   this.scroller.scrollToIndex(index + 10, true,ScrollAlign.CENTER);
+        //         // }
+        //
+        //
+        //       })
+        //       .onActionEnd(() => {
+        //         this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
+        //           this.dragItem = -1;
+        //         })
+        //         this.getUIContext().animateTo({ curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150 }, () => {
+        //           this.scaleItem = -1;
+        //         })
+        //       })
+        //   )
+        //     .onCancel(() => {
+        //       this.getUIContext().animateTo({ curve: curves.interpolatingSpring(0, 1, 400, 38) }, () => {
+        //         this.dragItem = -1;
+        //       })
+        //       this.getUIContext().animateTo({ curve: curves.interpolatingSpring(14, 1, 170, 17), delay: 150 }, () => {
+        //         this.scaleItem = -1;
+        //       })
+        //     })
+        // )
 
         // [End gesture_start]
         // [EndExclude GridItem_start]
@@ -3625,6 +3655,9 @@ export struct LocalMusic {
           Image(StrUtil.isEmpty(item.pixelMapPath) ? Utility.getMusisBg2(index) : item.pixelMapPath)
             .height(this.getGridHeight())
             .width(this.getGridWight())
+            .draggable(false)
+            .interpolation(ImageInterpolation.Medium)// 用于重采样后的抗锯齿
+            .autoResize(true) // 重采样,可减少内存占用
             .alt($r('app.media.ic_avatar2'))
             .clip(true)
             .borderRadius({
@@ -3633,6 +3666,17 @@ export struct LocalMusic {
               bottomLeft: 0,
               bottomRight: 0
             })
+            .bindSheet(this.longItemFilePath== item.filePath, this.editSheet(item), {
+              height: this.isCoverOpacity() ? '95%' : '88%',
+              dragBar: true,
+              onDisappear: () => {
+                this.longItemFilePath = '';
+                this.tempLyricContent = ''
+              },
+              showClose: true,
+              preferType: SheetType.CENTER ,
+              title: { title: '编辑信息' }
+            })
             .draggable(false)
             .opacity(this.opacityItem)// 绑定透明度
             // .transition(TransitionEffect.move(TransitionEdge.BOTTOM)
@@ -3655,6 +3699,18 @@ export struct LocalMusic {
                 duration: 555,
                 curve: 'Linear',
               })
+              .bindSheet(this.longItemFilePathDetail== item.filePath, this.detailSheet(item), {
+                height:  '95%',
+                dragBar: true,
+                showClose: true,
+                onDisappear: () => {
+                  this.longItemFilePathDetail = '';
+                },
+                blurStyle:BlurStyle.Thin,
+                backgroundColor:Color.Transparent,
+                preferType: SheetType.CENTER ,
+                title: { title: '详情' }
+              })
               .fontColor(this.currentSong?.filePath === item.filePath ? this.themeColor :
               $r('app.color.text_color'))
 
@@ -3704,42 +3760,43 @@ export struct LocalMusic {
             .alignItems(HorizontalAlign.Center) // 关键:使内容水平居中
 
           }
-          .bindPopup(this.longItemFilePath === item.filePath, {
-            builder: this.MenuBuilder(item, index, item.filePath),
-            placement: Placement.Top,
-            // autoCancel: true,
-            mask: { color: '#33000000' },
-            // popupColor: Color.Yellow,
-            enableArrow: false, //是否显示箭头
-            showInSubWindow: false,
-            onStateChange: (e) => {
-              if (!e.isVisible) {
-                this.longItemFilePath = ''
-                this.tempLyricContent = ''
-              }
-            }
-          })
 
-          .gesture(LongPressGesture()
-            .onAction(async () => {
-              //如果是专辑和艺术家的首页,不能长按
-              if ((this.modeType === 2 || this.modeType == 3) && !this.isCanBack) {
-                return
-              }
-              //如果是我的收藏 最近播放等也不能长按
-              if (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
-                item.name === LocalMusic.STR_HISTORY_MUSIC
-              ) {
-                return
-              }
-              this.longItemFilePath = item.filePath
-              this.tempLyricContent = await this.getLyricContent(item)
-              LogUtil.info('长按this.tempLyricContent = ' + this.tempLyricContent)
-            })
-            .onActionEnd((event: GestureEvent) => {
-
-            })
-          )
+          // .bindPopup(this.longItemFilePath === item.filePath, {
+          //   builder: this.MenuBuilder(item, index, item.filePath),
+          //   placement: Placement.Top,
+          //   // autoCancel: true,
+          //   mask: { color: '#33000000' },
+          //   // popupColor: Color.Yellow,
+          //   enableArrow: false, //是否显示箭头
+          //   showInSubWindow: false,
+          //   onStateChange: (e) => {
+          //     if (!e.isVisible) {
+          //       this.longItemFilePath = ''
+          //       this.tempLyricContent = ''
+          //     }
+          //   }
+          // })
+          //
+          // .gesture(LongPressGesture()
+          //   .onAction(async () => {
+          //     //如果是专辑和艺术家的首页,不能长按
+          //     if ((this.modeType === 2 || this.modeType == 3) && !this.isCanBack) {
+          //       return
+          //     }
+          //     //如果是我的收藏 最近播放等也不能长按
+          //     if (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+          //       item.name === LocalMusic.STR_HISTORY_MUSIC
+          //     ) {
+          //       return
+          //     }
+          //     this.longItemFilePath = item.filePath
+          //     this.tempLyricContent = await this.getLyricContent(item)
+          //     LogUtil.info('长按this.tempLyricContent = ' + this.tempLyricContent)
+          //   })
+          //   .onActionEnd((event: GestureEvent) => {
+          //
+          //   })
+          // )
           .height(this.twoFingerType == 3 ? 60 : this.twoFingerType == 2 ? 55 : 42)
           .width(this.getGridWight())
           .justifyContent(FlexAlign.Center)
@@ -3837,108 +3894,134 @@ export struct LocalMusic {
     return wightG
   }
   @State isShowDetail:boolean = false
+  // @State isShowDetailGrid:boolean = false
+  // @State isShowEditGrid:boolean = false
+  @State longItemFilePathDetail:string =''
   @Builder
   MenuBuilder(item: VideoItem, index: number, filePath: string) {
-    Scroll() {
-      Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
-        Menu() {
-          MenuItem({
-            symbolStartIcon: new SymbolGlyphModifier(Utility.getIsFav(this.favList, item) ?
-            $r('sys.symbol.heart_fill') : $r('sys.symbol.heart')),
+    if(
+      ((this.modeType===2||this.modeType==3)&&!this.isCanBack)
+      ||(item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+        item.name === LocalMusic.STR_HISTORY_MUSIC)
+    ){
+      //如果是专辑和艺术家的首页,不能长按
+      //如果是我的收藏 最近播放等也不能长按
+    }else{
 
-            content: Utility.getIsFav(this.favList, item) ? '取消收藏' : '收藏'
-          })
-            .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
-            .onClick(() => {
-              if (item) {
-                this.doFav(item)
-              }
-              this.longItemFilePath = ''
+      Scroll() {
+        Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
+          Menu() {
+            MenuItem({
+              symbolStartIcon: new SymbolGlyphModifier(Utility.getIsFav(this.favList, item) ?
+              $r('sys.symbol.heart_fill') : $r('sys.symbol.heart')),
 
+              content: Utility.getIsFav(this.favList, item) ? '取消收藏' : '收藏'
             })
-          MenuItem({
-            symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.forward_end_fill')),
-            content: '下一首播放'
-          })
-            .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
-            .onClick(() => {
-              this.addToNextPlay(item);
-              this.longItemFilePath = ''
-            })
+              .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
+              .onClick(() => {
+                if (item) {
+                  this.doFav(item)
+                }
+                this.longItemFilePath = ''
 
-          MenuItem({
-            symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.square_and_pencil')),
-            content: '编辑信息'
-          })
-            .bindSheet($$this.isShowEdit, this.editSheet(item), {
-              height: this.isCoverOpacity() ? '95%' : '88%',
-              dragBar: true,
-              showClose: true,
-              preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
-              title: { title: '编辑信息' }
+              })
+            MenuItem({
+              symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.forward_end_fill')),
+              content: '下一首播放'
             })
-            .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
-            .onClick(() => {
-              this.isShowEdit = !this.isShowEdit;
+              .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
+              .onClick(() => {
+                this.addToNextPlay(item);
+                this.longItemFilePath = ''
+              })
+
+            MenuItem({
+              symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.square_and_pencil')),
+              content: '编辑信息'
             })
+              .bindSheet($$this.isShowEdit, this.editSheet(item), {
+                height: this.isCoverOpacity() ? '95%' : '88%',
+                dragBar: true,
+                showClose: true,
+                preferType: SheetType.CENTER ,
+                title: { title: '编辑信息' }
+              })
+              .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
+              .onClick(async() => {
+                this.tempLyricContent = await this.getLyricContent(item);
+                // console.info('onecold 长按this.tempLyricContent' +this.tempLyricContent)
+                if(this.isGridMusic){
+                  this.longItemFilePath = item.filePath
+                }else{
+                  this.isShowEdit = !this.isShowEdit;
+                }
 
-          MenuItem({
-            symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.rename')),
-            content: $r('app.string.rename')
-          })
-            .visibility(item.type === CommonConstants.TYPE_IS_DIR ?
-              (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
-                item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
-            .onClick(() => {
-              this.showReNameDialog(item, index + '', filePath)
-              this.longItemFilePath = ''
+              })
+
+            MenuItem({
+              symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.rename')),
+              content: $r('app.string.rename')
             })
-          MenuItem({
-            symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.trash')),
-            content: $r('app.string.delete')
-          })
-            .visibility(item.type === CommonConstants.TYPE_IS_DIR ?
-              (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
-                item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
-            .onClick(() => {
-              this.showWarnIsDeleteFile(item, index + '', filePath)
-              this.longItemFilePath = ''
+              .visibility(item.type === CommonConstants.TYPE_IS_DIR ?
+                (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+                  item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
+              .onClick(() => {
+                this.showReNameDialog(item, index + '', filePath)
+                this.longItemFilePath = ''
+              })
+            MenuItem({
+              symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.trash')),
+              content: $r('app.string.delete')
             })
+              .visibility(item.type === CommonConstants.TYPE_IS_DIR ?
+                (item.name === LocalMusic.STR_LOCK_VIDEO || item.name === LocalMusic.STR_FAC_VIDEO ||
+                  item.name === LocalMusic.STR_HISTORY_MUSIC ? Visibility.None : Visibility.Visible) : Visibility.Visible)
+              .onClick(() => {
+                this.showWarnIsDeleteFile(item, index + '', filePath)
+                this.longItemFilePath = ''
+              })
 
-          MenuItem({
-            symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.info_circle')),
-            content: $r('app.string.detail')
-          })
-            .bindSheet($$this.isShowDetail, this.detailSheet(item), {
-              height:this.isCoverOpacity()?'95%': '95%',
-              dragBar: true,
-              showClose: true,
-              blurStyle:BlurStyle.Thin,
-              preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
-              backgroundColor:Color.Transparent,
-              title: { title: '详情信息' }
-            })
-            .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
-            .onClick(() => {
-              this.isShowDetail = !this.isShowDetail
+            MenuItem({
+              symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.info_circle')),
+              content: $r('app.string.detail')
             })
+              .bindSheet($$this.isShowDetail, this.detailSheet(item), {
+                height:'95%',
+                dragBar: true,
+                showClose: true,
+                blurStyle:BlurStyle.Thin,
+                preferType: this.currentBreakpoint !== BreakpointTypeEnum.SM ? SheetType.CENTER : SheetType.BOTTOM,
+                backgroundColor:Color.Transparent,
+                title: { title: '详情信息' }
+              })
+              .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
+              .onClick(() => {
+                if(this.isGridMusic){
+                  this.longItemFilePathDetail = item.filePath
+                }else{
+                  this.isShowDetail = !this.isShowDetail
+                }
 
-          MenuItem({
-            symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.share')),
-            content: $r('app.string.share')
-          })
-            .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
-            .onClick(() => {
-              Utility.doShareMusic(item, getContext(this) as common.UIAbilityContext)
-              this.longItemFilePath = ''
+              })
+
+            MenuItem({
+              symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.share')),
+              content: $r('app.string.share')
             })
+              .visibility(item.type === CommonConstants.TYPE_IS_DIR ? Visibility.None : Visibility.Visible)
+              .onClick(() => {
+                Utility.doShareMusic(item, getContext(this) as common.UIAbilityContext)
+                this.longItemFilePath = ''
+              })
 
+          }
+          .font({ size: 15, weight: FontWeight.Normal })
         }
-        .font({ size: 15, weight: FontWeight.Normal })
+        .width(180)
       }
-      .width(180)
+      .height('auto')
     }
-    .height(item.type === CommonConstants.TYPE_IS_DIR ? 150 : 400)
+
   }
 
   private listMaxScrollOffsetY: number = 0
@@ -4717,7 +4800,12 @@ export struct LocalMusic {
 
     this.table.updateMediaInfo(item.filePath, this.titleStr, this.artistStr, this.ablumStr,
       (success: boolean, error?: string) => {
-        this.isShowEdit = false
+        // this.isShowEdit = false
+        if(this.isGridMusic){
+          this.longItemFilePath =''
+        }else{
+          this.isShowEdit = false
+        }
         if (success) {
           console.log(" onecold 编辑信息成功,数据库已同步");
           ToastUtil.showToast('保存成功')
@@ -4967,7 +5055,6 @@ export struct LocalMusic {
             .margin({ right: 20, bottom: 20 })
             .onClick(async () => {
               this.doEdit(item)
-
             })
 
           Button('取消')
@@ -4979,7 +5066,12 @@ export struct LocalMusic {
             .stateEffect(true)
             .margin({ left: 20, bottom: 20 })
             .onClick(async () => {
-              this.isShowEdit = false
+
+              if(this.isGridMusic){
+                this.longItemFilePath =''
+              }else{
+                this.isShowEdit = false
+              }
             })
         }
         .margin({
@@ -5067,11 +5159,11 @@ export struct LocalMusic {
         Row() {
           Text('歌手名:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem?.artist ? currentItem.artist : '未知歌手')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 10 })
             .layoutWeight(1)
 
@@ -5084,12 +5176,12 @@ export struct LocalMusic {
         Row() {
           Text('专辑名:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem?.album ?currentItem.album : '未知专辑')
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5099,13 +5191,13 @@ export struct LocalMusic {
         Row() {
           Text('时长:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(StrUtil.isEmpty(currentItem.duration)?
             (this.isShowDetailMore?this.totalTime:'未知'):currentItem.duration)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5115,12 +5207,12 @@ export struct LocalMusic {
         Row() {
           Text('采样率:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(Utility.convertToKHz(currentItem.sampleRate))
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5130,12 +5222,12 @@ export struct LocalMusic {
         Row() {
           Text('比特率:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.bit_rate)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5145,12 +5237,12 @@ export struct LocalMusic {
         Row() {
           Text('风格:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.genre)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5160,12 +5252,12 @@ export struct LocalMusic {
         Row() {
           Text('发行时间:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.year)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5175,12 +5267,12 @@ export struct LocalMusic {
         Row() {
           Text('质量评分:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.probe_score+"")
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5190,12 +5282,12 @@ export struct LocalMusic {
         Row() {
           Text('音轨号:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.track)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5206,12 +5298,12 @@ export struct LocalMusic {
         Row() {
           Text('格式:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(Utility.formatMimeType(currentItem.mimeType))
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5221,12 +5313,12 @@ export struct LocalMusic {
         Row() {
           Text('播放次数:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.playCount?.toString())
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5238,12 +5330,12 @@ export struct LocalMusic {
         Row() {
           Text('流数量:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.nb_streams?.toString())
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5253,12 +5345,12 @@ export struct LocalMusic {
         Row() {
           Text('文件大小:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.size)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5268,12 +5360,12 @@ export struct LocalMusic {
         Row() {
           Text('文件名:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.fileName)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5283,12 +5375,12 @@ export struct LocalMusic {
         Row() {
           Text('修改时间:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.cTime)
             .fontSize(14)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .width('100%')
@@ -5298,12 +5390,12 @@ export struct LocalMusic {
         Row() {
           Text('存放目录:')
             .fontSize(14)
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .margin({ left: 22 })
           Text(currentItem.filePath)
             .fontSize(12)
             .margin({ left: 10 })
-            .fontColor(Color.White)
+            .fontColor($r('app.color.text_color'))
             .layoutWeight(1)
         }
         .margin({ top: 10, bottom: 10 })
@@ -6595,6 +6687,12 @@ export struct LocalMusic {
 
   //根据item返回歌词内容
   async getLyricContent(item: VideoItem): Promise<string> {
+    let neiqianLrc = ''
+    let lyContent = item?.lyricContent
+    if(lyContent&&StrUtil.isNotEmpty(lyContent)){//取数据库里面的歌词lyContent
+      neiqianLrc = lyContent
+      return neiqianLrc
+    }
     try {
       let filePath = item.filePath;
       let lyricPath = filePath.substring(0, filePath.lastIndexOf('.')) + '.lrc';
@@ -7029,6 +7127,12 @@ export struct LocalMusic {
         .onClick(async () => {
           this.playPrevious()
         })
+        .onKeyEvent((event: KeyEvent) => {
+          if ((event.keyCode === KeyCode.KEYCODE_DPAD_LEFT && event.type === KeyType.Down)) {
+            this.playPrevious()
+          }
+        })
+        .defaultFocus(true) // 自动获取键盘焦点
         .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
         .backgroundColor(Color.Transparent)
         .margin({ left: 5 })
@@ -7048,8 +7152,13 @@ export struct LocalMusic {
             .onClick(async () => {
               this.playOrPause()
 
-
             })
+            .onKeyEvent((event: KeyEvent) => {
+              if ((event.keyCode === KeyCode.KEYCODE_SPACE && event.type === KeyType.Down)) {
+                this.playOrPause()
+              }
+            })
+            .defaultFocus(true) // 自动获取键盘焦点
         }
 
       }
@@ -7065,10 +7174,14 @@ export struct LocalMusic {
             .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
             .aspectRatio(CommonConstants.ASPECT_RATIO)
             .onClick(() => {
-
               this.playNext();
-
             })
+            .onKeyEvent((event: KeyEvent) => {
+              if ((event.keyCode === KeyCode.KEYCODE_DPAD_RIGHT && event.type === KeyType.Down)) {
+                this.playNext()
+              }
+            })
+            .defaultFocus(true) // 自动获取键盘焦点
         }
         .backgroundColor(Color.Transparent)
         .margin({ right: 5 })

+ 1 - 1
entry/src/main/resources/base/element/string.json

@@ -446,7 +446,7 @@
     },
     {
       "name": "sync_tips",
-      "value": "如果你在系统的文件管理删除了音乐媒体文件,可以使用校正数据来删除校正对于的数据库。"
+      "value": "如果你在系统的文件管理删除了音乐媒体文件,可以使用校正数据来删除校正对应的数据。"
     },
     {
       "name": "sync_dataing",