diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 404214dfc..0ce4fba46 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -27,6 +27,7 @@ class Fileslistitem extends Component{ this.props.Settingtypes(discussMessage.id) } showfiles=()=>{ + debugger let {discussMessage,coursesId}=this.props let file_id=discussMessage.id let url="/files/"+file_id+"/histories.json" @@ -35,12 +36,13 @@ class Fileslistitem extends Component{ course_id:coursesId }, }).then((result)=>{ + if(result.data.attachment_histories.length===0){ let link = document.createElement('a'); document.body.appendChild(link); link.href = result.data.url; - link.download = result.data.title; + link.download = ''; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); evt.initEvent("click", false, false); diff --git a/public/react/src/modules/courses/shixunHomework/Listofworks.js b/public/react/src/modules/courses/shixunHomework/Listofworks.js index 893747da6..c3604f314 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworks.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworks.js @@ -1359,14 +1359,16 @@ class Listofworks extends Component { }else{ // window.location.href("/api"+url); console.log("开始下载zip文件") - const type='application/zip'//ZIP文件 + // const type='application/zip'//ZIP文件 + const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件 + const blob = new Blob([response.data], { type: type }) const downloadElement = document.createElement('a') const href = window.URL.createObjectURL(blob) //后台再header中传文件名 const name = decodeURI(response.headers['content-disposition'].split('=')[1]) downloadElement.href = href - // downloadElement.download = name + downloadElement.download = '' document.body.appendChild(downloadElement) downloadElement.click() document.body.removeChild(downloadElement) // 下载完成移除元素 @@ -1387,6 +1389,12 @@ class Listofworks extends Component { // search: this.state.searchtext, // } // },{responseType: 'blob'}) + // 56S+5Yy65a+85biIX+iuoeeul+aAnee7tOWvvOiuujIwMTnmmKXlraPor77l,oIJfUHl0aG9u5a6e546w6YCJ5oup,.xls + // console.log(decodeURIComponent("b178a6c387c1dd2d4097b0dcaa19a043_1562205834")); + // console.log(decodeURI("b178a6c387c1dd2d4097b0dcaa19a043_1562205834")); + // console.log(Base64.decode("b178a6c387c1dd2d4097b0dcaa19a043_1562205834")); + // console.log(Base64.decode("56S-5Yy65a-85biIX-iuoeeul-aAnee7tOWvvOiuujIwMTnmmKXlraPor77loIJfUHl0aG9u5a6e546w6YCJ5oup")); + axios.get((url),{responseType: 'blob'}).then((response) => { console.log("1374"); console.log(response); @@ -1401,14 +1409,18 @@ class Listofworks extends Component { const downloadElement = document.createElement('a') const href = window.URL.createObjectURL(blob) //后台再header中传文件名 - const name = decodeURI(response.headers['content-disposition'].split('=')[1]) + // const name = decodeURI(response.headers['content-disposition'].split('=')[1]) console.log(response.headers['content-disposition'].split('=')[1]); - console.log(name); - console.log(decodeURIComponent(response.headers['content-disposition'].split('=')[1])); - console.log("1409"); + // console.log(name); + // console.log(decodeURIComponent(response.headers['content-disposition'].split('=')[1])); + console.log("1409"); console.log(Base64.decode(response.headers['content-disposition'].split('=')[1])); + const string = response.headers['content-disposition'].split('=')[1]; + var index=string.lastIndexOf("\."); + const name=obj.substring(0,index); + console.log(Base64.decode(name)); downloadElement.href = href - // downloadElement.download = name + downloadElement.download = Base64.decode(name)+".xlsx"; document.body.appendChild(downloadElement) downloadElement.click() @@ -1569,8 +1581,10 @@ class Listofworks extends Component { {this.props.isAdmin()?
  • 导出
  • :""} {this.props.isAdmin() ?