From d49209b3e18c9550f7c457ae3f5dd846b1787ae6 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 30 Jul 2019 16:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AF=95=E5=8D=B7=E7=9A=84ex?= =?UTF-8?q?cel,pdf,zip=E7=9A=84=E5=AF=BC=E5=87=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 6 +++++- app/controllers/zips_controller.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 126362fe8..c22bd3217 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1283,7 +1283,11 @@ class ExercisesController < ApplicationController @exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC") filename_ = "#{@exercise.user.real_name}_#{@course.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}.pdf" stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css" - render pdf: 'exercise_export/blank_exercise', filename: filename_, stylesheets: stylesheets + if params[:export].present? && params[:export] + normal_status(0,"正在下载中") + else + render pdf: 'exercise_export/blank_exercise', filename: filename_, stylesheets: stylesheets,cookies:{fileDownload:true,HttpOnly:false} + end end #空白试卷预览页面,仅供测试使用,无其他任何用途 diff --git a/app/controllers/zips_controller.rb b/app/controllers/zips_controller.rb index f4822b96b..f3ae9df5a 100644 --- a/app/controllers/zips_controller.rb +++ b/app/controllers/zips_controller.rb @@ -18,7 +18,11 @@ class ZipsController < ApplicationController exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url) file_name_ = filename_for_content_disposition(exercises.filename) - send_file exercises.ex_zip, filename: file_name_, type: 'application/zip' + if params[:export].present? && params[:export] + normal_status(0,"正在下载中") + else + send_file exercises.ex_zip, filename: file_name_, type: 'application/zip', cookies:{fileDownload:true,HttpOnly:false} + end rescue Exception => e normal_status(-1, e.message) end