Skip to content

Commit b56ee55

Browse files
committed
🐛 修复上传文件夹时,实际上传后的文件路径错乱的 BUG
🐛 修复文件夹上传时,当文件进入队列后,切换到其他目录,队列中的文件上传目录会变化的 BUG.
1 parent ea14e9e commit b56ee55

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/composables/file/useFileUpload.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ export default function useFileUpload() {
114114
visible.value = true;
115115
fileList.forEach((item) => {
116116
beforeUpload({
117-
file: item,
118-
uploadToPath: currentPath.value
117+
file: item
119118
});
120119
})
121120
}
@@ -355,13 +354,16 @@ export default function useFileUpload() {
355354
* @param param
356355
*/
357356
const beforeUpload = (param) => {
358-
uploadFile(param.file, param.uploadToPath);
357+
uploadFile(param.file, param.uploadBasePath);
359358
}
360359

361360
// 文件上传操作.
362-
const uploadFile = (file, uploadToPath) => {
361+
const uploadFile = (file, uploadBasePath) => {
363362
const fileIndex = uploadIndex++;
364-
uploadToPath = uploadToPath || currentPath.value;
363+
364+
uploadBasePath = uploadBasePath || currentPath.value;
365+
366+
let uploadToPath = uploadBasePath;
365367

366368
// 如果包含 webkitRelativePath, 则表示是文件夹上传, 需要获取文件完整路径
367369
if (file.webkitRelativePath || file.dropUploadPath) {
@@ -397,7 +399,7 @@ export default function useFileUpload() {
397399
waitingFileList.push({
398400
index: fileIndex,
399401
file: file,
400-
uploadToPath: uploadToPath,
402+
uploadBasePath: uploadBasePath,
401403
});
402404
return;
403405
}
@@ -683,7 +685,7 @@ export default function useFileUpload() {
683685
let fileItem = spliceList[0];
684686
beforeUpload({
685687
file: fileItem.file,
686-
uploadToPath: fileItem.uploadToPath
688+
uploadBasePath: fileItem.uploadBasePath
687689
});
688690
console.log('开始从等待队列中获取上传文件: ', fileItem.file.name);
689691
}

0 commit comments

Comments
 (0)