From 0746014dbaafc72920d41310030f0bad11eac6d2 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Sat, 17 Aug 2019 09:34:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=92=8C=E5=85=B6=E4=BB=96=E9=99=84=E4=BB=B6=E7=9A=84=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- app/views/files/histories.json.jbuilder | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6f2e1720..099d45406 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -258,7 +258,7 @@ module ApplicationHelper end def download_url attachment - attachment_path(attachment).gsub("/api","") + attachment_path(attachment) end # 耗时:天、小时、分、秒 diff --git a/app/views/files/histories.json.jbuilder b/app/views/files/histories.json.jbuilder index 7039752e7..ed322bb17 100644 --- a/app/views/files/histories.json.jbuilder +++ b/app/views/files/histories.json.jbuilder @@ -1,3 +1,9 @@ -json.partial! 'attachments/attachment_small', attachment: @file +# json.partial! 'attachments/attachment_small', attachment: @file +json.id @file.id +json.title @file.title +json.filesize number_to_human_size(@file.filesize) +json.url download_url(@file).gsub("/api","") +json.created_on @file.created_on +json.is_pdf @file.is_pdf? json.partial! "attachment_histories/list", attachment_histories: @attachment_histories From 05b09597defc1f612470bacd7b380f8ecd668677 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, 17 Aug 2019 09:39:16 +0800 Subject: [PATCH 2/2] 1 --- public/react/src/modules/courses/Resource/Fileslistitem.js | 4 ++-- .../react/src/modules/courses/coursesPublic/Showoldfiles.js | 6 +++--- 2 files 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 b65297884..563724040 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{ //预览pdf axios({ method:'get', - url:"http:"+window.location.host+result.data.url, + url:result.data.url, responseType: 'arraybuffer', }).then((result)=>{ var binaryData = []; @@ -53,7 +53,7 @@ class Fileslistitem extends Component{ }else{ let link = document.createElement('a'); document.body.appendChild(link); - link.href = result.data.url; + link.href = "/api"+result.data.url; link.download = result.data.title; //兼容火狐浏览器 let evt = document.createEvent("MouseEvents"); diff --git a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js index 2c682ec19..483768271 100644 --- a/public/react/src/modules/courses/coursesPublic/Showoldfiles.js +++ b/public/react/src/modules/courses/coursesPublic/Showoldfiles.js @@ -45,7 +45,7 @@ class Showoldfiles extends Component{ showfiless=(url)=>{ axios({ method:'get', - url:"http:"+window.location.host+url, + url:url, responseType: 'arraybuffer', }).then((result)=>{ var binaryData = []; @@ -188,7 +188,7 @@ class Showoldfiles extends Component{
  • {allfiles.is_pdf===false? - {allfiles.title}: + {allfiles.title}: this.showfiless(allfiles.url)} >{allfiles.title} } 当前版本 @@ -208,7 +208,7 @@ class Showoldfiles extends Component{
  • {item.is_pdf===false? - {item.title}: + {item.title}: this.showfiless(item.url)} >{item.title} }