فهرست منبع

优化歌词代码和Navidrome的默认封面

onecold 7 ماه پیش
والد
کامیت
1b3dc9b5ce

+ 8 - 8
entry/src/main/ets/view/NavidromePage.ets

@@ -1929,7 +1929,7 @@ export struct NavidromePage {
     Button({ type: ButtonType.Capsule, stateEffect: true }) {
       Row({ space: 12 }) {
         // 歌曲封面
-        Image(song.pixelMapPath ? song.pixelMapPath : $r('app.media.alt'))
+        Image(song.pixelMapPath ? song.pixelMapPath : $r('app.media.nocover'))
           .width(52)
           .height(52)
           .borderRadius(9)
@@ -1937,7 +1937,7 @@ export struct NavidromePage {
           .draggable(false)
           .interpolation(ImageInterpolation.High)// 用于重采样后的抗锯齿
           .autoResize(true) // 重采样,可减少内存占用
-          .alt($r('app.media.alt'))
+          .alt($r('app.media.nocover'))
           .fillColor(song.pixelMapPath ? undefined : this.themeColor)
           .objectFit(ImageFit.Cover)
           .margin({ left: 20 })
@@ -2011,12 +2011,12 @@ export struct NavidromePage {
   buildArtistItem(artist: NavidromeRestArtist) {
     Button({ type: ButtonType.Capsule, stateEffect: true }) {
       Row({ space: 12 }) {
-        Image(artist.coverUrl ?? $r('app.media.alt'))
+        Image(artist.coverUrl ?? $r('app.media.nocover'))
           .width(48)
           .height(48)
           .borderRadius(10)
           .draggable(false)
-          .alt($r('app.media.alt'))
+          .alt($r('app.media.nocover'))
           // .interpolation(ImageInterpolation.High)// 用于重采样后的抗锯齿
           // .autoResize(true) // 重采样,可减少内存占用
           .sourceSize({ width: 38, height: 38 })
@@ -2059,12 +2059,12 @@ export struct NavidromePage {
   buildAlbumItem(album: NavidromeRestAlbum) {
     Button({ type: ButtonType.Capsule, stateEffect: true }) {
       Row({ space: 12 }) {
-        Image(album.coverUrl ?? $r('app.media.alt'))
+        Image(album.coverUrl ?? $r('app.media.nocover'))
           .width(48)
           .height(48)
           .borderRadius(10)
           .clip(true)
-          .alt($r('app.media.alt'))
+          .alt($r('app.media.nocover'))
           .draggable(false)
           // .interpolation(ImageInterpolation.High)// 用于重采样后的抗锯齿
           // .autoResize(true) // 重采样,可减少内存占用
@@ -2115,11 +2115,11 @@ export struct NavidromePage {
   buildPlaylistItem(playlist: NavidromeRestPlaylist) {
     Button({ type: ButtonType.Capsule, stateEffect: true }) {
       Row({ space: 12 }) {
-        Image($r('app.media.alt'))
+        Image($r('app.media.nocover'))
           .width(48)
           .height(48)
           .borderRadius(10)
-          .alt($r('app.media.alt'))
+          .alt($r('app.media.nocover'))
           .draggable(false)
           .sourceSize({ width: 38, height: 38 })
           .fillColor(this.themeColor)

BIN
entry/src/main/resources/base/media/nocover.png


+ 18 - 13
lib/src/main/ets/view/LyricView2.ets

@@ -222,6 +222,7 @@ export struct LyricView2 {
         .contentEndOffset(this.h / 3)
         .contentStartOffset(this.isUserTouching?this.h / 3:0)
         .cachedCount(this.cacheSize)
+        .chainAnimation(true)
         .animation({
             curve: curves.springCurve(100, 10, 80, 10),
             duration: 500
@@ -274,19 +275,19 @@ export struct LyricView2 {
                 .textAlign(this.alignMode == 'center' ? TextAlign.Center : TextAlign.Start)
                 .fontColor(index == this.currentIndex ? this.textHighlightColor : this.textColor)
                 .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
+                .padding(this.isSingleLine?0:{ top:5,bottom:5 })
+                .visibility(this.isSingleLine?
+                    (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
+                    : Visibility.Visible)
+                .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '80%')
                 .animation({
                     duration: 150,
                     curve: Curve.Linear
                 })
-                .padding(this.isSingleLine?0:{ top:5,bottom:5 })
                 .blendMode(
                     index == this.currentIndex ? BlendMode.DST_IN : undefined,
                     index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
                 )
-                .visibility(this.isSingleLine?
-                    (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
-                    : Visibility.Visible)
-                .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '80%')
 
             // 中文翻译(整行显示)
             if (item.translation)  {
@@ -298,10 +299,6 @@ export struct LyricView2 {
                 .fontWeight(index == this.currentIndex && this.isHighlightBold ? FontWeight.Bold : this.textWeight)
                 .padding(this.isSingleLine?{ bottom:2 }:{ bottom:5 })
                 .textAlign(this.alignMode == 'center' ? TextAlign.Center : TextAlign.Start)
-                .animation({
-                    duration: 150,
-                    curve: Curve.Linear
-                })
                 .visibility(this.isSingleLine?
                     (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
                     : Visibility.Visible)
@@ -310,6 +307,10 @@ export struct LyricView2 {
                     index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
                 )
                 .width(this.alignMode == 'center' ? '100%' :index == this.currentIndex ?'95%': '80%')
+                .animation({
+                    duration: 150,
+                    curve: Curve.Linear
+                })
 
             }
         }
@@ -322,6 +323,10 @@ export struct LyricView2 {
             index == this.currentIndex ? BlendMode.SRC_OVER : undefined,
             index == this.currentIndex ? BlendApplyType.OFFSCREEN : undefined
         )
+        .animation({
+            duration: index == this.currentIndex ?150:0,
+            curve: Curve.Linear
+        })
 
     }
 
@@ -441,10 +446,10 @@ export struct LyricView2 {
                             (index >= this.currentIndex && index <= this.currentIndex + 1 ? Visibility.Visible : Visibility.None)
                             : Visibility.Visible)
                         .padding(this.isSingleLine?0:{ top:5,bottom:5 })
-                        .shaderStyle(index == this.currentIndex ?{
-                            direction: GradientDirection.Right,
-                            colors: this.getWordByWordLyricLyricItemLinearGradient(item, word, index)
-                        }:undefined)
+                        // .shaderStyle(index == this.currentIndex ?{
+                        //     direction: GradientDirection.Right,
+                        //     colors: this.getWordByWordLyricLyricItemLinearGradient(item, word, index)
+                        // }:undefined)
                         .animation({
                             duration: 150,
                             curve: Curve.Linear