|
|
|
@ -27,8 +27,18 @@ 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 newvalue=Base64.encode(value)
|
|
|
|
|
let {discussMessage,coursesId}=this.props
|
|
|
|
|
let file_id=discussMessage.id
|
|
|
|
|
let url="/files/"+file_id+"/histories.json"
|
|
|
|
@ -39,35 +49,14 @@ class Fileslistitem extends Component{
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
|
|
|
|
|
if(result.data.attachment_histories.length===0){
|
|
|
|
|
|
|
|
|
|
let link = document.createElement('a');
|
|
|
|
|
document.body.appendChild(link);
|
|
|
|
|
link.href = result.data.url;
|
|
|
|
|
console.log(value)
|
|
|
|
|
link.download = Base64.decode(newvalue);
|
|
|
|
|
//兼容火狐浏览器
|
|
|
|
|
let evt = document.createEvent("MouseEvents");
|
|
|
|
|
evt.initEvent("click", false, false);
|
|
|
|
|
link.dispatchEvent(evt);
|
|
|
|
|
document.body.removeChild(link);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // window.location.href=result.data.url;
|
|
|
|
|
// let url = window.URL.createObjectURL(new Blob([result.data.url]));
|
|
|
|
|
// let link = document.createElement('a');
|
|
|
|
|
// link.style.display = 'none';
|
|
|
|
|
// link.href = url;
|
|
|
|
|
// link.setAttribute('download',result.data.title);
|
|
|
|
|
// document.body.appendChild(link);
|
|
|
|
|
// link.click();
|
|
|
|
|
|
|
|
|
|
this.downloadfiles(result.data.url,filesname)
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
Showoldfiles:true,
|
|
|
|
|
allfiles:result.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// console.log(result)
|
|
|
|
|
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
|
console.log(error)
|
|
|
|
|
})
|
|
|
|
|