diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c1fa48be8..54b1725f9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -289,6 +289,11 @@ class FilesController < ApplicationController @old_attachment.save! @new_attachment.delete end + if params[:name].present? && params[:link].present? + tip_exception("资源名称不能超过60个字符") if params[:name].strip.length > 60 + @old_attachment.filename = params[:name].strip + @old_attachment.link = params[:link].strip + end @old_attachment.is_public = is_public == true && @course.is_public == 1 ? 1 : 0 @old_attachment.is_publish = @atta_is_publish @old_attachment.delay_publish = @atta_delay_publish diff --git a/app/views/attachments/_attachment.json.jbuilder b/app/views/attachments/_attachment.json.jbuilder index b30869d57..c87f8372e 100644 --- a/app/views/attachments/_attachment.json.jbuilder +++ b/app/views/attachments/_attachment.json.jbuilder @@ -1,5 +1,6 @@ json.id attachment.id json.title attachment.title +json.link attachment.link json.is_public attachment.publiced? # json.is_lock attachment.locked?(@is_member) json.is_lock !attachment.publiced? @@ -15,4 +16,4 @@ json.created_on attachment.created_on json.content_type attachment.content_type json.is_pdf attachment.is_pdf? json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) -json.play_url attachment_show_users_path(file_name: local_path(attachment)) +json.play_url attachment.link.present? ? nil : attachment_show_users_path(file_name: local_path(attachment)) diff --git a/public/react/public/css/demo_index.html b/public/react/public/css/demo_index.html index 281ac40d0..7b0854698 100644 --- a/public/react/public/css/demo_index.html +++ b/public/react/public/css/demo_index.html @@ -30,6 +30,54 @@