Przeglądaj źródła

:bug: Fixing a bug. 修复菜单预览时 windows 和 unix 系统下不同格式的处理

aeizzz 1 rok temu
rodzic
commit
edf3ce1c9d
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      src/views/gen/preview.vue

+ 6 - 2
src/views/gen/preview.vue

@@ -57,7 +57,6 @@ export default {
       }
       const files = this.handleFiles(this.fileTreeOriginal)
       this.fileTree = handleTree(files, 'id', 'parentId', 'children', '/')
-      console.log(this.fileTree, 'fileTree')
     })
   },
   methods: {
@@ -78,7 +77,12 @@ export default {
       const files = []
       // 遍历每个元素
       for (const data of fileTreeOriginal) {
-        const paths = data.v.split('\\')
+        let paths = []
+        if(data.v.includes("\\")){
+          paths = data.v.split('\\')
+        }else{
+          paths = data.v.split('/')
+        }
         let fullPath = '' // 从头开始的路径,用于生成 id
         // 遍历每个 path, 拼接成树
         for (let i = 0; i < paths.length; i++) {