Skip to content

Commit

Permalink
Revert "Download verify" (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
weearc authored Jan 13, 2024
1 parent 92dc701 commit 4d5d0f1
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions components/DownloadModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,17 @@ export default {
return
}
const name = url.slice(url.lastIndexOf("/") + 1)
this.verifyPre(url)
const blobUrl = this.xhrDownloadHandler(this.selectedVersionUrl).toString()
console.log(url,"====> url")
const a = document.createElement("a")
a.setAttribute("href", blobUrl)
// a.setAttribute("href", this.selectedVersionUrl)
this.verifyPre(url)
a.setAttribute("href", this.selectedVersionUrl)
a.setAttribute("download", name)
a.click()
a.remove()
URL.revokeObjectURL(blobUrl)
this.$modal.hide('download-dialog')
},
async verifyPre(key) {
console.log(key)
const xhr = new XMLHttpRequest()
const url = Api_mirror.getBaseurl({}) + key
xhr.open('HEAD', url, true)
Expand All @@ -133,24 +132,6 @@ export default {
}
}.bind(this)
},
async xhrDownloadHandler(url) {
const xhr = new XMLHttpRequest()
xhr.setRequestHeader('Cookie', document.cookie)
xhr.open('GET', url, true)
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
const data = xhr.response
const blob = new Blob([data], { type: 'application/octet-stream'})
return URL.createObjectURL(blob)
} else {
console.error('request failed. ', xhr.status)
return ''
}
}
}.bind(this)
xhr.send()
},
addCookie(cookieName, cookieValue, path) {
document.cookie = `${cookieName}=${cookieValue}; max-age=300;`
setTimeout("location.reload()", 5000)
Expand Down

0 comments on commit 4d5d0f1

Please sign in to comment.