Przeglądaj źródła

针对有配置封面api的如果没有封面 就自动加载封面。

onecold 9 miesięcy temu
rodzic
commit
f0df99dbe6

+ 1 - 0
entry/src/main/ets/common/util/WebdavManager.ets

@@ -800,6 +800,7 @@ export class WebdavManager {
     if (musicData.isValid)  {
       console.log('onecold parseMusicFileName  artist:', musicData.artist)
       videoItem.artist = musicData.artist
+      videoItem.name = musicData.title
     }
 
     // 设置WebDAV账号ID,用于后续认证信息查询

+ 8 - 2
entry/src/main/ets/pages/WebDavMainPage.ets

@@ -12,6 +12,7 @@ import { FileInfo } from '../viewmodel/FileInfo';
 import { emitter } from '@kit.BasicServicesKit';
 import { EventConstants } from '../common/constants/EventConstants';
 import { LazyDataSource } from '../common/util/LazyDataSource';
+import { PreferencesUtil } from '@pura/harmony-utils';
 
 /**
  * 歌单播放事件数据
@@ -75,6 +76,8 @@ export struct WebDavMainPage {
   @State breadcrumbs:string[] = []//面包屑导航
 
   @State visibleFoldersState: FileInfo[] = []; // 改为普通状态变量
+  @State isShowFileName: boolean = false//是否显示文件名
+  @State isLongNameRoLL: boolean = true//长歌名滚动
 
   async onSwitchAccount(){
     console.log('onecold 切换账户:', this.selectedAccount.name);
@@ -142,6 +145,8 @@ export struct WebDavMainPage {
   };
 
   aboutToAppear(): void {
+    this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
+    this.isLongNameRoLL = PreferencesUtil.getBooleanSync('isLongNameRoLL', true)
     // 获取顶部安全区高度
     this.getTopRectHeight();
 
@@ -674,14 +679,15 @@ export struct WebDavMainPage {
 
         // 歌曲信息
         Column({ space: 4 }) {
-          Text(decodeUrlEncodedString(song.name))
+          Text(this.isShowFileName?song.fileName :song.name)
             .fontSize(15)
+            .textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
             .fontColor($r('app.color.index_tab_font_color'))
             .maxLines(1)
             .textOverflow({ overflow: TextOverflow.Ellipsis })
 
           Row(){
-            Text(song.artist)
+            Text(song.artist+"  ")
               .fontSize(13)
               .fontColor($r('app.color.index_tab_font_color'))
               .opacity(0.6)

+ 5 - 0
entry/src/main/ets/view/LocalMusic.ets

@@ -11721,6 +11721,11 @@ export struct LocalMusic {
       ["user_agent", "Mozilla/5.0 BiliDroid/7.30.0 (ttmusic)"],
       ["referer", "https://www.bilibili.com"]
     ]);
+    if (this.currentSong&&StrUtil.isEmpty(this.currentSong.pixelMapPath)
+    &&PreferencesUtil.getStringSync('COVER_API',  '') != '') {
+      //如果封面为空,则搜索封面
+      this.searchCover(this.currentSong,  this.currentSong.name,  this.currentSong.artist||'')
+    }
 
     // 如果是WebDAV网络音频,使用webdav_account_id获取认证信息
     if (this.currentSong&&this.currentSong.type === CommonConstants.TYPE_WEBDAV) {