|
|
@ -27,8 +27,18 @@ class Fileslistitem extends Component{
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.props.Settingtypes(discussMessage.id)
|
|
|
|
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)=>{
|
|
|
|
showfiles=(value)=>{
|
|
|
|
let newvalue=Base64.encode(value)
|
|
|
|
|
|
|
|
let {discussMessage,coursesId}=this.props
|
|
|
|
let {discussMessage,coursesId}=this.props
|
|
|
|
let file_id=discussMessage.id
|
|
|
|
let file_id=discussMessage.id
|
|
|
|
let url="/files/"+file_id+"/histories.json"
|
|
|
|
let url="/files/"+file_id+"/histories.json"
|
|
|
@ -39,35 +49,14 @@ class Fileslistitem extends Component{
|
|
|
|
}).then((result)=>{
|
|
|
|
}).then((result)=>{
|
|
|
|
|
|
|
|
|
|
|
|
if(result.data.attachment_histories.length===0){
|
|
|
|
if(result.data.attachment_histories.length===0){
|
|
|
|
|
|
|
|
this.downloadfiles(result.data.url,filesname)
|
|
|
|
let link = document.createElement('a');
|
|
|
|
}else{
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
Showoldfiles:true,
|
|
|
|
Showoldfiles:true,
|
|
|
|
allfiles:result.data
|
|
|
|
allfiles:result.data
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// console.log(result)
|
|
|
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
}).catch((error)=>{
|
|
|
|
console.log(error)
|
|
|
|
console.log(error)
|
|
|
|
})
|
|
|
|
})
|
|
|
|