|
@@ -464,27 +464,37 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async toHref (row) {
|
|
async toHref (row) {
|
|
- let suffix = row.name.substring(row.name.lastIndexOf('.') + 1)
|
|
|
|
- if (suffix === 'pdf' || suffix === 'txt') {
|
|
|
|
- if (row.id === null || row.id === undefined || row.id === '') {
|
|
|
|
- this.ossService.downLoadAttach(row.raw.url)
|
|
|
|
- } else {
|
|
|
|
- this.ossService.downLoadAttach(row.url)
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- console.log('rr', row)
|
|
|
|
const link = document.createElement('a')
|
|
const link = document.createElement('a')
|
|
- link.setAttribute('download', row.name)
|
|
|
|
- link.setAttribute('target', '_blank')
|
|
|
|
if (row.id === null || row.id === undefined || row.id === '') {
|
|
if (row.id === null || row.id === undefined || row.id === '') {
|
|
await this.ossService.getTemporaryUrl(row.raw.url).then((data) => {
|
|
await this.ossService.getTemporaryUrl(row.raw.url).then((data) => {
|
|
- link.setAttribute('href', data.data)
|
|
|
|
- link.click()
|
|
|
|
|
|
+ const url = data.data // 完整的url则直接使用
|
|
|
|
+ // 这里是将url转成blob地址,
|
|
|
|
+ fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
|
|
|
|
+ link.href = URL.createObjectURL(blob)
|
|
|
|
+ console.log(link.href)
|
|
|
|
+ link.download = row.name || '' // 下载文件的名字
|
|
|
|
+ // a.download = url.split('/')[url.split('/').length -1] // // 下载文件的名字
|
|
|
|
+ document.body.appendChild(link)
|
|
|
|
+ link.click()
|
|
|
|
+ // 在资源下载完成后 清除 占用的缓存资源
|
|
|
|
+ window.URL.revokeObjectURL(link.href)
|
|
|
|
+ document.body.removeChild(link)
|
|
|
|
+ })
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
- link.setAttribute('href', row.temporaryUrl)
|
|
|
|
- link.click()
|
|
|
|
|
|
+ const url = row.temporaryUrl // 完整的url则直接使用
|
|
|
|
+ // 这里是将url转成blob地址,
|
|
|
|
+ fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
|
|
|
|
+ link.href = URL.createObjectURL(blob)
|
|
|
|
+ console.log(link.href)
|
|
|
|
+ link.download = row.name || '' // 下载文件的名字
|
|
|
|
+ // a.download = url.split('/')[url.split('/').length -1] // // 下载文件的名字
|
|
|
|
+ document.body.appendChild(link)
|
|
|
|
+ link.click()
|
|
|
|
+ // 在资源下载完成后 清除 占用的缓存资源
|
|
|
|
+ window.URL.revokeObjectURL(link.href)
|
|
|
|
+ document.body.removeChild(link)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onPreview (url) {
|
|
onPreview (url) {
|