hjm 5 years ago
commit 2e0d3e4649

@ -23,22 +23,31 @@ export function SnackbarHOC(options = {}) {
}
// 全局的snackbar this.props.showSnackbar调用即可
showSnackbar(description, message = "提示",icon) {
// this.setState({
// snackbarOpen: true,
// snackbarText: text,
// snackbarVertical: vertical,
// snackbarHorizontal: horizontal,
// })
const data = {
message,
description
}
if (icon) {
data.icon = icon;
// showSnackbar(description, message = "提示",icon) {
// // this.setState({
// // snackbarOpen: true,
// // snackbarText: text,
// // snackbarVertical: vertical,
// // snackbarHorizontal: horizontal,
// // })
// const data = {
// message,
// description
// }
// if (icon) {
// data.icon = icon;
// }
// notification.open(data);
// }
showSnackbar(text, vertical, horizontal) {
this.setState({
snackbarOpen: true,
snackbarText: text,
snackbarVertical: vertical,
snackbarHorizontal: horizontal,
})
}
notification.open(data);
}
render() {
const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical } = this.state;

@ -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();
}else{
this.downloadfiles(result.data.url,filesname)
}else{
this.setState({
Showoldfiles:true,
allfiles:result.data
})
}
// console.log(result)
}).catch((error)=>{
console.log(error)
})

Loading…
Cancel
Save