Download centralized on api.js
Former-commit-id: 58fd027bfbc32198c39d87fe7e575229d33a65c8 [formerly 17779d3221cb765d4ce3a5aeccb551ddbfc56f19] [formerly 2f28a4e0bb119490a69968e3c6df29aa3779cc11 [formerly c6348931e0]]
Former-commit-id: 70b4148b16b7c8ac43dc6cb3f38fe5e7062c2af8 [formerly fa369137715c436e5f110b931386f4f6556e9733]
Former-commit-id: 760257fd5ce7b37f48c3848042fe33a4fdd7a905
This commit is contained in:
1 parent
deef004513
commit
5a992f1785
5 files changed
+51
-20
No files matched your search
@@ -12,6 +12,7 @@
|
||||
|
||||
<script>
|
||||
import {mapGetters, mapState} from 'vuex'
|
||||
import api from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'download',
|
||||
@@ -21,24 +22,18 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
download: function (format) {
|
||||
let uri = this.$route.params[0]
|
||||
uri = this.$store.state.baseURL + '/api/download/' + uri
|
||||
uri += `?token=${this.$store.state.jwt}`
|
||||
uri += `&format=${format}`
|
||||
|
||||
if (this.selectedCount > 0) {
|
||||
let files = ''
|
||||
if (this.selectedCount === 0) {
|
||||
api.download(format, this.$route.path)
|
||||
} else {
|
||||
let files = []
|
||||
|
||||
for (let i of this.selected) {
|
||||
files += this.req.items[i].url.replace(window.location.pathname, '') + ','
|
||||
files.push(this.req.items[i].url)
|
||||
}
|
||||
|
||||
files = files.substring(0, files.length - 1)
|
||||
files = encodeURIComponent(files)
|
||||
uri += `&files=${files}`
|
||||
api.download(format, ...files)
|
||||
}
|
||||
|
||||
window.open(uri)
|
||||
this.$store.commit('closePrompts')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user