dev_winse
杨树明 6 years ago
parent 14ecd68aa4
commit 965f9b65f8

@ -29,7 +29,7 @@ const env = getClientEnvironment(publicUrl);
module.exports = {
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s
devtool: "cheap-module-eval-source-map",
// devtool: "cheap-module-eval-source-map",
// 开启调试
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.

@ -36,7 +36,16 @@ class Fileslistitem extends Component{
course_id:coursesId
},
}).then((result)=>{
if(result.data.attachment_histories.length===0){
if(result.data.attachment_histories.length===0){
if(result.data.is_pdf===true){
axios.get(result.data.url).then((result)=>{
var binaryData = [];
binaryData.push(result.data);
this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"}));
window.open(this.url);
})
}else{
let link = document.createElement('a');
document.body.appendChild(link);
link.href = result.data.url;
@ -46,12 +55,15 @@ class Fileslistitem extends Component{
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
}
}else{
this.setState({
Showoldfiles:true,
allfiles:result.data
})
}
this.setState({
Showoldfiles:true,
allfiles:result.data
})
}
}).catch((error)=>{
console.log(error)
})
@ -144,6 +156,7 @@ class Fileslistitem extends Component{
loadtype={this.state.Loadtype}
/>:""}
<Showoldfiles
{...this.props}
visible={this.state.Showoldfiles}
allfiles={this.state.allfiles}
closaoldfilesprops={this.closaoldfilesprops}

@ -42,6 +42,14 @@ class Showoldfiles extends Component{
this.props.closaoldfilesprops()
}
showfiless=(url)=>{
axios.get(url).then((result)=>{
var binaryData = [];
binaryData.push(result.data);
this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"}));
window.open(this.url);
})
}
render(){
let {visible,allfiles}=this.props;
@ -175,7 +183,10 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={allfiles.id}>
<li className="fl fontlefts">
<a className={"isabox"} href={allfiles.url}>{allfiles.title}</a>
{allfiles.is_pdf===false?
<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>:
<a className={"isabox"} onClick={()=>this.showfiless(allfiles.url)} >{allfiles.title}</a>
}
<span className={"newcolor-orange fl"}>当前版本</span>
</li>
@ -191,7 +202,11 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={item.id} key={key}>
<li className="fl fontlefts">
<a className={"isabox"} href={item.url}>{item.title}</a>
{allfiles.is_pdf===false?
<a className={"isabox"} href={item.url}>{item.title}</a>:
<a className={"isabox"} onClick={()=>this.showfiless(item.url)} >{item.title}</a>
}
</li>
<li className="fl filesves ">

Loading…
Cancel
Save