mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-04-05 20:17:53 +08:00
feat: 直接粘贴视频上传功能
This commit is contained in:
parent
f78b65424a
commit
a7eccd2a83
@ -79,7 +79,7 @@ avatar=/static/images/headimgurl.jpg
|
|||||||
token_size=12
|
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,必须带单位
|
# - 如果不填写, 则默认1GB,如果希望超过1GB,必须带单位
|
||||||
|
@ -488,7 +488,6 @@ func (c *DocumentController) Upload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
names := []string{"editormd-file-file", "editormd-image-file", "file", "editormd-resource-file"}
|
names := []string{"editormd-file-file", "editormd-image-file", "file", "editormd-resource-file"}
|
||||||
currentName := ""
|
|
||||||
var files []*multipart.FileHeader
|
var files []*multipart.FileHeader
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
file, err := c.GetFiles(name)
|
file, err := c.GetFiles(name)
|
||||||
@ -496,7 +495,6 @@ func (c *DocumentController) Upload() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(file) > 0 && err == nil {
|
if len(file) > 0 && err == nil {
|
||||||
currentName = name
|
|
||||||
files = append(files, file...)
|
files = append(files, file...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -667,8 +665,8 @@ func (c *DocumentController) Upload() {
|
|||||||
}
|
}
|
||||||
result2 = append(result2, result)
|
result2 = append(result2, result)
|
||||||
}
|
}
|
||||||
if currentName == "file" {
|
if len(files) == 1 {
|
||||||
// froala单图片上传
|
// froala单文件上传
|
||||||
c.Ctx.Output.JSON(result, true, false)
|
c.Ctx.Output.JSON(result, true, false)
|
||||||
} else {
|
} else {
|
||||||
c.Ctx.Output.JSON(result2, true, false)
|
c.Ctx.Output.JSON(result2, true, false)
|
||||||
|
@ -476,6 +476,9 @@ function uploadResource($id, $callback) {
|
|||||||
case "video/mp4":
|
case "video/mp4":
|
||||||
fileName += ".mp4";
|
fileName += ".mp4";
|
||||||
break;
|
break;
|
||||||
|
case "video/webm":
|
||||||
|
fileName += ".webm";
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
layer.msg(locales[lang].unsupportType);
|
layer.msg(locales[lang].unsupportType);
|
||||||
return;
|
return;
|
||||||
|
@ -251,14 +251,16 @@ $(function () {
|
|||||||
shade: [0.1, '#fff'] // 0.1 透明度的白色背景
|
shade: [0.1, '#fff'] // 0.1 透明度的白色背景
|
||||||
});
|
});
|
||||||
} else if ($state === "success") {
|
} else if ($state === "success") {
|
||||||
if ($res[0].errcode === 0) {
|
if ($res.errcode === 0) {
|
||||||
if ($res[0].resource_type === 'video') {
|
if ($res.resource_type === 'video') {
|
||||||
let value = `<video controls><source src="${$res[0].url}" type="video/mp4"></video>`;
|
let value = `<video controls><source src="${$res.url}" type="video/mp4"></video>`;
|
||||||
window.editor.insertValue(value);
|
window.editor.insertValue(value);
|
||||||
} else {
|
} else {
|
||||||
let value = '';
|
let value = '';
|
||||||
window.editor.insertValue(value);
|
window.editor.insertValue(value);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
layer.msg("上传失败:" + $res.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -263,7 +263,12 @@ func IsImageExt(filename string) bool {
|
|||||||
func IsVideoExt(filename string) bool {
|
func IsVideoExt(filename string) bool {
|
||||||
ext := filepath.Ext(filename)
|
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头
|
// 忽略字符串中的BOM头
|
||||||
|
@ -508,7 +508,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}).on("uploadSuccess",function (file, res) {
|
}).on("uploadSuccess",function (file, res) {
|
||||||
|
|
||||||
for(var index in window.vueApp.lists){
|
for(var index in window.vueApp.lists){
|
||||||
var item = window.vueApp.lists[index];
|
var item = window.vueApp.lists[index];
|
||||||
if(item.attachment_id === file.id){
|
if(item.attachment_id === file.id){
|
||||||
|
Loading…
Reference in New Issue
Block a user