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 01/12] 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 02/12] =?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 03/12] =?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 04/12] 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 05/12] =?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 06/12] =?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 07/12] =?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 08/12] =?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 09/12] =?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 10/12] 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 11/12] 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 12/12] =?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,