From f9a2d947098932eaa08bc7df4b8925901179953b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 13:47:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 68d0f7542..cd46570bd 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -27,6 +27,17 @@ class Fileslistitem extends Component{ }) this.props.Settingtypes(discussMessage.id) } + + downloadfiles=(url,name)=>{ + const aLink = document.createElement('a'); + document.body.appendChild(aLink); + aLink.style.display='none'; + aLink.download =name; + aLink.href = url; + aLink.click(); + document.body.removeChild(aLink); + + } showfiles=(value)=>{ let {discussMessage,coursesId}=this.props let file_id=discussMessage.id @@ -38,17 +49,7 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - - const aLink = document.createElement('a'); - document.body.appendChild(aLink); - aLink.style.display='none'; - const objectUrl = window.URL.createObjectURL(result.data.url); - aLink.href = objectUrl; - aLink.download =result.data.title; - aLink.click(); - document.body.removeChild(aLink); - - + this.downloadfiles(result.data.url,filesname) }else{ this.setState({ Showoldfiles:true,