1、实现富文本粘贴图片

2、以项目标识组织图片
This commit is contained in:
Minho
2018-01-27 12:26:51 +08:00
parent 88221c70d1
commit dc2a920acc
2 changed files with 24 additions and 9 deletions

View File

@@ -432,8 +432,7 @@ func (c *DocumentController) Upload() {
type Size interface {
Size() int64
}
beego.Info(conf.GetUploadFileSize())
beego.Info(moreFile.Size)
if conf.GetUploadFileSize() > 0 && moreFile.Size > conf.GetUploadFileSize() {
c.JsonResult(6009, "查过文件允许的上传最大值")
}
@@ -450,7 +449,7 @@ func (c *DocumentController) Upload() {
}
}
book_id := 0
bookId := 0
// 如果是超级管理员,则不判断权限
if c.Member.IsAdministrator() {
@@ -460,7 +459,7 @@ func (c *DocumentController) Upload() {
c.JsonResult(6006, "文档不存在或权限不足")
}
book_id = book.BookId
bookId = book.BookId
} else {
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
@@ -478,7 +477,7 @@ func (c *DocumentController) Upload() {
c.JsonResult(6006, "权限不足")
}
book_id = book.BookId
bookId = book.BookId
}
if doc_id > 0 {
@@ -487,13 +486,15 @@ func (c *DocumentController) Upload() {
c.JsonResult(6007, "文档不存在")
}
if doc.BookId != book_id {
if doc.BookId != bookId {
c.JsonResult(6008, "文档不属于指定的项目")
}
}
fileName := "attach_" + strconv.FormatInt(time.Now().UnixNano(), 16)
filePath := filepath.Join(conf.WorkingDirectory, "uploads", time.Now().Format("200601"), fileName+ext)
filePath := filepath.Join(conf.WorkingDirectory, "uploads", time.Now().Format("200601"),identify, fileName+ext)
path := filepath.Dir(filePath)
os.MkdirAll(path, os.ModePerm)
@@ -506,7 +507,7 @@ func (c *DocumentController) Upload() {
}
attachment := models.NewAttachment()
attachment.BookId = book_id
attachment.BookId = bookId
attachment.FileName = moreFile.Filename
attachment.CreateAt = c.Member.MemberId
attachment.FileExt = ext

View File

@@ -20,6 +20,20 @@ $(function () {
window.editor.history.redo();
});
uploadImage("docEditor", function ($state, $res) {
if ($state === "before") {
return layer.load(1, {
shade: [0.1, '#fff'] // 0.1 透明度的白色背景
});
} else if ($state === "success") {
if ($res.errcode === 0) {
var range = window.editor.getSelection();
window.editor.insertEmbed(range.index, 'image', $res.url);
}
}
});
$("#btnRelease").on("click",function () {
if (Object.prototype.toString.call(window.documentCategory) === '[object Array]' && window.documentCategory.length > 0) {
if ($("#markdown-save").hasClass('change')) {
@@ -72,7 +86,7 @@ $(function () {
layer.msg(data.message);
}else{
var range = window.editor.getSelection();
editor.insertEmbed(range.index, 'image', data.url);
window.editor.insertEmbed(range.index, 'image', data.url);
}
}
});