Browse Source

fix(webdav):修复文件夹显示逻辑并优化路径处理

chendeben 9 tháng trước cách đây
mục cha
commit
32f850f138
1 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 4 3
      entry/src/main/ets/pages/WebDavMainPage.ets

+ 4 - 3
entry/src/main/ets/pages/WebDavMainPage.ets

@@ -108,12 +108,13 @@ export struct WebDavMainPage {
           continue;
         }
 
-        const shouldShow = this.isDirectChildOfCurrentPath(folder);
+        let shouldShow = this.isDirectChildOfCurrentPath(folder);
 
         if (shouldShow) {
           visible.push(folder);
         }
       }
+      console.log('更新文件夹列表:', visible);
 
       this.visibleFoldersState = visible;
     } catch (error) {
@@ -228,10 +229,10 @@ export struct WebDavMainPage {
 
     // 如果在根目录(currentPath为空或'/'),显示所有第一级文件夹
     if (currentPath === '' || currentPath === '/') {
-      // 根目录情况下,显示所有第一级文件夹(href格式为/foldername)
+      const folderPath = folder.href.replace(/\/$/, ''); // 去掉尾部斜杠
       return folder.href.startsWith('/') &&
              folder.href !== '/' &&
-             !folder.href.substring(1).includes('/');
+             !folderPath.substring(1).includes('/');
     }
 
     // 非根目录情况,计算相对路径