hjm 5 years ago
commit 2e0d3e4649

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

@ -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)
}) })

Loading…
Cancel
Save