|
@@ -67,7 +67,7 @@ |
|
|
:selectSystemFolders="selectSystemFolders" |
|
|
:selectSystemFolders="selectSystemFolders" |
|
|
/> |
|
|
/> |
|
|
<!-- 文件上传队列 --> |
|
|
<!-- 文件上传队列 --> |
|
|
<div class="list-group" v-if="currentFolder.id === currentNodeFolder.id"> |
|
|
|
|
|
|
|
|
<div class="list-group"> |
|
|
<FileItem |
|
|
<FileItem |
|
|
class="lisy-group-item" |
|
|
class="lisy-group-item" |
|
|
v-for="file in uploadFileList" |
|
|
v-for="file in uploadFileList" |
|
@@ -266,7 +266,7 @@ import { firstCharToLowerCase, firstCharToUpperCase, notify } from '@/utils/tool |
|
|
import FileItem from './components/file-item'; |
|
|
import FileItem from './components/file-item'; |
|
|
import FolderItem from './components/folder-item'; |
|
|
import FolderItem from './components/folder-item'; |
|
|
import { FileWorkStatus, getFileStoreKey, injectionFileLocalStatus, LoadingEnum, VirtualFolder } from './helper'; |
|
|
import { FileWorkStatus, getFileStoreKey, injectionFileLocalStatus, LoadingEnum, VirtualFolder } from './helper'; |
|
|
import { propertyOf, uniqBy, throttle } from 'lodash'; |
|
|
|
|
|
|
|
|
import { propertyOf, uniqBy, throttle, flatten } from 'lodash'; |
|
|
|
|
|
|
|
|
const $ = window.jQuery; |
|
|
const $ = window.jQuery; |
|
|
const Velocity = window.Velocity; |
|
|
const Velocity = window.Velocity; |
|
@@ -459,11 +459,12 @@ export default { |
|
|
const files = propertyOf(e)('dataTransfer.files'); |
|
|
const files = propertyOf(e)('dataTransfer.files'); |
|
|
if(!files || files.length === 0) return; |
|
|
if(!files || files.length === 0) return; |
|
|
const itemPaths = Array.from(files).map(file => file.path); |
|
|
const itemPaths = Array.from(files).map(file => file.path); |
|
|
itemPaths.forEach(async fullPath => { |
|
|
|
|
|
const maybeTasks = await system.analyzeSystemPath(fullPath); |
|
|
|
|
|
const tasks = maybeTasks || []; |
|
|
|
|
|
tasks.forEach(uploadTask => this.clientUpload(uploadTask)); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.clientUpload(itemPaths); |
|
|
|
|
|
// itemPaths.forEach(async fullPath => { |
|
|
|
|
|
// const maybeTasks = await system.analyzeSystemPath(fullPath); |
|
|
|
|
|
// const tasks = maybeTasks || []; |
|
|
|
|
|
// tasks.forEach(uploadTask => this.clientUpload(uploadTask)); |
|
|
|
|
|
// }); |
|
|
}, |
|
|
}, |
|
|
stopPropagation(e) { |
|
|
stopPropagation(e) { |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
@@ -739,11 +740,12 @@ export default { |
|
|
if(!this.isClient) return; |
|
|
if(!this.isClient) return; |
|
|
const filePaths = await system.chooseFiles(); |
|
|
const filePaths = await system.chooseFiles(); |
|
|
if(!filePaths) return; |
|
|
if(!filePaths) return; |
|
|
filePaths.forEach(async fullPath => { |
|
|
|
|
|
const maybeTasks = await system.analyzeSystemPath(fullPath); |
|
|
|
|
|
const tasks = maybeTasks || []; |
|
|
|
|
|
tasks.forEach(uploadTask => this.clientUpload(uploadTask)); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.clientUpload(filePaths); |
|
|
|
|
|
// filePaths.forEach(async fullPath => { |
|
|
|
|
|
// const maybeTasks = await system.analyzeSystemPath(fullPath); |
|
|
|
|
|
// const tasks = maybeTasks || []; |
|
|
|
|
|
// tasks.forEach(uploadTask => this.clientUpload(uploadTask)); |
|
|
|
|
|
// }); |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 客户端选择文件夹列表并上传 |
|
|
* 客户端选择文件夹列表并上传 |
|
@@ -752,11 +754,12 @@ export default { |
|
|
if(!this.isClient) return; |
|
|
if(!this.isClient) return; |
|
|
const folderPaths = await system.chooseFolders(); |
|
|
const folderPaths = await system.chooseFolders(); |
|
|
if(!folderPaths) return; |
|
|
if(!folderPaths) return; |
|
|
folderPaths.forEach(async fullPath => { |
|
|
|
|
|
const maybeTasks = await system.analyzeSystemPath(fullPath); |
|
|
|
|
|
const tasks = maybeTasks || []; |
|
|
|
|
|
tasks.forEach(uploadTask => this.clientUpload(uploadTask)); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
this.clientUpload(folderPaths); |
|
|
|
|
|
// folderPaths.forEach(async fullPath => { |
|
|
|
|
|
// const maybeTasks = await system.analyzeSystemPath(fullPath); |
|
|
|
|
|
// const tasks = maybeTasks || []; |
|
|
|
|
|
// tasks.forEach(uploadTask => this.clientUpload(uploadTask)); |
|
|
|
|
|
// }); |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 客户端上传文件 |
|
|
* 客户端上传文件 |
|
@@ -767,47 +770,70 @@ export default { |
|
|
* relativePath: 相对路径 |
|
|
* relativePath: 相对路径 |
|
|
* } |
|
|
* } |
|
|
*/ |
|
|
*/ |
|
|
clientUpload(uploadTask) { |
|
|
|
|
|
|
|
|
async clientUpload(filePaths) { // uploadTask |
|
|
|
|
|
|
|
|
|
|
|
const tasksGroup = await Promise.all(filePaths.map(path => system.analyzeSystemPath(path))); |
|
|
|
|
|
const uploadTasks = flatten(tasksGroup); |
|
|
const { folderName, levelId, id: folderId } = this.currentNodeFolder; |
|
|
const { folderName, levelId, id: folderId } = this.currentNodeFolder; |
|
|
const { folderPath = '' } = this.currentFolder; |
|
|
const { folderPath = '' } = this.currentFolder; |
|
|
const { fullPath: sourceFilePath, fileName, extension: fileExtension, relativePath } = uploadTask; |
|
|
|
|
|
const params = { |
|
|
|
|
|
projectId: this.projectId, |
|
|
|
|
|
projectName: this.projectName, |
|
|
|
|
|
folderId, folderName, folderLevelId: levelId, distFileRelativePath: `${folderPath ? `${folderPath}\\`:''}${relativePath?`${relativePath}`:''}`.replace(/(\\)+/g, '/'), |
|
|
|
|
|
fileName, fileExtension, sourceFilePath, |
|
|
|
|
|
fileList: this.workFileList, |
|
|
|
|
|
onSuccess: (file) => { // onSuccess |
|
|
|
|
|
const {ArchName, IpfsCid, Extension, RelativePath} = file; |
|
|
|
|
|
// 注入到文件下载检测表中 |
|
|
|
|
|
const key = `${folderName}\\${RelativePath ? `${RelativePath.replace(/\//g, '\\')}\\`: ''}${ArchName}${Extension ? `.${Extension}`: ''}`; |
|
|
|
|
|
this.addLocalFileRecord(key, IpfsCid); |
|
|
|
|
|
this.removeFileLoadingState(file.Id); |
|
|
|
|
|
this.fetchFolderFiles(); |
|
|
|
|
|
}, |
|
|
|
|
|
onProgress: (progressData, upperUploadFile) => { // onLoading |
|
|
|
|
|
const { process, hash, size, currentSize, currentUnit, unit } = progressData; |
|
|
|
|
|
const uploadFile = firstCharToLowerCase(upperUploadFile); |
|
|
|
|
|
// 避免使用最后一次progreessData中size被修正为Kb的数据 |
|
|
|
|
|
if(!hash) { |
|
|
|
|
|
this.updateFileLoadState(uploadFile.id, UPLOADING, process, currentSize, currentUnit, size, unit); |
|
|
|
|
|
} |
|
|
|
|
|
// 覆盖已有的同名文件 |
|
|
|
|
|
if(uploadFile.id.indexOf('upload:') === -1) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// 插入上传队列 |
|
|
|
|
|
if(!this.uploadFileList.find(f => f.id === uploadFile.id)) { |
|
|
|
|
|
this.uploadFileList.push(uploadFile); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
onError: (e, upperFile) => { |
|
|
|
|
|
this.removeFileLoadingState(upperFile.Id); |
|
|
|
|
|
this.uploadFileList = this.uploadFileList.filter(iFile => iFile.id !== upperFile.Id); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
const workFileList = this.workFileList; |
|
|
|
|
|
// 检查是否存在文件重名,有则提示 |
|
|
|
|
|
const ifHaveRepeatFile = uploadTasks.some(uploadTask => { |
|
|
|
|
|
const { fileName, extension: fileExtension, relativePath } = uploadTask; |
|
|
|
|
|
const extensionedFileName = fileExtension ? `${fileName}.${fileExtension}`: fileName; |
|
|
|
|
|
const distFileRelativePath = `${folderPath ? `${folderPath}\\`:''}${relativePath ? `${relativePath}`:''}`.replace(/(\\)+/g, '/'); |
|
|
|
|
|
debugger; |
|
|
|
|
|
// todo |
|
|
|
|
|
return workFileList.some(iFile => distFileRelativePath === iFile.relativePath && `${iFile.archName}${iFile.extension ? `.${iFile.extension}` : ''}` === extensionedFileName) |
|
|
|
|
|
}); |
|
|
|
|
|
if(ifHaveRepeatFile) { |
|
|
|
|
|
let confirmRes = false; |
|
|
|
|
|
try { |
|
|
|
|
|
await Vue.prototype.$confirm('监测到文件夹存在同名文件,是否继续上传并覆盖同名文件?'); |
|
|
|
|
|
confirmRes = true; |
|
|
|
|
|
} catch(e) { console.log('user canceled'); } |
|
|
|
|
|
if(!confirmRes) return; |
|
|
} |
|
|
} |
|
|
// console.log(folderName, levelId, folderId); |
|
|
|
|
|
system.uploadFile(params); |
|
|
|
|
|
|
|
|
uploadTasks.forEach(uploadTask => { |
|
|
|
|
|
const { fullPath: sourceFilePath, fileName, extension: fileExtension, relativePath } = uploadTask; |
|
|
|
|
|
const params = { |
|
|
|
|
|
projectId: this.projectId, |
|
|
|
|
|
projectName: this.projectName, |
|
|
|
|
|
folderId, folderName, folderLevelId: levelId, distFileRelativePath: `${folderPath ? `${folderPath}\\`:''}${relativePath?`${relativePath}`:''}`.replace(/(\\)+/g, '/'), |
|
|
|
|
|
fileName, fileExtension, sourceFilePath, |
|
|
|
|
|
fileList: workFileList, |
|
|
|
|
|
onSuccess: (file) => { // onSuccess |
|
|
|
|
|
const {ArchName, IpfsCid, Extension, RelativePath} = file; |
|
|
|
|
|
// 注入到文件下载检测表中 |
|
|
|
|
|
const key = `${folderName}\\${RelativePath ? `${RelativePath.replace(/\//g, '\\')}\\`: ''}${ArchName}${Extension ? `.${Extension}`: ''}`; |
|
|
|
|
|
this.addLocalFileRecord(key, IpfsCid); |
|
|
|
|
|
this.removeFileLoadingState(file.Id); |
|
|
|
|
|
this.fetchFolderFiles(); |
|
|
|
|
|
}, |
|
|
|
|
|
onProgress: (progressData, upperUploadFile) => { // onLoading |
|
|
|
|
|
const { process, hash, size, currentSize, currentUnit, unit } = progressData; |
|
|
|
|
|
const uploadFile = firstCharToLowerCase(upperUploadFile); |
|
|
|
|
|
// 避免使用最后一次progreessData中size被修正为Kb的数据 |
|
|
|
|
|
if(!hash) { |
|
|
|
|
|
this.updateFileLoadState(uploadFile.id, UPLOADING, process, currentSize, currentUnit, size, unit); |
|
|
|
|
|
} |
|
|
|
|
|
// 覆盖已有的同名文件 |
|
|
|
|
|
if(uploadFile.id.indexOf('upload:') === -1) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// 插入上传队列 |
|
|
|
|
|
if(!this.uploadFileList.find(f => f.id === uploadFile.id)) { |
|
|
|
|
|
this.uploadFileList.push(uploadFile); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
onError: (e, upperFile) => { |
|
|
|
|
|
this.removeFileLoadingState(upperFile.Id); |
|
|
|
|
|
this.uploadFileList = this.uploadFileList.filter(iFile => iFile.id !== upperFile.Id); |
|
|
|
|
|
}, |
|
|
|
|
|
} |
|
|
|
|
|
// console.log(folderName, levelId, folderId); |
|
|
|
|
|
system.uploadFile(params); |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 客户端下载方法 |
|
|
* 客户端下载方法 |
|
|