chendeben 9 месяцев назад
Родитель
Сommit
aa17447b22
1 измененных файлов с 24 добавлено и 2 удалено
  1. 24 2
      entry/src/main/ets/pages/UploadMusicPage.ets

+ 24 - 2
entry/src/main/ets/pages/UploadMusicPage.ets

@@ -222,6 +222,21 @@ export struct UploadMusicPage {
     return '';
   }
 
+  private normalizeBrowsePath(path: string): string {
+    if (!path || path.trim().length === 0) {
+      return '/';
+    }
+    let normalized = path.trim().replace(/\\/g, '/');
+    if (!normalized.startsWith('/')) {
+      normalized = `/${normalized}`;
+    }
+    normalized = normalized.replace(/\/+/g, '/');
+    if (normalized.length > 1 && normalized.endsWith('/')) {
+      normalized = normalized.slice(0, -1);
+    }
+    return normalized || '/';
+  }
+
   /**
    * 预选指定账户
    * @param accountId 账户ID
@@ -494,6 +509,9 @@ export struct UploadMusicPage {
         try {
           const stat = fs.statSync(fullPath);
           const isDirectory = stat.isDirectory();
+          if (fileName.startsWith('.')) {
+            continue;
+          }
           const lowerFileName = fileName.toLowerCase();
           const isAudioFile = !isDirectory && Constants.AUDIO_EXTENSIONS.some(ext => lowerFileName.endsWith(ext));
           
@@ -730,10 +748,14 @@ export struct UploadMusicPage {
       // 过滤出文件夹
       const allFiles = this.webdavManager.webDavFiles;
       this.browseFolders = [];
+      const normalizedCurrent = this.normalizeBrowsePath(this.currentBrowsePath);
       for (let i = 0; i < allFiles.length; i++) {
         const file = allFiles[i];
         if (file.isDirectory) {
-          this.browseFolders.push(file);
+          const folderPath = this.normalizeBrowsePath(file.href);
+          if (folderPath !== normalizedCurrent) {
+            this.browseFolders.push(file);
+          }
         }
       }
 
@@ -1521,7 +1543,7 @@ export struct UploadMusicPage {
         }
         .alignItems(HorizontalAlign.Start)
         .layoutWeight(1)
-
+        
         if (this.currentBrowsePath !== '/') {
           Button('返回上级')
             .fontSize(12)