Skip to content

Commit 65ac8ce

Browse files
committed
fix: 修复下载文件夹提示所选文件夹为空的问题 #89
1 parent 5028338 commit 65ac8ce

File tree

3 files changed

+32
-85
lines changed

3 files changed

+32
-85
lines changed

src/components/ShowFile/ShowFile.vue

+8-31
Original file line numberDiff line numberDiff line change
@@ -3846,42 +3846,19 @@ export default {
38463846
this.rowContextData.isShare = true;
38473847
},
38483848
downloadFile() {
3849-
let totalSize = 0;
3849+
let fileIds = [];
38503850
if (this.$refs.fileListTable.tableSelectData.length > 0) {
3851-
this.$refs.fileListTable.tableSelectData.forEach(item => {
3852-
totalSize += item.size;
3851+
this.$refs.fileListTable.tableSelectData.forEach(value => {
3852+
fileIds.push(value.id);
38533853
});
38543854
} else {
3855-
totalSize += this.rowContextData.size;
3855+
fileIds.push(this.rowContextData.id);
38563856
}
3857-
if (totalSize > 0) {
3858-
let fileIds = [];
3859-
if (this.$refs.fileListTable.tableSelectData.length > 0) {
3860-
this.$refs.fileListTable.tableSelectData.forEach(value => {
3861-
fileIds.push(value.id);
3862-
});
3863-
} else {
3864-
fileIds.push(this.rowContextData.id);
3865-
}
3866-
if (fileIds.length > 1 || this.rowContextData.isFolder) {
3867-
fileConfig.packageDownload(
3868-
fileIds,
3869-
this.$store.state.user.token,
3870-
this.$store.state.user.name
3871-
);
3872-
return;
3873-
}
3874-
fileConfig.download(
3875-
this.$store.state.user.name,
3876-
this.rowContextData,
3877-
this.$store.getters.token
3878-
);
3879-
} else {
3880-
this.$message({
3881-
message: "所选文件为空",
3882-
type: "warning"
3883-
});
3857+
if (fileIds.length > 1 || this.rowContextData.isFolder) {
3858+
fileConfig.packageDownload(fileIds,this.$store.state.user.token,this.$store.state.user.name)
3859+
return;
38843860
}
3861+
fileConfig.download(this.$store.state.user.name,this.rowContextData,this.$store.getters.token)
38853862
},
38863863
// 复制下载链接
38873864
copyDownloadLink(row) {

src/views/home/mobile/index.vue

+8-23
Original file line numberDiff line numberDiff line change
@@ -611,34 +611,19 @@ export default {
611611
}
612612
},
613613
downloadFile() {
614-
let totalSize = 0
614+
let fileIds = [];
615615
if (this.selectRowData.length > 0) {
616-
this.selectRowData.forEach(item => {
617-
totalSize += item.size
616+
this.selectRowData.forEach(value => {
617+
fileIds.push(value.id)
618618
})
619619
} else {
620-
totalSize += this.rowContextData.size
620+
fileIds.push(this.rowContextData.id)
621621
}
622-
if (totalSize > 0) {
623-
let fileIds = [];
624-
if (this.selectRowData.length > 0) {
625-
this.selectRowData.forEach(value => {
626-
fileIds.push(value.id)
627-
})
628-
} else {
629-
fileIds.push(this.rowContextData.id)
630-
}
631-
if (fileIds.length > 1 || this.rowContextData.isFolder) {
632-
fileConfig.packageDownload(fileIds, this.$store.state.user.token, this.$store.state.user.name)
633-
return
634-
}
635-
fileConfig.download(this.$store.state.user.name, this.rowContextData, this.$store.state.user.token)
636-
} else {
637-
this.$message({
638-
message: '所选文件夹为空',
639-
type: 'warning'
640-
});
622+
if (fileIds.length > 1 || this.rowContextData.isFolder) {
623+
fileConfig.packageDownload(fileIds, this.$store.state.user.token, this.$store.state.user.name)
624+
return
641625
}
626+
fileConfig.download(this.$store.state.user.name, this.rowContextData, this.$store.state.user.token)
642627
},
643628
// 复制下载链接
644629
copyDownloadLink(row) {

src/views/public/share/shareList.vue

+16-31
Original file line numberDiff line numberDiff line change
@@ -1000,45 +1000,30 @@ export default {
10001000
this.selectTreeNode.showName = ' "' + row.name + '"'
10011001
},
10021002
downloadFile(copy) {
1003-
let totalSize = 0
1004-
if (this.indexList.length > 0) {
1005-
this.selectRowData.forEach(item => {
1006-
totalSize += item.size
1003+
let fileIds = [];
1004+
if (this.menusIsMultiple) {
1005+
this.selectRowData.forEach(value => {
1006+
fileIds.push(value.id)
10071007
})
10081008
} else {
1009-
totalSize = this.rowContextData.size
1009+
fileIds.push(this.rowContextData.id)
10101010
}
1011-
if (totalSize > 0) {
1012-
let fileIds = [];
1013-
if (this.menusIsMultiple) {
1014-
this.selectRowData.forEach(value => {
1015-
fileIds.push(value.id)
1016-
})
1011+
if (fileIds.length > 1 || this.rowContextData.isFolder) {
1012+
if (copy) {
1013+
this.copyDownloadLink(fileConfig.publicPackageDownloadUrl(this.shareId, fileIds, this.$store.getters.shareToken))
10171014
} else {
1018-
fileIds.push(this.rowContextData.id)
1019-
}
1020-
if (fileIds.length > 1 || this.rowContextData.isFolder) {
1021-
if (copy) {
1022-
this.copyDownloadLink(fileConfig.publicPackageDownloadUrl(this.shareId, fileIds, this.$store.getters.shareToken))
1023-
} else {
1024-
fileConfig.publicPackageDownload(this.shareId, fileIds, this.$store.getters.shareToken)
1025-
}
1026-
return
1015+
fileConfig.publicPackageDownload(this.shareId, fileIds, this.$store.getters.shareToken)
10271016
}
1028-
if (copy) {
1029-
if (this.rowContextData.isShare) {
1030-
this.copyDownloadLink(window.location.origin + fileConfig.previewUrl(this.sharer.username, this.rowContextData, undefined, this.$store.getters.shareToken))
1031-
} else {
1032-
this.copyDownloadLink(fileConfig.publicPackageDownloadUrl(this.shareId, fileIds, this.$store.getters.shareToken))
1033-
}
1017+
return
1018+
}
1019+
if (copy) {
1020+
if (this.rowContextData.isShare) {
1021+
this.copyDownloadLink(window.location.origin + fileConfig.previewUrl(this.sharer.username, this.rowContextData, undefined, this.$store.getters.shareToken))
10341022
} else {
1035-
fileConfig.publicDownload(this.shareId, this.rowContextData, this.$store.getters.shareToken)
1023+
this.copyDownloadLink(fileConfig.publicPackageDownloadUrl(this.shareId, fileIds, this.$store.getters.shareToken))
10361024
}
10371025
} else {
1038-
this.$message({
1039-
message: '所选文件为空',
1040-
type: 'warning'
1041-
});
1026+
fileConfig.publicDownload(this.shareId, this.rowContextData, this.$store.getters.shareToken)
10421027
}
10431028
},
10441029
// 复制下载链接

0 commit comments

Comments
 (0)