Browse Source

fix: bug6743

ldong 3 weeks ago
parent
commit
98f6c268f5
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/mixins/index.js

+ 3 - 2
src/mixins/index.js

@@ -141,6 +141,7 @@ const mixins = {
 			const b=new http.Base64() 
 			const arr=url.split('/')
 			const _fileName=arr[arr.length-1]
+			const _fileType= _fileName.substring(_fileName.lastIndexOf(".") + 1)
 			const fileNameTypeArr = fileName.split('.')
 			const _fileNameTypeArr = _fileName.split('.')
 			const fileNameType = fileNameTypeArr.length>1?fileNameTypeArr[fileNameTypeArr.length-1]:''
@@ -160,7 +161,7 @@ const mixins = {
 				const blob = new Blob([content])
 				if ('download' in document.createElement('a')) {
 					const elink = document.createElement('a')
-					elink.download = fileNameType?fileName:(fileName+'.'+_fileNameType)
+					elink.download = fileName+'.'+_fileType
 					elink.style.display = 'none'
 					elink.href = window.URL.createObjectURL(blob)
 					document.body.appendChild(elink)
@@ -168,7 +169,7 @@ const mixins = {
 					window.URL.revokeObjectURL(elink.href)
 					document.body.removeChild(elink)
 				} else {
-					navigator.msSaveBlob(blob, fileNameType?fileName:(fileName+'.'+_fileNameType))
+					navigator.msSaveBlob(blob, fileName+'.'+_fileType)
 				}
 				successCb&&successCb()
 			}).catch(()=>{