Browse Source

视频相关

Lita-Tako 4 months ago
parent
commit
1999768544
1 changed files with 6 additions and 12 deletions
  1. 6 12
      src/utils/systemUtils.js

+ 6 - 12
src/utils/systemUtils.js

@@ -186,16 +186,10 @@ export const getQueryParams = (name) => {
186
 }
186
 }
187
 
187
 
188
 export const downloadLink = (url) => {
188
 export const downloadLink = (url) => {
189
-	const iframe = document.createElement('iframe')
190
-	iframe.style.display = 'none' // 防止影响页面
191
-	iframe.style.height = 0 // 防止影响页面
192
-	iframe.src = url
193
-	document.body.appendChild(iframe) // 这一行必须,iframe挂在到dom树上才会发请求
194
-	// 5分钟之后删除(onload方法对于下载链接不起作用,就先抠脚一下吧)
195
-	setTimeout(
196
-		function () {
197
-			iframe.remove()
198
-		},
199
-		5 * 60 * 1000
200
-	)
189
+	const a = document.createElement('a')
190
+	a.href = url
191
+	a.download = fileName || 'download'
192
+	document.body.appendChild(a)
193
+	a.click()
194
+	document.body.removeChild(a)
201
 }
195
 }