diff --git a/public/react/src/modules/courses/shixunHomework/Listofworks.js b/public/react/src/modules/courses/shixunHomework/Listofworks.js index 9606740dc..a720cffd4 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworks.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworks.js @@ -1350,21 +1350,10 @@ class Listofworks extends Component { },{responseType: 'blob'}).then((response) => { console.log("1342"); console.log(response); - if (response.status == 200) { - - var blob = new Blob([response.data]) - var downloadElement = document.createElement('a'); - var href = window.URL.createObjectURL(blob); //创建下载的链接 - let filename = response.headers.get('Content-Disposition'); - if (filename) { - filename = filename.match(/\"(.*)\"/)[1]; //提取文件名 - downloadElement.href = href; - downloadElement.download = filename; //下载后文件名 - document.body.appendChild(downloadElement); - downloadElement.click(); //点击下载 - document.body.removeChild(downloadElement); //下载完成移除元素 - } - window.URL.revokeObjectURL(href); //释放掉blob对象 + if(response.status === 200){ + window.open(url, '_blank'); + }else{ + } }).catch((error) => { console.log(error) @@ -1384,21 +1373,11 @@ class Listofworks extends Component { },{responseType: 'blob'}).then((response) => { console.log("1306"); console.log(response); - if (response.status == 200) { - var blob = new Blob([response.data]) - var downloadElement = document.createElement('a'); - var href = window.URL.createObjectURL(blob); //创建下载的链接 - let filename = response.headers.get('Content-Disposition'); - if (filename) { - filename = filename.match(/\"(.*)\"/)[1]; //提取文件名 - downloadElement.href = href; - downloadElement.download = filename; //下载后文件名 - document.body.appendChild(downloadElement); - downloadElement.click(); //点击下载 - document.body.removeChild(downloadElement); //下载完成移除元素 - } - window.URL.revokeObjectURL(href); //释放掉blob对象 - } + if(response.status === 200){ + window.open(url, '_blank'); + }else{ + + } }).catch((error) => { console.log(error) }); diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 19343ad79..f67eca6ab 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -1619,19 +1619,11 @@ class Trainingjobsetting extends Component { },{responseType: 'blob'}).then((response) => { console.log("326"); console.log(response); - var blob = new Blob([response.data]) - var downloadElement = document.createElement('a'); - var href = window.URL.createObjectURL(blob); //创建下载的链接 - let filename = response.headers.get('Content-Disposition'); - if (filename) { - filename = filename.match(/\"(.*)\"/)[1]; //提取文件名 - downloadElement.href = href; - downloadElement.download = filename; //下载后文件名 - document.body.appendChild(downloadElement); - downloadElement.click(); //点击下载 - document.body.removeChild(downloadElement); //下载完成移除元素 + if(response.status === 200){ + window.open(url, '_blank'); + }else{ + } - window.URL.revokeObjectURL(href); //释放掉blob对象 }).catch((error) => { console.log(error) @@ -1646,19 +1638,11 @@ class Trainingjobsetting extends Component { axios.get((url),{responseType: 'blob'}).then((response) => { console.log("339"); console.log(response); - var blob = new Blob([response.data]) - var downloadElement = document.createElement('a'); - var href = window.URL.createObjectURL(blob); //创建下载的链接 - let filename = response.headers.get('Content-Disposition'); - if (filename) { - filename = filename.match(/\"(.*)\"/)[1]; //提取文件名 - downloadElement.href = href; - downloadElement.download = filename; //下载后文件名 - document.body.appendChild(downloadElement); - downloadElement.click(); //点击下载 - document.body.removeChild(downloadElement); //下载完成移除元素 + if(response.status === 200){ + window.open(url, '_blank'); + }else{ + } - window.URL.revokeObjectURL(href); //释放掉blob对象 }).catch((error) => { console.log(error) diff --git a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js index d341aab6b..ab650aae2 100644 --- a/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js +++ b/public/react/src/modules/courses/shixunHomework/Workquestionandanswer.js @@ -330,19 +330,11 @@ class Workquestionandanswer extends Component { },{responseType: 'blob'}).then((response) => { console.log("326"); console.log(response); - var blob = new Blob([response.data]) - var downloadElement = document.createElement('a'); - var href = window.URL.createObjectURL(blob); //创建下载的链接 - let filename = response.headers.get('Content-Disposition'); - if (filename) { - filename = filename.match(/\"(.*)\"/)[1]; //提取文件名 - downloadElement.href = href; - downloadElement.download = filename; //下载后文件名 - document.body.appendChild(downloadElement); - downloadElement.click(); //点击下载 - document.body.removeChild(downloadElement); //下载完成移除元素 + if(response.status === 200){ + window.open(url, '_blank'); + }else{ + } - window.URL.revokeObjectURL(href); //释放掉blob对象 }).catch((error) => { console.log(error) @@ -357,19 +349,11 @@ class Workquestionandanswer extends Component { axios.get((url),{responseType: 'blob'}).then((response) => { console.log("339"); console.log(response); - var blob = new Blob([response.data]) - var downloadElement = document.createElement('a'); - var href = window.URL.createObjectURL(blob); //创建下载的链接 - let filename = response.headers.get('Content-Disposition'); - if (filename) { - filename = filename.match(/\"(.*)\"/)[1]; //提取文件名 - downloadElement.href = href; - downloadElement.download = filename; //下载后文件名 - document.body.appendChild(downloadElement); - downloadElement.click(); //点击下载 - document.body.removeChild(downloadElement); //下载完成移除元素 + if(response.status === 200){ + window.open(url, '_blank'); + }else{ + } - window.URL.revokeObjectURL(href); //释放掉blob对象 }).catch((error) => { console.log(error)