From 58eea151523cc705a7ab77b33923f3a65b8fb283 Mon Sep 17 00:00:00 2001 From: yirenyishi Date: Sun, 2 Dec 2018 20:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/FileController.go | 6 ++++-- views/newblog.html | 9 +++++++-- views/note.html | 3 +-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/controllers/FileController.go b/controllers/FileController.go index bb9099e..afbdade 100644 --- a/controllers/FileController.go +++ b/controllers/FileController.go @@ -40,7 +40,8 @@ func (this *FileController) Upload() { return } //创建目录 - uploadDir := "static/upload/" + time.Now().Format("2006/01/02/") + urlDir := time.Now().Format("2006/01/02/") + uploadDir := "/opt/filetom/webapps/itstack/" + urlDir err := os.MkdirAll(uploadDir, 777) if err != nil { this.Data["json"] = models.ReurnError(500, "") @@ -53,6 +54,7 @@ func (this *FileController) Upload() { hashName := md5.Sum([]byte( time.Now().Format("2006_01_02_15_04_05_") + randNum )) fileName := fmt.Sprintf("%x", hashName) + ext fpath := uploadDir + fileName + urlDir += fileName defer f.Close() //关闭上传的文件,不然的话会出现临时文件不能清除的情况 err = this.SaveToFile(filename, fpath) if err != nil { @@ -61,6 +63,7 @@ func (this *FileController) Upload() { this.ServeJSON() return } + urlDir = "https://aiprose.com/foss/" + urlDir this.Data["json"] = models.ReurnData("", fpath) this.ServeJSON() return @@ -128,7 +131,6 @@ func (this *FileController) HeadImgUpload() { this.ServeJSON() return } - this.SetSession("headimg", urlDir) this.Data["json"] = models.ReurnData("", urlDir) this.ServeJSON() return diff --git a/views/newblog.html b/views/newblog.html index f57774c..7d4f28e 100644 --- a/views/newblog.html +++ b/views/newblog.html @@ -33,8 +33,14 @@ var storage=window.localStorage var E = window.wangEditor var editor = new E('#editor') - editor.customConfig.uploadImgServer = '/upload' + editor.customConfig.uploadImgServer = '/file/upload' // 或者 var editor = new E( document.getElementById('editor') ) + editor.customConfig.uploadImgHooks = { + customInsert: function (insertImg, result, editor) { + insertImg(result.Data); + debugger + } + } editor.create() document.onkeydown = keyDown; @@ -42,7 +48,6 @@ var currKey = 0, e = e || event || window.event; currKey = e.keyCode || e.which || e.charCode; if (currKey == 83 && (e.ctrlKey || e.metaKey)) { - layer.msg("ctrl+s") saveBlog() return } diff --git a/views/note.html b/views/note.html index c0295bd..8255758 100644 --- a/views/note.html +++ b/views/note.html @@ -88,8 +88,7 @@ // 或者 var editor = new E( document.getElementById('editor') ) editor.customConfig.uploadImgHooks = { customInsert: function (insertImg, result, editor) { - var url = result.Data.replace("static/upload", "https://airose.com/itstack"); - insertImg(url); + insertImg(result.Data); debugger } }