diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 563724040..58305f589 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -39,17 +39,18 @@ class Fileslistitem extends Component{ if(result.data.attachment_histories.length===0){ if(result.data.is_pdf===true){ + this.props.ShowOnlinePdf(result.data.url) //预览pdf - axios({ - method:'get', - url:result.data.url, - responseType: 'arraybuffer', - }).then((result)=>{ - var binaryData = []; - binaryData.push(result.data); - this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - window.open(this.url); - }) + // axios({ + // method:'get', + // url:result.data.url, + // responseType: 'arraybuffer', + // }).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); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 483768271..1b2b89565 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -43,16 +43,17 @@ class Showoldfiles extends Component{ } showfiless=(url)=>{ - axios({ - method:'get', - url:url, - responseType: 'arraybuffer', - }).then((result)=>{ - var binaryData = []; - binaryData.push(result.data); - this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); - window.open(this.url); - }) + // axios({ + // method:'get', + // url:url, + // responseType: 'arraybuffer', + // }).then((result)=>{ + // var binaryData = []; + // binaryData.push(result.data); + // this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + // window.open(this.url); + // }) + this.props.ShowOnlinePdf(url) } render(){ let {visible,allfiles}=this.props; diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index f87f128a1..690e8bc80 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -321,6 +321,19 @@ export function TPMIndexHOC(WrappedComponent) { checkIfProfileCompleted = () => { return this.state.current_user && this.state.current_user.profile_completed } + + ShowOnlinePdf = (url) => { + return axios({ + method:'get', + url:url, + responseType: 'arraybuffer', + }).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{Headertop,Footerdown, isRender, AccountProfiletype}=this.state; const common = { @@ -334,11 +347,11 @@ export function TPMIndexHOC(WrappedComponent) { isNotMember: this.isNotMember, isUserid:this.state.coursedata&&this.state.coursedata.userid, fetchUser: this.fetchUser, - showLoginDialog: this.showLoginDialog, checkIfLogin: this.checkIfLogin, showProfileCompleteDialog: this.showProfileCompleteDialog, checkIfProfileCompleted: this.checkIfProfileCompleted, + ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url) } return (