Преглед изворни кода

fix:jszip用windows文件资源管理解压空白

ananzhusen пре 6 месеци
родитељ
комит
42f3003e3e
1 измењених фајлова са 20 додато и 4 уклоњено
  1. 20 4
      src/views/components/Header.vue

+ 20 - 4
src/views/components/Header.vue

@@ -1375,13 +1375,21 @@ const doDownloadZip = async ()=>{
           const res: Blob = await axios.get(url, {
             responseType: 'blob',
           });
-          _zip.file(item.path.split('?')[0], res, { createFolders: true });
+          let path = item.path.split('?')[0];
+          if(path.startsWith('/')){
+            path = path.slice(1);
+          }
+          _zip.file(path, res, { createFolders: true });
         }catch(e){
           console.log(e);
         }
       } else if (item.data) {
         //直接写数据
-        _zip.file(item.path, item.data, { createFolders: true });
+        let path = item.path;
+        if(path.startsWith('/')){
+          path = path.slice(1);
+        }
+        _zip.file(path, item.data, { createFolders: true });
       }
     })
   );
@@ -2109,13 +2117,21 @@ const saveDownload = async () => {
           const res: Blob = await axios.get(item.url.startsWith('/')?(cdn+item.url):item.url, {
             responseType: 'blob',
           });
-          zip.file(item.path.split('?')[0], res, { createFolders: true });
+          let path = item.path.split('?')[0];
+          if(path.startsWith('/')){
+            path = path.slice(1);
+          }
+          zip.file(path, res, { createFolders: true });
         }catch(e){
           console.log(e);
         }
       } else if (item.data) {
         //直接写数据
-        zip.file(item.path, item.data, { createFolders: true });
+        let path = item.path;
+        if(path.startsWith('/')){
+          path = path.slice(1);
+        }
+        zip.file(path, item.data, { createFolders: true });
       }
     })
   );