|
|
@ -35,27 +35,27 @@ class Fileslistitem extends Component{
|
|
|
|
params:{
|
|
|
|
params:{
|
|
|
|
course_id:coursesId
|
|
|
|
course_id:coursesId
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).then((result)=>{
|
|
|
|
}).then((response)=>{
|
|
|
|
|
|
|
|
|
|
|
|
if(result.data.attachment_histories.length===0){
|
|
|
|
if(result.data.attachment_histories.length===0){
|
|
|
|
let link = document.createElement('a');
|
|
|
|
response.blob().then(blob => {
|
|
|
|
// link.href = window.URL.createObjectURL(new Blob([result.data.url]));
|
|
|
|
const aLink = document.createElement('a');
|
|
|
|
link.href = result.data.url;
|
|
|
|
document.body.appendChild(aLink);
|
|
|
|
link.download = result.data.title;
|
|
|
|
aLink.style.display='none';
|
|
|
|
//兼容火狐浏览器
|
|
|
|
const objectUrl = window.URL.createObjectURL(blob.data.url);
|
|
|
|
console.log(link)
|
|
|
|
aLink.href = objectUrl;
|
|
|
|
document.body.appendChild(link);
|
|
|
|
aLink.download =blob.data.title;
|
|
|
|
let evt = document.createEvent("MouseEvents");
|
|
|
|
aLink.click();
|
|
|
|
evt.initEvent("click", false, false);
|
|
|
|
document.body.removeChild(aLink);
|
|
|
|
link.dispatchEvent(evt);
|
|
|
|
});
|
|
|
|
document.body.removeChild(link);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
}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)
|
|
|
|
})
|
|
|
|
})
|
|
|
|