diff --git a/conf/app.conf.example b/conf/app.conf.example index afa11c76..58d4ab01 100644 --- a/conf/app.conf.example +++ b/conf/app.conf.example @@ -79,7 +79,7 @@ avatar=/static/images/headimgurl.jpg token_size=12 #上传文件的后缀,如果不限制后缀可以设置为 * -upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif +upload_file_ext=txt|doc|docx|xls|xlsx|ppt|pptx|pdf|7z|rar|jpg|jpeg|png|gif|mp4|webm|avi #上传的文件大小限制 # - 如果不填写, 则默认1GB,如果希望超过1GB,必须带单位 diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index f6df4279..35e6f0c4 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -488,7 +488,6 @@ func (c *DocumentController) Upload() { } names := []string{"editormd-file-file", "editormd-image-file", "file", "editormd-resource-file"} - currentName := "" var files []*multipart.FileHeader for _, name := range names { file, err := c.GetFiles(name) @@ -496,7 +495,6 @@ func (c *DocumentController) Upload() { continue } if len(file) > 0 && err == nil { - currentName = name files = append(files, file...) } } @@ -667,8 +665,8 @@ func (c *DocumentController) Upload() { } result2 = append(result2, result) } - if currentName == "file" { - // froala单图片上传 + if len(files) == 1 { + // froala单文件上传 c.Ctx.Output.JSON(result, true, false) } else { c.Ctx.Output.JSON(result2, true, false) diff --git a/static/js/editor.js b/static/js/editor.js index 0f5438e2..63ca446b 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -476,6 +476,9 @@ function uploadResource($id, $callback) { case "video/mp4": fileName += ".mp4"; break; + case "video/webm": + fileName += ".webm"; + break; default : layer.msg(locales[lang].unsupportType); return; diff --git a/static/js/markdown.js b/static/js/markdown.js index cd61fa69..96e37c36 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -251,14 +251,16 @@ $(function () { shade: [0.1, '#fff'] // 0.1 透明度的白色背景 }); } else if ($state === "success") { - if ($res[0].errcode === 0) { - if ($res[0].resource_type === 'video') { - let value = ``; + if ($res.errcode === 0) { + if ($res.resource_type === 'video') { + let value = ``; window.editor.insertValue(value); } else { - let value = '![](' + $res[0].url + ')'; + let value = '![](' + $res.url + ')'; window.editor.insertValue(value); } + } else { + layer.msg("上传失败:" + $res.message); } } }); diff --git a/utils/filetil/filetil.go b/utils/filetil/filetil.go index 0bff4638..d2175f76 100644 --- a/utils/filetil/filetil.go +++ b/utils/filetil/filetil.go @@ -263,7 +263,12 @@ func IsImageExt(filename string) bool { func IsVideoExt(filename string) bool { ext := filepath.Ext(filename) - return strings.EqualFold(ext, ".mp4") + return strings.EqualFold(ext, ".mp4") || + strings.EqualFold(ext, ".webm") || + strings.EqualFold(ext, ".ogg") || + strings.EqualFold(ext, ".avi") || + strings.EqualFold(ext, ".flv") || + strings.EqualFold(ext, ".mov") } // 忽略字符串中的BOM头 diff --git a/views/document/markdown_edit_template.tpl b/views/document/markdown_edit_template.tpl index 5a141376..4a37291c 100644 --- a/views/document/markdown_edit_template.tpl +++ b/views/document/markdown_edit_template.tpl @@ -508,7 +508,6 @@ } }).on("uploadSuccess",function (file, res) { - for(var index in window.vueApp.lists){ var item = window.vueApp.lists[index]; if(item.attachment_id === file.id){