Эх сурвалжийг харах

受控文件查阅文件下载替换浏览器地址

zhonghuizhen 8 сар өмнө
parent
commit
ff1dcc6848

+ 8 - 0
src/views/component/fileTraining/index.vue

@@ -632,6 +632,14 @@ export default {
       if (this.isSuper || hasRole) {
       if (this.isSuper || hasRole) {
         const a = document.createElement('a')
         const a = document.createElement('a')
         a.href = this.optionFile.url
         a.href = this.optionFile.url
+
+        console.log('文件下载替换前地址:',a.href)
+        const url = new URL(a.href)
+        //替换文件下载路径为浏览器路径
+        url.host = window.location.host;
+        a.href = url.href
+        console.log('文件下载替换后地址:',a.href)
+        
         a.download = this.optionFile.data.fileName
         a.download = this.optionFile.data.fileName
         document.body.appendChild(a)
         document.body.appendChild(a)
         a.click()
         a.click()