From f72237a3b549502e66eee16cd6de9212deb0c6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 10:03:16 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 6239f1b3d..1af027757 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -42,7 +42,7 @@ class Fileslistitem extends Component{ let link = document.createElement('a'); document.body.appendChild(link); link.href = result.data.url; - console.log(filesname) + console.log(value) link.download = value; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); From f102b5a8adf02580bca9884409fb43758e73bcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Sat, 6 Jul 2019 10:05:13 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/shixunHomework/Listofworks.js | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/Listofworks.js b/public/react/src/modules/courses/shixunHomework/Listofworks.js index db008e2c4..5dd049441 100644 --- a/public/react/src/modules/courses/shixunHomework/Listofworks.js +++ b/public/react/src/modules/courses/shixunHomework/Listofworks.js @@ -1340,14 +1340,15 @@ class Listofworks extends Component { // 导出实习报告批量 internshipreport = (url)=>{ console.log("internshipreport"); - // params: { - // homework_common_id: homeworkid, - // work_status: this.state.course_groupyslstwo, - // course_group: this.state.checkedValuesineinfo, - // search: this.state.searchtext, - // } - // let url = "/zip/shixun_report"; - // let homeworkid = this.props.match.params.homeworkid; + var struy=""; + try { + struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm'); + struy=struy.replace(/-/g,""); + }catch (e) { + console.log(1347); + console.log(e); + } + axios.get((url),{responseType: 'blob'}).then((response) => { console.log("1350"); console.log(response); @@ -1363,19 +1364,10 @@ class Listofworks extends Component { const blob = new Blob([response.data], { type: type }) const downloadElement = document.createElement('a') const href = window.URL.createObjectURL(blob) - //后台再header中传文件名 - // console.log(Base64.decode(response.headers['content-disposition'].split('=')[1])); const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); + console.log(response.headers['content-disposition'].split('=')[1]); downloadElement.href = href - var now=""; - try { - now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+"" - console.log(now); - - } catch (e) { - console.log("1376"); - } - downloadElement.download = string+now+".zip" + downloadElement.download = string+struy+".zip" document.body.appendChild(downloadElement) downloadElement.click() document.body.removeChild(downloadElement) // 下载完成移除元素 @@ -1388,6 +1380,17 @@ class Listofworks extends Component { // 课堂学生成绩的导出下载 Classstudentachievement=(url)=>{ console.log("Classstudentachievement"); + // console.log(); + var struy=""; + try { + struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm'); + struy=struy.replace(/-/g,""); + }catch (e) { + console.log(1397); + console.log(e); + } + + axios.get((url),{responseType: 'blob'}).then((response) => { console.log("1374"); console.log(response); @@ -1401,21 +1404,10 @@ class Listofworks extends Component { const blob = new Blob([response.data], { type: type }) const downloadElement = document.createElement('a') const href = window.URL.createObjectURL(blob) - //后台再header中传文件名 - // console.log("1409"); - // console.log(Base64.decode(response.headers['content-disposition'].split('=')[1])); const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); - var now=""; - try { - now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+"" - console.log("1422"); - console.log(now); - - } catch (e) { - console.log("1432"); - } + console.log(response.headers['content-disposition'].split('=')[1]); downloadElement.href = href - downloadElement.download =string+now+".xlsx"; + downloadElement.download =string+struy+".xlsx"; document.body.appendChild(downloadElement) downloadElement.click() document.body.removeChild(downloadElement) // 下载完成移除元素 From a9c694225649cc02a9b459ef3a393e9a562442fe Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 6 Jul 2019 10:13:30 +0800 Subject: [PATCH 03/19] display --- .../react/src/context/TPIContextProvider.js | 79 +++++++++++++++---- .../react/src/modules/page/main/ActionView.js | 18 +++-- 2 files changed, 77 insertions(+), 20 deletions(-) diff --git a/public/react/src/context/TPIContextProvider.js b/public/react/src/context/TPIContextProvider.js index ae88bf865..3e7695847 100644 --- a/public/react/src/context/TPIContextProvider.js +++ b/public/react/src/context/TPIContextProvider.js @@ -54,6 +54,8 @@ const testSetsExpandedArrayInitVal = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false] window.__fetchAllFlag = false; // 是否调用过fetchAll TODO 如何多次使用provider? + +const $ = window.$ class TPIContextProvider extends Component { constructor(props) { super(props) @@ -592,13 +594,48 @@ pop_box_new(htmlvalue, 480, 182); currentPassedGameGainExperience: experience, }) } + initDisplayInterval = () => { + if (this.showWebDisplayButtonTimeout) { + window.clearTimeout(this.showWebDisplayButtonTimeout) + } + this.showWebDisplayButtonTimeout = window.setTimeout(() => { + this.setState({ challenge: update(challenge, + { + showWebDisplayButton: { $set: false }, + }) + }) + this.showWebDisplayButtonTimeout = null + }, 61 * 1000) + + let remain = 60 + if (this.displayInterval) { + window.clearInterval(this.displayInterval) + } + this.displayInterval = window.setInterval(() => { + const button = $('#showWebDisplayButton'); + if (button.length) { + button.html(`查看效果(${remain})`) + if (remain == 0) { + button.html('查看效果') + } + } + if (remain == 0) { + window.clearInterval(this.displayInterval) + this.displayInterval = null + return; + } + + remain -= 1; + }, 1000) + } language_display(data) { const { game, tomcat_url } = this.state; - const $ = window.$; const challenge = Object.assign({}, this.state.challenge) if(challenge.isWeb && data.port != -1) { // var $result = $("#php_display"); challenge.showWebDisplayButton = true; // ActionView处是否出现查看效果按钮 + this.initDisplayInterval() + const path = challenge.web_route || challenge.path const webDisplayUrl = `${tomcat_url}:${data.port}/${path}` challenge.webDisplayUrl = webDisplayUrl @@ -653,24 +690,11 @@ pop_box_new(htmlvalue, 480, 182); const currentGamePassed = this.props.game !== 2 && status === 2 - currentGamePassed && this.language_display(response); + // 评测通过了,立即同步costTime currentGamePassed && this._updateCostTime(true, true); - if (currentGamePassed) { - game.status = 2; - game.next_game = next_game; - - } else { - this.showDialog({ - contentText:
-
评测未通过
-
详情请参见“测试结果”
-
, - isSingleButton: true - }) - } const output_sets = { "test_sets": test_sets, @@ -689,6 +713,31 @@ pop_box_new(htmlvalue, 480, 182); // output_sets.test_sets_array = test_sets_array; // } + // 检查是否编译通过 + let compileSuccess = false; + if (test_sets && test_sets.length) { + test_sets.some((item) => { + if (item.compile_success) { + compileSuccess = true; + return true; + } + }) + } + + compileSuccess && this.language_display(response); + if (currentGamePassed) { + game.status = 2; + game.next_game = next_game; + } else { + this.showDialog({ + contentText:
+
评测未通过
+
详情请参见“测试结果”
+
, + isSingleButton: true + }) + } + this.setState({ testSetsExpandedArray: testSetsExpandedArrayInitVal.slice(0), // 重置测试集展开状态 diff --git a/public/react/src/modules/page/main/ActionView.js b/public/react/src/modules/page/main/ActionView.js index e0e52de9e..fff7d416d 100644 --- a/public/react/src/modules/page/main/ActionView.js +++ b/public/react/src/modules/page/main/ActionView.js @@ -25,7 +25,14 @@ const styles = theme => ({ color: '#4CACFF', border: '1px solid #4CACFF' } + }, + hoverButton: { + margin: theme.spacing.unit, + height: '30px', + padding: '0 16px', + color: '#4CACFF', + border: '1px solid #4CACFF' }, buttonText: { color: '#1B4061 !important', @@ -64,11 +71,12 @@ class ActionView extends Component { {/*将第一个按钮改为visibility方式隐藏,不然加载时测评按钮会出现没有垂直居中的情况*/} - - + + + { !gameBuilding && From f1894db89232d02dd54671733c815366a002f4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 10:16:39 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 1af027757..6b68386fb 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -5,7 +5,8 @@ import {Link} from 'react-router-dom'; import {getImageUrl} from 'educoder'; import axios from 'axios' import {getUrl} from 'educoder'; -import moment from 'moment'; +import moment from 'moment' +import { Base64 } from 'js-base64'; import CoursesListType from '../coursesPublic/CoursesListType'; import Showoldfiles from "../coursesPublic/Showoldfiles"; import Modals from '../../modals/Modals'; @@ -27,7 +28,7 @@ class Fileslistitem extends Component{ this.props.Settingtypes(discussMessage.id) } showfiles=(value)=>{ - + let newvalue=Base64.encode(value) let {discussMessage,coursesId}=this.props let file_id=discussMessage.id let url="/files/"+file_id+"/histories.json" @@ -43,7 +44,7 @@ class Fileslistitem extends Component{ document.body.appendChild(link); link.href = result.data.url; console.log(value) - link.download = value; + link.download = Base64.decode(newvalue); //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); evt.initEvent("click", false, false); From 2277013898cd887deaa3a81e39327af0fe924ee3 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 6 Jul 2019 10:21:22 +0800 Subject: [PATCH 05/19] challenge --- public/react/src/context/TPIContextProvider.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/react/src/context/TPIContextProvider.js b/public/react/src/context/TPIContextProvider.js index 3e7695847..3cb725c34 100644 --- a/public/react/src/context/TPIContextProvider.js +++ b/public/react/src/context/TPIContextProvider.js @@ -595,6 +595,7 @@ pop_box_new(htmlvalue, 480, 182); }) } initDisplayInterval = () => { + const challenge = this.state.challenge if (this.showWebDisplayButtonTimeout) { window.clearTimeout(this.showWebDisplayButtonTimeout) } From 2d0a22153f8ed3fdc55f99c4f02aaad789ea61a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 10:23:30 +0800 Subject: [PATCH 06/19] b --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 6b68386fb..a7123f7b8 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -43,7 +43,7 @@ class Fileslistitem extends Component{ let link = document.createElement('a'); document.body.appendChild(link); link.href = result.data.url; - console.log(value) + console.log(newvalue) link.download = Base64.decode(newvalue); //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); From 7b693c49c2f306daed6f5f56897a846c401f1163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 10:32:16 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/Resource/Fileslistitem.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index a7123f7b8..0b65a6f9f 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -46,10 +46,16 @@ class Fileslistitem extends Component{ console.log(newvalue) link.download = Base64.decode(newvalue); //兼容火狐浏览器 - let evt = document.createEvent("MouseEvents"); - evt.initEvent("click", false, false); - link.dispatchEvent(evt); - document.body.removeChild(link); + // let evt = document.createEvent("MouseEvents"); + // evt.initEvent("click", false, false); + // link.dispatchEvent(evt); + // document.body.removeChild(link); + + link.style.display = 'none'; + + link.setAttribute('download',result.data.title); + document.body.appendChild(link); + link.click(); // // window.location.href=result.data.url; From 77bf53215f9834032b508a416cfe2d4695509c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 10:33:21 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/common/SnackbarHOC.js | 39 ++++++++++++++++---------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/public/react/src/common/SnackbarHOC.js b/public/react/src/common/SnackbarHOC.js index a59607bf4..d66b697ca 100644 --- a/public/react/src/common/SnackbarHOC.js +++ b/public/react/src/common/SnackbarHOC.js @@ -23,22 +23,31 @@ export function SnackbarHOC(options = {}) { } // 全局的snackbar this.props.showSnackbar调用即可 - showSnackbar(description, message = "提示",icon) { - // this.setState({ - // snackbarOpen: true, - // snackbarText: text, - // snackbarVertical: vertical, - // snackbarHorizontal: horizontal, - // }) - const data = { - message, - description - } - if (icon) { - data.icon = icon; + // showSnackbar(description, message = "提示",icon) { + // // this.setState({ + // // snackbarOpen: true, + // // snackbarText: text, + // // snackbarVertical: vertical, + // // snackbarHorizontal: horizontal, + // // }) + // const data = { + // message, + // description + // } + // if (icon) { + // data.icon = icon; + // } + // notification.open(data); + // } + + showSnackbar(text, vertical, horizontal) { + this.setState({ + snackbarOpen: true, + snackbarText: text, + snackbarVertical: vertical, + snackbarHorizontal: horizontal, + }) } - notification.open(data); - } render() { const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical } = this.state; From 027dab3f9ba4fbf02c8c8dd076036b9664e7a765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 10:41:05 +0800 Subject: [PATCH 09/19] b --- .../react/src/modules/courses/Resource/Fileslistitem.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 0b65a6f9f..4ab29ab3f 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -44,20 +44,16 @@ class Fileslistitem extends Component{ document.body.appendChild(link); link.href = result.data.url; console.log(newvalue) - link.download = Base64.decode(newvalue); + // link.download = Base64.decode(newvalue); //兼容火狐浏览器 // let evt = document.createEvent("MouseEvents"); // evt.initEvent("click", false, false); // link.dispatchEvent(evt); // document.body.removeChild(link); - - link.style.display = 'none'; - + link.style.display = 'none'; link.setAttribute('download',result.data.title); document.body.appendChild(link); link.click(); - - // // window.location.href=result.data.url; // let url = window.URL.createObjectURL(new Blob([result.data.url])); // let link = document.createElement('a'); From f423e2156134c260e4e760adc9884ec2ce2bf5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 12:21:03 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 4ab29ab3f..5eef94d9f 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -31,6 +31,10 @@ class Fileslistitem extends Component{ let newvalue=Base64.encode(value) let {discussMessage,coursesId}=this.props let file_id=discussMessage.id + let link = document.createElement('a'); + document.body.appendChild(link); + link.download = Base64.decode(newvalue); + let url="/files/"+file_id+"/histories.json" axios.get(url,{ params:{ @@ -39,21 +43,15 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - - let link = document.createElement('a'); - document.body.appendChild(link); link.href = result.data.url; - console.log(newvalue) - // link.download = Base64.decode(newvalue); + link.style.display = 'none'; + document.body.appendChild(link); + link.click(); //兼容火狐浏览器 // let evt = document.createEvent("MouseEvents"); // evt.initEvent("click", false, false); // link.dispatchEvent(evt); // document.body.removeChild(link); - link.style.display = 'none'; - link.setAttribute('download',result.data.title); - document.body.appendChild(link); - link.click(); // // window.location.href=result.data.url; // let url = window.URL.createObjectURL(new Blob([result.data.url])); // let link = document.createElement('a'); From 6a75a6c56adb6c0ab6403424f755e7a7f3405140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 12:35:03 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/Resource/Fileslistitem.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 5eef94d9f..239fd34a4 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -43,10 +43,10 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - link.href = result.data.url; - link.style.display = 'none'; - document.body.appendChild(link); - link.click(); + // link.href = result.data.url; + // link.style.display = 'none'; + // document.body.appendChild(link); + // link.click(); //兼容火狐浏览器 // let evt = document.createEvent("MouseEvents"); // evt.initEvent("click", false, false); @@ -60,7 +60,7 @@ class Fileslistitem extends Component{ // link.setAttribute('download',result.data.title); // document.body.appendChild(link); // link.click(); - + window.open=result.data.url; }else{ this.setState({ Showoldfiles:true, From 1414b85c6b91f030e23676cb2c1276cc1a52a465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 12:42:48 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 239fd34a4..a9860f1e2 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -60,7 +60,7 @@ class Fileslistitem extends Component{ // link.setAttribute('download',result.data.title); // document.body.appendChild(link); // link.click(); - window.open=result.data.url; + window.open(result.data.url); }else{ this.setState({ Showoldfiles:true, From 32b94f640d9890d69eb143fe0f47f63c6823fd8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 12:55:40 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 239fd34a4..c0a55ee80 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -28,13 +28,8 @@ class Fileslistitem extends Component{ this.props.Settingtypes(discussMessage.id) } showfiles=(value)=>{ - let newvalue=Base64.encode(value) let {discussMessage,coursesId}=this.props let file_id=discussMessage.id - let link = document.createElement('a'); - document.body.appendChild(link); - link.download = Base64.decode(newvalue); - let url="/files/"+file_id+"/histories.json" axios.get(url,{ params:{ @@ -43,24 +38,17 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - // link.href = result.data.url; - // link.style.display = 'none'; - // document.body.appendChild(link); - // link.click(); - //兼容火狐浏览器 - // let evt = document.createEvent("MouseEvents"); - // evt.initEvent("click", false, false); - // link.dispatchEvent(evt); - // document.body.removeChild(link); - // // window.location.href=result.data.url; - // let url = window.URL.createObjectURL(new Blob([result.data.url])); - // let link = document.createElement('a'); - // link.style.display = 'none'; - // link.href = url; - // link.setAttribute('download',result.data.title); - // document.body.appendChild(link); - // link.click(); - window.open=result.data.url; + let link = document.createElement('a'); + // link.href = window.URL.createObjectURL(new Blob([result.data.url])); + link.href = result.data.url; + link.download = result.data.title; + //兼容火狐浏览器 + console.log(link) + document.body.appendChild(link); + let evt = document.createEvent("MouseEvents"); + evt.initEvent("click", false, false); + link.dispatchEvent(evt); + document.body.removeChild(link); }else{ this.setState({ Showoldfiles:true, From fc354bc549e9c59631f34dd0f2b7a93fd3829148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 13:02:19 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index c0a55ee80..3e1e21810 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -35,27 +35,27 @@ class Fileslistitem extends Component{ params:{ course_id:coursesId }, - }).then((result)=>{ + }).then((response)=>{ if(result.data.attachment_histories.length===0){ - let link = document.createElement('a'); - // link.href = window.URL.createObjectURL(new Blob([result.data.url])); - link.href = result.data.url; - link.download = result.data.title; - //兼容火狐浏览器 - console.log(link) - document.body.appendChild(link); - let evt = document.createEvent("MouseEvents"); - evt.initEvent("click", false, false); - link.dispatchEvent(evt); - document.body.removeChild(link); - }else{ + response.blob().then(blob => { + const aLink = document.createElement('a'); + document.body.appendChild(aLink); + aLink.style.display='none'; + const objectUrl = window.URL.createObjectURL(blob.data.url); + aLink.href = objectUrl; + aLink.download =blob.data.title; + aLink.click(); + document.body.removeChild(aLink); + }); + + }else{ this.setState({ Showoldfiles:true, allfiles:result.data }) } - // console.log(result) + }).catch((error)=>{ console.log(error) }) From 2cbf3f80304bbc4ff49189b69c2ff9f7dbbc6e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 13:06:48 +0800 Subject: [PATCH 15/19] b --- public/react/src/modules/courses/Resource/Fileslistitem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 3e1e21810..d068e86df 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -35,10 +35,10 @@ class Fileslistitem extends Component{ params:{ course_id:coursesId }, - }).then((response)=>{ + }).then((result)=>{ if(result.data.attachment_histories.length===0){ - response.blob().then(blob => { + result.blob().then(blob => { const aLink = document.createElement('a'); document.body.appendChild(aLink); aLink.style.display='none'; From f38091a59a549ebd7fb8f101806313c981fcf9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 13:13:09 +0800 Subject: [PATCH 16/19] b --- .../modules/courses/Resource/Fileslistitem.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index d068e86df..68d0f7542 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -38,16 +38,16 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - result.blob().then(blob => { - const aLink = document.createElement('a'); - document.body.appendChild(aLink); - aLink.style.display='none'; - const objectUrl = window.URL.createObjectURL(blob.data.url); - aLink.href = objectUrl; - aLink.download =blob.data.title; - aLink.click(); - document.body.removeChild(aLink); - }); + + const aLink = document.createElement('a'); + document.body.appendChild(aLink); + aLink.style.display='none'; + const objectUrl = window.URL.createObjectURL(result.data.url); + aLink.href = objectUrl; + aLink.download =result.data.title; + aLink.click(); + document.body.removeChild(aLink); + }else{ this.setState({ From f9a2d947098932eaa08bc7df4b8925901179953b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 13:47:32 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 68d0f7542..cd46570bd 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -27,6 +27,17 @@ class Fileslistitem extends Component{ }) this.props.Settingtypes(discussMessage.id) } + + downloadfiles=(url,name)=>{ + const aLink = document.createElement('a'); + document.body.appendChild(aLink); + aLink.style.display='none'; + aLink.download =name; + aLink.href = url; + aLink.click(); + document.body.removeChild(aLink); + + } showfiles=(value)=>{ let {discussMessage,coursesId}=this.props let file_id=discussMessage.id @@ -38,17 +49,7 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - - const aLink = document.createElement('a'); - document.body.appendChild(aLink); - aLink.style.display='none'; - const objectUrl = window.URL.createObjectURL(result.data.url); - aLink.href = objectUrl; - aLink.download =result.data.title; - aLink.click(); - document.body.removeChild(aLink); - - + this.downloadfiles(result.data.url,filesname) }else{ this.setState({ Showoldfiles:true, From 2293487e85f969fcaaa5b2c0da54d7b0e1a34f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 13:51:44 +0800 Subject: [PATCH 18/19] b --- public/react/src/modules/courses/Resource/Fileslistitem.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index cd46570bd..91d4738d5 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -30,13 +30,12 @@ class Fileslistitem extends Component{ downloadfiles=(url,name)=>{ const aLink = document.createElement('a'); - document.body.appendChild(aLink); aLink.style.display='none'; aLink.download =name; aLink.href = url; + document.body.appendChild(aLink); aLink.click(); - document.body.removeChild(aLink); - + // document.body.removeChild(aLink); } showfiles=(value)=>{ let {discussMessage,coursesId}=this.props @@ -49,7 +48,7 @@ class Fileslistitem extends Component{ }).then((result)=>{ if(result.data.attachment_histories.length===0){ - this.downloadfiles(result.data.url,filesname) + this.downloadfiles(result.data.url,result.data.title) }else{ this.setState({ Showoldfiles:true, From e8ff20d94cb59930d9958e390c3edb2ac93314c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Sat, 6 Jul 2019 13:58:15 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Resource/Fileslistitem.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index 91d4738d5..6a1e16d6d 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -31,7 +31,8 @@ class Fileslistitem extends Component{ downloadfiles=(url,name)=>{ const aLink = document.createElement('a'); aLink.style.display='none'; - aLink.download =name; + console.log(name) + aLink.setAttribute('download',name) aLink.href = url; document.body.appendChild(aLink); aLink.click();