From c29c8253a4e0cb8e8afeec1f03c4de93c50f86f0 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 24 Jul 2019 18:16:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?monaca=20=E9=9C=80=E8=A6=81=E5=88=B7?= =?UTF-8?q?=E6=96=B0=EF=BC=8C=E4=B8=8D=E7=84=B6=E6=97=A0=E6=B3=95=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/page/MainContent.js | 2 +- public/react/src/modules/page/MainContentContainer.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/page/MainContent.js b/public/react/src/modules/page/MainContent.js index c03d49351..601c002a9 100644 --- a/public/react/src/modules/page/MainContent.js +++ b/public/react/src/modules/page/MainContent.js @@ -114,7 +114,7 @@ class MainContent extends Component { ? readRepoTimeout === true ?
代码加载失败, this.props.fetchRepositoryCode(this.props, null, null, true)}>重试 + onClick={() => this.props.fetchRepositoryCode(this.props, null, null, true, true)}>重试
:
diff --git a/public/react/src/modules/page/MainContentContainer.js b/public/react/src/modules/page/MainContentContainer.js index d24a5cefb..a437391d6 100644 --- a/public/react/src/modules/page/MainContentContainer.js +++ b/public/react/src/modules/page/MainContentContainer.js @@ -235,7 +235,7 @@ class MainContentContainer extends Component { } // arg_path 点击文件目录树时,传入的点击节点对应的path - fetchRepositoryCode( props, arg_path, type, isRetry) { + fetchRepositoryCode( props, arg_path, type, isRetry, retryAndRefresh) { const { challenge, showSnackbar, game, shixun, myshixun, hide_code } = props ? props : this.props; if (shixun.vnc == true) { // vnc模式下不需要加载代码 @@ -293,6 +293,10 @@ class MainContentContainer extends Component { // that._cancel = c; // }) }).then((fetchRepositoryCodeResponse) => { + if (retryAndRefresh && fetchRepositoryCodeResponse.data.content) { + window.location.reload() + return; + } // 空字符串还是正常切换 if (fetchRepositoryCodeResponse.data.status == 0) { readingRepoTimes = readingRepoTimes + 1; From aa2cc34cc9d0b1d27f0462a17df32bb2b2f07334 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 24 Jul 2019 18:23:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 55 ++++++++++++----------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 8eb7ffebc..07ab97cb5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -4,14 +4,15 @@ class AttachmentsController < ApplicationController before_action :require_login, :check_auth, except: [:show] before_action :find_file, only: %i[show destroy] + before_action :attachment_candown, only: [:show] include ApplicationHelper def show # 1. 优先跳到cdn # 2. 如果没有cdn,send_file - candown = attachment_candown @file - tip_exception("您没有权限下载该附件") if !candown + # candown = attachment_candown @file + # tip_exception(403,"您没有权限下载该附件") if !candown if @file.cloud_url.present? update_downloads(@file) redirect_to @file.cloud_url and return @@ -160,32 +161,32 @@ class AttachmentsController < ApplicationController edu_setting('public_cdn_host') + "/" + path end - def attachment_candown attachment - return true if current_user.admin? || current_user.business? - candown = false - if attachment.container && current_user.logged? - # 课堂资源、作业、毕设相关资源的权限判断 - if attachment.container.is_a?(Course) - course = attachment.container - candown = current_user.member_of_course?(course) || attachment.is_public == 1 - elsif attachment.container.is_a?(HomeworkCommon) || attachment.container.is_a?(GraduationTask) || attachment.container.is_a?(GraduationTopic) - course = attachment.container&.course - elsif attachment.container.is_a?(StudentWork) - course = attachment.container&.homework_common&.course - elsif attachment.container.is_a?(StudentWorksScore) - course = attachment.container&.student_work&.homework_common&.course - elsif attachment.container.is_a?(GraduationWork) - course = attachment.container&.graduation_task&.course - elsif attachment.container.is_a?(GraduationWorkScore) - course = attachment.container&.graduation_work&.graduation_task&.course - else - candown = true - end - - candown = !candown && course.present? ? current_user.member_of_course?(course) : candown - else + def attachment_candown + unless current_user.admin? || current_user.business? candown = true + if @file.container && current_user.logged? + # 课堂资源、作业、毕设相关资源的权限判断 + if @file.container.is_a?(Course) + course = @file.container + candown = current_user.member_of_course?(course) || @file.is_public == 1 + elsif @file.container.is_a?(HomeworkCommon) || @file.container.is_a?(GraduationTask) || @file.container.is_a?(GraduationTopic) + course = @file.container&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(StudentWork) + course = @file.container&.homework_common&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(StudentWorksScore) + course = @file.container&.student_work&.homework_common&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(GraduationWork) + course = @file.container&.graduation_task&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(GraduationWorkScore) + course = @file.container&.graduation_work&.graduation_task&.course + candown = current_user.member_of_course?(course) + end + tip_exception(409, "您没有权限进入") if course.present? && !candown + end end - candown end end From 7c21c728de62607f6f4cba2367cb30612b388a3f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 24 Jul 2019 18:29:17 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 07ab97cb5..a6c74818c 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -11,8 +11,6 @@ class AttachmentsController < ApplicationController def show # 1. 优先跳到cdn # 2. 如果没有cdn,send_file - # candown = attachment_candown @file - # tip_exception(403,"您没有权限下载该附件") if !candown if @file.cloud_url.present? update_downloads(@file) redirect_to @file.cloud_url and return @@ -185,7 +183,7 @@ class AttachmentsController < ApplicationController course = @file.container&.graduation_work&.graduation_task&.course candown = current_user.member_of_course?(course) end - tip_exception(409, "您没有权限进入") if course.present? && !candown + tip_exception(403, "您没有权限进入") if course.present? && !candown end end end