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

@ -29,7 +29,7 @@ const env = getClientEnvironment(publicUrl);
module.exports = { module.exports = {
// You may want 'eval' instead if you prefer to see the compiled output in DevTools. // 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 // 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. // These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle. // 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 course_id:coursesId
}, },
}).then((result)=>{ }).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'); let link = document.createElement('a');
document.body.appendChild(link); document.body.appendChild(link);
link.href = result.data.url; link.href = result.data.url;
@ -46,12 +55,15 @@ class Fileslistitem extends Component{
evt.initEvent("click", false, false); evt.initEvent("click", false, false);
link.dispatchEvent(evt); link.dispatchEvent(evt);
document.body.removeChild(link); document.body.removeChild(link);
}
}else{ }else{
this.setState({ this.setState({
Showoldfiles:true, Showoldfiles:true,
allfiles:result.data allfiles:result.data
}) })
} }
}).catch((error)=>{ }).catch((error)=>{
console.log(error) console.log(error)
}) })
@ -144,6 +156,7 @@ class Fileslistitem extends Component{
loadtype={this.state.Loadtype} loadtype={this.state.Loadtype}
/>:""} />:""}
<Showoldfiles <Showoldfiles
{...this.props}
visible={this.state.Showoldfiles} visible={this.state.Showoldfiles}
allfiles={this.state.allfiles} allfiles={this.state.allfiles}
closaoldfilesprops={this.closaoldfilesprops} closaoldfilesprops={this.closaoldfilesprops}

@ -42,6 +42,14 @@ class Showoldfiles extends Component{
this.props.closaoldfilesprops() 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(){ render(){
let {visible,allfiles}=this.props; 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}> <div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={allfiles.id}>
<li className="fl fontlefts"> <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> <span className={"newcolor-orange fl"}>当前版本</span>
</li> </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}> <div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={item.id} key={key}>
<li className="fl fontlefts"> <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>
<li className="fl filesves "> <li className="fl filesves ">

Loading…
Cancel
Save