From 965f9b65f86f800465a12c1062cd5a6383c0cad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 16 Aug 2019 15:50:33 +0800 Subject: [PATCH 1/2] =?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/config/webpack.config.dev.js | 2 +- .../modules/courses/Resource/Fileslistitem.js | 25 ++++++++++++++----- .../courses/coursesPublic/Showoldfiles.js | 19 ++++++++++++-- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index 6e78fd410..510bcaa4f 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -29,7 +29,7 @@ const env = getClientEnvironment(publicUrl); module.exports = { // You may want 'eval' instead if you prefer to see the compiled output in DevTools. // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s - devtool: "cheap-module-eval-source-map", + // devtool: "cheap-module-eval-source-map", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index f0aec7f64..5832770f1 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -36,7 +36,16 @@ class Fileslistitem extends Component{ course_id:coursesId }, }).then((result)=>{ - if(result.data.attachment_histories.length===0){ + + if(result.data.attachment_histories.length===0){ + if(result.data.is_pdf===true){ + axios.get(result.data.url).then((result)=>{ + var binaryData = []; + binaryData.push(result.data); + this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + window.open(this.url); + }) + }else{ let link = document.createElement('a'); document.body.appendChild(link); link.href = result.data.url; @@ -46,12 +55,15 @@ class Fileslistitem extends Component{ evt.initEvent("click", false, false); link.dispatchEvent(evt); document.body.removeChild(link); + } }else{ - this.setState({ - Showoldfiles:true, - allfiles:result.data - }) - } + this.setState({ + Showoldfiles:true, + allfiles:result.data + }) + } + + }).catch((error)=>{ console.log(error) }) @@ -144,6 +156,7 @@ class Fileslistitem extends Component{ loadtype={this.state.Loadtype} />:""} { + axios.get(url).then((result)=>{ + var binaryData = []; + binaryData.push(result.data); + this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"})); + window.open(this.url); + }) + } render(){ let {visible,allfiles}=this.props; @@ -175,7 +183,10 @@ class Showoldfiles extends Component{
  • - {allfiles.title} + {allfiles.is_pdf===false? + {allfiles.title}: + this.showfiless(allfiles.url)} >{allfiles.title} + } 当前版本
  • @@ -191,7 +202,11 @@ class Showoldfiles extends Component{
  • - {item.title} + + {allfiles.is_pdf===false? + {item.title}: + this.showfiless(item.url)} >{item.title} + }
  • From 1677cea34dbf1a5b24a20dddbecc5d885f3da78b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 16 Aug 2019 16:01:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E8=80=81=E5=B8=88?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=8A=A0=E5=85=A5=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E8=AF=BE=E5=A0=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/users/update_account_service.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/services/users/update_account_service.rb b/app/services/users/update_account_service.rb index c8ba6da61..3f0aa8cc8 100644 --- a/app/services/users/update_account_service.rb +++ b/app/services/users/update_account_service.rb @@ -51,8 +51,10 @@ class Users::UpdateAccountService < ApplicationService if first_full_reward RewardGradeService.call(user, container_id: user.id, container_type: 'Account', score: 500) - - sms_notify_admin(user.lastname) if user.user_extension.teacher? + if user.user_extension.teacher? + join_course(user.id,1309, 2) + sms_notify_admin(user.lastname) + end end user @@ -73,4 +75,11 @@ class Users::UpdateAccountService < ApplicationService rescue => ex Util.logger_error(ex) end + + def join_course(user_id, course_id, identity) + course = Course.find_by(id: course_id) + return unless course + attr = {course_id: course_id, role: identity, user_id: user_id} + CourseMember.create!(attr) + end end \ No newline at end of file