Browse Source

修复打开显示文件名的开关后 百度网盘显示不了文件名的问题

onecold 5 months ago
parent
commit
32e0f63271

+ 3 - 0
entry/src/main/ets/common/util/RemoteDriveManager.ets

@@ -2096,6 +2096,7 @@ export class RemoteDriveManager {
       videoItem.artist = musicData.artist;
       videoItem.name = musicData.title;
     }
+    videoItem.fileName = fileInfo.fileName
     return videoItem;
   }
 
@@ -2141,6 +2142,7 @@ export class RemoteDriveManager {
     if (account && account.id) {
       videoItem.webdav_account_id = account.id.toString();
     }
+    videoItem.fileName = fileInfo.fileName
     videoItem.remote_rel_path = normalizedPath;
     return videoItem;
   }
@@ -2169,6 +2171,7 @@ export class RemoteDriveManager {
     );
     videoItem.size = Utility.formatFSize(entry.size);
     videoItem.album = '';
+    videoItem.fileName = entry.server_filename
     videoItem.remote_rel_path = entry.path;
     videoItem.baiduFsId = entry.fs_id.toString();
     if (account && account.id) {

+ 22 - 21
entry/src/main/ets/view/LocalMusic.ets

@@ -3334,7 +3334,7 @@ export struct LocalMusic {
             })
             // 右侧居中的字母表索引
 
-              this.indexBuilder()
+            this.indexBuilder()
 
 
             this.topTitleBar()
@@ -6015,7 +6015,8 @@ export struct LocalMusic {
               right: this.currentBreakpoint !== BreakpointTypeEnum.SM ? 40 : 20
             })
           Column() {
-            Text(this.isShowFileName&&item.type!=CommonConstants.TYPE_IS_DIR?item.fileName :item.name.startsWith('.') ? item.name.replace(/\./g, '') : item.name)
+            Text(this.isShowFileName&&this.modeType !== 2&&this.modeType !== 3&&
+              item.type!=CommonConstants.TYPE_IS_DIR?item.fileName :item.name.startsWith('.') ? item.name.replace(/\./g, '') : item.name)
               .fontSize(this.twoFingerType == 1 ? 12 : this.twoFingerType == 2 ? 15 : 18)
               .maxLines(1)
               .fontWeight(FontWeight.Bold)
@@ -7343,7 +7344,7 @@ export struct LocalMusic {
 
     // 检查当前播放歌曲是否在已加载的列表中
     const targetIndex = Utility.getIndexFromList(this.videoLocalList, this.currentSong.filePath);
-    
+
     if (targetIndex > 0) {
       // 歌曲在当前列表中,直接滚动
       console.info("heanup locateCurrentSong: 找到歌曲,索引=" + targetIndex);
@@ -11255,7 +11256,7 @@ export struct LocalMusic {
         title: {
           title:this.getPlayListDisplayCount()==0?Utility.resourceToString(this.context, $r('app.string.current_play_list'))
             :Utility.resourceToString(this.context, $r('app.string.current_play_list'))
-            + `(${this.getPlayListDisplayCount()}首)`
+              + `(${this.getPlayListDisplayCount()}首)`
         }
       })
       .onClick(() => {
@@ -13099,7 +13100,7 @@ export struct LocalMusic {
                   .height(24);
 
                 Toggle({ type: ToggleType.Switch, isOn: this.isGeKongPlayNext })
-                .selectedColor(this.themeColor)
+                  .selectedColor(this.themeColor)
                   .switchPointColor(Color.White)
                   .clickEffect({ level: ClickEffectLevel.LIGHT, scale: 0.5 })
                   .margin({ right: 15 })
@@ -14088,7 +14089,7 @@ export struct LocalMusic {
     if(this.isShowSingleLineLyric){
       this.lyricControllerSingle.updatePosition(position + this.timeOffset * 1000);
     }
-    
+
     // 蓝牙歌词更新逻辑
     if (this.bluetoothLyricEnabled && this.isBluetoothConnected && this.lyricContent && this.currentSong) {
       const currentLyricLine = LyricUtil.getCurrentLyricLine(this.lyricContent, position + this.timeOffset * 1000);
@@ -15940,13 +15941,13 @@ export struct LocalMusic {
       // 阈值常量
       const UNPLAYED_THRESHOLD = 10; // 剩余未播放歌曲阈值
       const LOAD_MORE_PAGES = 3;     // 每次加载页数
-      
+
       // 获取网盘播放列表
       const navidromeList = getNavidromeVideoItems();
       const webdavList = getWebdavVideoItems();
       const isNavidrome = navidromeList.length > 0;
       const remoteList = isNavidrome ? navidromeList : webdavList;
-      
+
       if (remoteList.length > 0) {
         // 将当前歌加入历史栈
         if (this.currentSong) {
@@ -15963,9 +15964,9 @@ export struct LocalMusic {
         let unplayedCount = isNavidrome ? getUnplayedCount() : remoteList.length;
         const totalCount = remoteList.length;
         const playedCount = isNavidrome ? getPlayedCount() : 0;
-        
+
         Logger.info(TAG, `randomPlay(网盘模式): 总数${totalCount}, 已播放${playedCount}, 未播放${unplayedCount}`);
-        
+
         // 如果未播放数量不足阈值,且还有更多数据,触发加载更多页
         if (isNavidrome && unplayedCount < UNPLAYED_THRESHOLD && hasMoreData()) {
           Logger.info(TAG, `randomPlay(网盘模式): 未播放(${unplayedCount})不足阈值(${UNPLAYED_THRESHOLD}),触发加载更多`);
@@ -15987,7 +15988,7 @@ export struct LocalMusic {
             clearPlayedHistory();
             // 排除当前歌曲
             const currentFilePath = this.currentSong?.filePath;
-            candidates = currentFilePath 
+            candidates = currentFilePath
               ? getNavidromeVideoItems().filter(v => v.filePath !== currentFilePath)
               : getNavidromeVideoItems();
           }
@@ -16002,12 +16003,12 @@ export struct LocalMusic {
         if (candidates.length > 0) {
           const randomIndex = Math.floor(Math.random() * candidates.length);
           const randomSong = candidates[randomIndex];
-          
+
           // 标记为已播放
           if (isNavidrome) {
             markAsPlayed(randomSong.filePath);
           }
-          
+
           Logger.info(TAG, `randomPlay(网盘模式): 从${candidates.length}首候选中随机选择: ${randomSong.name}`);
 
           // 将选中的歌曲加入播放列表(如果不存在)
@@ -16981,21 +16982,21 @@ export struct LocalMusic {
     // 保存歌单的歌曲路径列表,用于随机播放
     this.currentPlaylistSongFilePaths = songs.map(song => song.filePath);
     const actualTotal = totalCount ?? songs.length;
-    
+
     // 如果是网盘播放,保存服务端总数到全局存储
     if (totalCount && totalCount > 0 && songs.length > 0) {
       const firstSong = songs[0];
-      if (firstSong && (isNavidromeType(firstSong.type) || 
-          isJellyfinType(firstSong.type) || 
-          isEmbyType(firstSong.type) || 
-          isAudioStationType(firstSong.type) ||
-          isPlexType(firstSong.type) ||
-          isDaoLiYuType(firstSong.type))) {
+      if (firstSong && (isNavidromeType(firstSong.type) ||
+      isJellyfinType(firstSong.type) ||
+      isEmbyType(firstSong.type) ||
+      isAudioStationType(firstSong.type) ||
+      isPlexType(firstSong.type) ||
+      isDaoLiYuType(firstSong.type))) {
         setNavidromeTotalCount(totalCount);
         Logger.info('heanup finishLoadingPlaylist', `已保存服务端总数到全局存储: ${totalCount}`);
       }
     }
-    
+
     Logger.info('heanup finishLoadingPlaylist', `保存歌单歌曲路径列表,已加载=${this.currentPlaylistSongFilePaths.length}, 服务端总数=${actualTotal}`);
 
     if (songs[startIndex]) {