From 05b64eaf98016d4a977edb743e976e543195e6b4 Mon Sep 17 00:00:00 2001 From: "yadong.zhang" Date: Mon, 18 Feb 2019 14:36:55 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B5=84=E6=BA=90=E5=BA=93=E7=AE=A1=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E5=88=A0=E9=99=A4=E3=80=81=E6=89=B9=E9=87=8F=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=92=8C=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E7=AD=89?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=20:alien:=20=E5=B0=86=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E9=80=89=E6=8B=A9=E5=B0=81=E9=9D=A2=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=97=B6=E7=9A=84=E7=B4=A0=E6=9D=90=E5=BA=93=E7=94=B1?= =?UTF-8?q?=E5=8E=9F=E6=9D=A5=E7=9A=84=E6=9F=A5=E8=AF=A2=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=B0=81=E9=9D=A2=E5=88=97=E8=A1=A8=E6=94=B9=E4=B8=BA=E7=8E=B0?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E6=96=87=E4=BB=B6=E5=BA=93=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B=A9=E5=BA=93=E4=B8=AD=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E5=9B=BE=E7=89=87=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog-admin/pom.xml | 2 +- .../controller/ExceptionHandleController.java | 6 +- .../blog/controller/RestApiController.java | 13 +- .../blog/controller/RestFileController.java | 14 +- .../resources/static/assets/css/zhyd.core.css | 114 ++++++++++--- .../resources/static/assets/js/zhyd.core.js | 119 +++++++++++-- .../static/assets/js/zhyd.publish-article.js | 46 +---- .../resources/static/assets/js/zhyd.tool.js | 157 ++++++++++++++++++ .../main/resources/templates/file/list.ftl | 38 ++--- .../resources/templates/include/macros.ftl | 62 +++---- blog-core/pom.xml | 6 +- .../business/service/BizArticleService.java | 7 - .../blog/business/service/BizFileService.java | 3 + .../service/impl/BizArticleServiceImpl.java | 11 -- .../service/impl/BizFileServiceImpl.java | 16 ++ .../persistence/mapper/BizArticleMapper.java | 7 - .../resources/mybatis/BizArticleMapper.xml | 9 - blog-file/pom.xml | 2 +- .../file/exception/LocalApiException.java | 2 +- .../blog/file/exception/OssApiException.java | 2 +- .../file/exception/QiniuApiException.java | 2 +- blog-spider/pom.xml | 2 +- blog-web/pom.xml | 2 +- docs/db/update.sql | 9 +- pom.xml | 3 +- update.md | 13 ++ 26 files changed, 463 insertions(+), 204 deletions(-) diff --git a/blog-admin/pom.xml b/blog-admin/pom.xml index c6b8f014..3b6a5c1b 100644 --- a/blog-admin/pom.xml +++ b/blog-admin/pom.xml @@ -12,7 +12,7 @@ com.zyd blog - 2.1.0.Beta + 2.2.0 diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java b/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java index 906e07dc..565cfd23 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/ExceptionHandleController.java @@ -2,8 +2,8 @@ import com.zyd.blog.business.consts.CommonConst; import com.zyd.blog.business.enums.ResponseStatus; -import com.zyd.blog.file.exception.OssApiException; -import com.zyd.blog.framework.exception.*; +import com.zyd.blog.file.exception.GlobalFileException; +import com.zyd.blog.framework.exception.ZhydException; import com.zyd.blog.framework.object.ResponseVO; import com.zyd.blog.util.ResultUtil; import lombok.extern.slf4j.Slf4j; @@ -60,7 +60,7 @@ public ResponseVO maxUploadSizeExceededExceptionHandle(Throwable e) { @ExceptionHandler(value = Exception.class) @ResponseBody public ResponseVO handle(Throwable e) { - if (e instanceof ZhydException || e instanceof OssApiException) { + if (e instanceof ZhydException || e instanceof GlobalFileException) { return ResultUtil.error(e.getMessage()); } if (e instanceof UndeclaredThrowableException) { diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java index 47414027..815c4f25 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java @@ -69,17 +69,6 @@ public Object uploadFileForMd(@RequestParam("file") MultipartFile file) { return resultMap; } - /** - * 发布文章选择图片时获取素材库 - * - * @return - */ - @RequiresPermissions("article:publish") - @PostMapping("/material") - public ResponseVO material() { - return ResultUtil.success("", articleService.listMaterial()); - } - /** * 发送消息通知 * @@ -90,6 +79,6 @@ public ResponseVO material() { @BussinessLog("通过websocket向前台用户发送通知") public ResponseVO notice(String msg) throws UnsupportedEncodingException { WebSocketUtil.sendNotificationMsg(msg, websocketServer.getOnlineUsers()); - return ResultUtil.success("消息发送成功", articleService.listMaterial()); + return ResultUtil.success("消息发送成功"); } } diff --git a/blog-admin/src/main/java/com/zyd/blog/controller/RestFileController.java b/blog-admin/src/main/java/com/zyd/blog/controller/RestFileController.java index 2e079a9a..2fa9ff37 100644 --- a/blog-admin/src/main/java/com/zyd/blog/controller/RestFileController.java +++ b/blog-admin/src/main/java/com/zyd/blog/controller/RestFileController.java @@ -2,13 +2,9 @@ import com.github.pagehelper.PageInfo; import com.zyd.blog.business.annotation.BussinessLog; -import com.zyd.blog.business.entity.File; -import com.zyd.blog.business.enums.FileUploadType; import com.zyd.blog.business.service.BizFileService; import com.zyd.blog.business.vo.FileConditionVO; -import com.zyd.blog.file.FileUploader; import com.zyd.blog.framework.object.ResponseVO; -import com.zyd.blog.plugin.file.GlobalFileUploader; import com.zyd.blog.util.ResultUtil; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -54,9 +50,11 @@ public ResponseVO remove(Long[] ids) { @RequiresPermissions("files") @PostMapping(value = "/add") @BussinessLog("添加文件") - public ResponseVO add(MultipartFile file) { - FileUploader uploader = new GlobalFileUploader(); - uploader.upload(file, FileUploadType.COMMON.getPath(), true); - return ResultUtil.success("成功上传一张图片"); + public ResponseVO add(MultipartFile[] file) { + if (null == file || file.length == 0) { + return ResultUtil.error("请至少选择一张图片!"); + } + int res = fileService.upload(file); + return ResultUtil.success("成功上传" + res + "张图片"); } } diff --git a/blog-admin/src/main/resources/static/assets/css/zhyd.core.css b/blog-admin/src/main/resources/static/assets/css/zhyd.core.css index a609c240..39032e9a 100644 --- a/blog-admin/src/main/resources/static/assets/css/zhyd.core.css +++ b/blog-admin/src/main/resources/static/assets/css/zhyd.core.css @@ -2384,6 +2384,9 @@ a.star { padding: 3px 0; border: 1px solid #EFEFEF } +.editor-statusbar .lines:before { + content: ''!important; +} .input-group { margin-bottom: 10px @@ -3501,7 +3504,16 @@ ul.project_files li a i { margin-bottom: 5px } -.caption img { +.caption p span { + display: inline-block; + width: 88%; + white-space: nowrap; + word-wrap: normal; + text-overflow: ellipsis; + overflow: hidden; +} + +.caption p img { float: right; width: 20px; } @@ -3566,10 +3578,11 @@ ul.project_files li a i { .view p { font-family: Georgia, serif; - font-size: 12px; + font-size: 15px; color: #fff; padding: 10px 20px 20px; - text-align: center + text-align: center; + line-height: 7; } .view a.info { @@ -3642,20 +3655,24 @@ ul.project_files li a i { -webkit-box-shadow:0 0 15px #b5b5b5; box-shadow:0 0 15px #b5b5b5; } -.thumbnail.selected .selected-mask, .thumbnail:hover .selected-mask { +.thumbnail.selected .selected-mask, .thumbnail:hover .selected-mask, .material-item.selected .selected-mask { opacity: 1; } -.thumbnail .selected-mask { +.thumbnail .selected-mask, .material-item .selected-mask { display: block; position: absolute; top: 0; left: 0; opacity: 0; } +.thumbnail .selected-mask.mask-xs, .material-item .selected-mask.mask-xs { + width: 95px; + height: 95px; +} .thumbnail .selected-mask [class^="icheckbox"] { float: left!important; } -.thumbnail .selected-mask .inner { +.thumbnail .selected-mask .inner, .material-item .selected-mask .inner { width: 100%; height: 100%; -moz-opacity: .6; @@ -3664,7 +3681,7 @@ ul.project_files li a i { background-color: #000; filter: alpha(opacity=60); } -.thumbnail .selected-mask .icon { +.thumbnail .selected-mask .icon, .material-item .selected-mask .icon { position: absolute; top: 0; left: 0; @@ -4888,43 +4905,92 @@ ul, menu, dir { background-color: #f5f5f5; } + + +.chooseImgModal .material-status, #chooseImgModal .material-status { + line-height: 3; + color: #333 +} + +.chooseImgModal .material-box::-webkit-scrollbar { + margin-right: 2px; + width: 5px; +} + +.chooseImgModal .material-box::-webkit-scrollbar-thumb { + width: 5px; + border: 0 solid #000; + background: #cbcbcb; +} + +.chooseImgModal .material-box::-webkit-scrollbar-track-piece { + border-left: 0 solid #d2d2d2; + background-color: #f5f5f5; +} + .material-box { - min-height: 250px; - height: 250px; + max-height: 325px; + min-height: 215px; + /*height: 250px;*/ overflow-y: scroll; } -.material-box ul li { +.material-box ul li.material-item { border: 1px solid #ddd; - -webkit-transition: border .2s ease-in-out; - -o-transition: border .2s ease-in-out; - transition: border .2s ease-in-out; + /*-webkit-transition: border .2s ease-in-out;*/ + /*-o-transition: border .2s ease-in-out;*/ + /*transition: border .2s ease-in-out;*/ float: left; - width: 120px; - height: 120px; - margin: 5px; + width: 96px; + height: 96px; + margin: 7px; } -.material-box ul li:hover { +.material-box ul li.material-item:hover { -moz-box-shadow: 2px 2px 5px #cbd0d6; -webkit-box-shadow: 2px 2px 5px #cbd0d6; box-shadow: 2px 2px 5px #cbd0d6; } -.material-box ul li.active { +.material-box ul li.material-item.active { -moz-box-shadow: 2px 2px 5px #cbd0d6; -webkit-box-shadow: 2px 2px 5px #cbd0d6; box-shadow: 2px 2px 5px #cbd0d6; } -.material-box ul li img { - transition: all .2s linear; - width: 100px; - max-height: 100px; +.material-box ul li.material-item img { + /*transition: all .2s linear;*/ + width: 100%; + max-height: 95px; +} + +.material-box ul li.material-item:hover img { + /*transform: scale(1.1);*/ } -.material-box ul li:hover img { - transform: scale(1.1); +.material-box ul li.material-page { + width: 100%; + height: 38px; + border: 0 solid #ddd; + text-align: right; + padding-right: 15px; + padding-top: 5px; + float: right; +} + +.material-box ul li.material-page .material-page-body { + width: 100%; + height: 100%; +} + +.material-box ul li.material-page .material-page-body a, .material-box ul li.material-page .material-page-body input { + display: inline-block +} + +.material-box ul li.material-page .material-page-body input { + width: 50px; + position: relative; + top: -2px; } .preview img { diff --git a/blog-admin/src/main/resources/static/assets/js/zhyd.core.js b/blog-admin/src/main/resources/static/assets/js/zhyd.core.js index 3028e4cd..403f1b81 100644 --- a/blog-admin/src/main/resources/static/assets/js/zhyd.core.js +++ b/blog-admin/src/main/resources/static/assets/js/zhyd.core.js @@ -317,31 +317,18 @@ var zhyd = window.zhyd || { }, placeholder: "请输入文本内容", // 如果设置为true,则会出现JS警报窗口,询问链接或图像URL(插入图片或链接弹窗)。默认为false - promptURLs: true, + promptURLs: false, renderingConfig: { // 如果设置为true,将使用highlight.js高亮显示。默认为false codeSyntaxHighlighting: true }, showIcons: ["code", "table", "clean-block", "horizontal-rule"], tabSize: 4, - // 编辑器底部的状态栏 - status: true, - status: ["autosave", "lines", "words", "cursor"], // Optional usage - status: ["autosave", "lines", "words", "cursor", { - className: "keystrokes", - defaultValue: function (el) { - this.keystrokes = 0; - el.innerHTML = "0 Keystrokes"; - }, - onUpdate: function (el) { - el.innerHTML = ++this.keystrokes + " Keystrokes"; - } - }] - + status: false }); - zhyd.simpleMDE.plugins.registerFullscreen(); zhyd.simpleMDE.plugins.registerUpload($op.uploadUrl, simplemde); + zhyd.simpleMDE.plugins.registerUploadImg(); $(".editor-preview-side").addClass("markdown-body"); }, @@ -399,6 +386,96 @@ var zhyd = window.zhyd || { uploadUrl: uploadUrl }); } + }, + registerUploadImg: function () { + function getState(cm, pos) { + pos = pos || cm.getCursor("start"); + var stat = cm.getTokenAt(pos); + if(!stat.type) return {}; + var types = stat.type.split(" "); + var ret = {}, + data, text; + for(var i = 0; i < types.length; i++) { + data = types[i]; + if(data === "strong") { + ret.bold = true; + } else if(data === "variable-2") { + text = cm.getLine(pos.line); + if(/^\s*\d+\.\s/.test(text)) { + ret["ordered-list"] = true; + } else { + ret["unordered-list"] = true; + } + } else if(data === "atom") { + ret.quote = true; + } else if(data === "em") { + ret.italic = true; + } else if(data === "quote") { + ret.quote = true; + } else if(data === "strikethrough") { + ret.strikethrough = true; + } else if(data === "comment") { + ret.code = true; + } else if(data === "link") { + ret.link = true; + } else if(data === "tag") { + ret.image = true; + } else if(data.match(/^header(\-[1-6])?$/)) { + ret[data.replace("header", "heading")] = true; + } + } + return ret; + } + function insertHtml(imgUrl){ + var cm = simplemde.codemirror; + var state = getState(cm); + var options = simplemde.options; + + if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) + return; + var text; + var start = options.insertTexts.image[0]; + var end = options.insertTexts.image[1]; + var startPoint = cm.getCursor("start"); + var endPoint = cm.getCursor("end"); + if(imgUrl) { + end = end.replace("#url#", imgUrl); + } + if(state.image) { + text = cm.getLine(startPoint.line); + start = text.slice(0, startPoint.ch); + end = text.slice(startPoint.ch); + cm.replaceRange(start + end, { + line: startPoint.line, + ch: 0 + }); + } else { + text = cm.getSelection(); + var img = start + text + end; + cm.replaceSelection(img); + startPoint.ch += img.length; + if(startPoint !== endPoint) { + endPoint.ch += img.length; + } + } + cm.setSelection(startPoint, endPoint); + cm.focus(); + } + try { + var insertImage = document.getElementsByClassName("editor-toolbar")[0].getElementsByTagName("a")[9]; + insertImage.onclick = function (ev) { + $.modal.material.open({multiSelect: true, selectable: 10}, function (selectedImageUrls) { + if(!selectedImageUrls) { + return false; + } + for(var i = 0; i < selectedImageUrls.length; i ++){ + insertHtml(selectedImageUrls[i]); + } + }) + } + } catch (e) { + console.error(e); + } } } }, @@ -411,7 +488,9 @@ var zhyd = window.zhyd || { _open: function (container, msg, type) { var html = Mustache.render(this._box, {icon: this._icon[type], text: msg, maskType: type}); $(container).append(html); - + }, + closeAll: function (container) { + $(container).find("div.mask.load, div.mask.lock").remove(); }, init: function () { console.log("init mask..."); @@ -431,6 +510,12 @@ var zhyd = window.zhyd || { }, locking: function (container, msg) { this._open(container, msg || "Locking", "lock"); + }, + closeLoading: function (container) { + $(container).find("div.mask.load").remove(); + }, + closeLocking: function (container) { + $(container).find("div.mask.lock").remove(); } } }; diff --git a/blog-admin/src/main/resources/static/assets/js/zhyd.publish-article.js b/blog-admin/src/main/resources/static/assets/js/zhyd.publish-article.js index d8b021b2..b94e48c9 100644 --- a/blog-admin/src/main/resources/static/assets/js/zhyd.publish-article.js +++ b/blog-admin/src/main/resources/static/assets/js/zhyd.publish-article.js @@ -29,7 +29,7 @@ if(articleId){ $('#comment').iCheck(info.comment ? 'check' : 'uncheck'); } if(info['coverImage']){ - $(".coverImage").attr('src', appConfig.fileStoragePath + info['coverImage']); + $(".coverImage").attr('src', info['coverImage']); } var contentMd = info['contentMd']; if(contentMd){ @@ -84,7 +84,7 @@ $(".publishBtn").click(function () { if(isMarkdown == 1) { $.tool.delCache("smde_" + op.uniqueId); } - $.alert.ajaxSuccessConfirm(json, function () { + $.alert.ajaxSuccess(json, function () { window.location.href = '/articles'; }); }, @@ -93,45 +93,11 @@ $(".publishBtn").click(function () { } }); -var loadImg = false; -// 选择图片 $("#file-upload-btn").click(function () { - $("#chooseImg").modal('show'); - if(!loadImg){ - // 加载素材库 - $.ajax({ - type: "post", - url: "/api/material", - success: function (json) { - $.alert.ajaxSuccess(json); - loadImg = true; - var $box = $(".list-material"); - var tpl = '{{#data}}
  • image
  • {{/data}}{{^data}}
  • 素材库为空
  • {{/data}}'; - var html = Mustache.render(tpl, json); - $box.html(html); - $box.find("li").click(function () { - $box.find("li").each(function () { - $(this).removeClass("active"); - }); - var $this = $(this); - $this.toggleClass("active"); - if($this.hasClass("active")){ - var imgUrl = $this.attr("data-imgUrl"); - $("#cover-img-input").val(imgUrl); - $(".preview img.coverImage").attr("src", appConfig.fileStoragePath + imgUrl); - } - }); - $("img.lazy-img").lazyload({ - placeholder : appConfig.staticPath + "/img/loading.gif", - effect: "fadeIn", - threshold: 100 - }); - - $("img.lazy-img").trigger("sporty"); - }, - error: $.alert.ajaxError - }); - } + $.modal.material.open({multiSelect: false}, function (selectedImageUrl) { + $("#cover-img-input").val(selectedImageUrl); + $(".preview img.coverImage").attr("src", selectedImageUrl); + }) }); // 选择图片 diff --git a/blog-admin/src/main/resources/static/assets/js/zhyd.tool.js b/blog-admin/src/main/resources/static/assets/js/zhyd.tool.js index ef6f9803..65fec4f7 100644 --- a/blog-admin/src/main/resources/static/assets/js/zhyd.tool.js +++ b/blog-admin/src/main/resources/static/assets/js/zhyd.tool.js @@ -101,6 +101,163 @@ } } }); + $.extend({ + modal: { + material: { + _loadData: function(config, callback){ + $("#selectable").html(config.selectable), $("#selected").html(0); + zhyd.mask.loading($(".material-body"), "加载中..."); + $.ajax({ + url: "/file/list", + data: {pageNumber: config && config.pageNumber ? config.pageNumber : 1}, + type: "POST", + success: function (json) { + zhyd.mask.closeAll($(".material-body")); + var $box = $(".list-file"); + var tpl = '{{#list}}
  • ' + + '
    ' + + 'image
  • {{/list}}{{^list}}
  • 素材库为空
  • {{/list}}'; + var html = Mustache.render(tpl, json); + var pageTpl = '{{#data}}
  • \n' + + '
    \n' + + ' {{#hasPreviousPage}}\n' + + ' \n' + + ' {{/hasPreviousPage}}{{pageNum}}/{{pages}}{{#hasNextPage}}\n' + + ' \n' + + ' {{/hasNextPage}}\n' + + ' \n' + + ' Go\n' + + ' \n' + + ' \n' + + '
    \n' + + '
  • {{/data}}'; + html += Mustache.render(pageTpl, {data: json}); + $box.html(html); + + // 图片懒加载 + var $lazyImg = $("img.lazy-img"); + $lazyImg.lazyload({ + placeholder : appConfig.cmsPath + "/assets/images/loading.gif", + effect: "fadeIn", + threshold: 100 + }); + $lazyImg.trigger("sporty"); + + // 绑定分页点击事件 + $(".material-pagination").unbind("click").click(function () { + var $this = $(this); + var pageNumber = $this.data("page"); + config.pageNumber = !pageNumber || isNaN(pageNumber) ? 1 : parseInt(pageNumber); + console.log(config.pageNumber); + $.modal.material._loadData(config); + }); + // 绑定分页-跳转页面点击事件 + $(".material-jump").unbind("click").click(function () { + var $this = $(this); + var jumpTarget = $(".material-input").val(); + config.pageNumber = !jumpTarget || isNaN(jumpTarget) ? 1 : parseInt(jumpTarget); + $.modal.material._loadData(config); + }); + + // 绑定图片点击事件 + var selectable = 0; + var $li = $box.find("li.material-item"); + $li.unbind("click").click(function () { + var $this = $(this); + if(config.multiSelect) { + if($this.hasClass("active") || $this.hasClass("selected")) { + selectable --; + $this.removeClass("active selected"); + } else { + if(selectable >= config.selectable) { + $.alert.error("最多只能选择" + config.selectable + "张图片!"); + return false; + } + selectable ++; + $this.addClass("active selected"); + } + + $("#selected").html(selectable); + } else { + $this.addClass("current"); + $li.each(function () { + !$(this).hasClass("current") && $(this).removeClass("active selected"); + }); + $this.toggleClass("active selected").removeClass("current"); + if($this.hasClass("active") || $this.hasClass("selected")) { + $("#selected").html(1); + } else { + $("#selected").html(0); + } + } + }); + + // 执行回调 + callback && callback($box); + }, + error: function () { + zhyd.mask.closeAll($(".material-body")); + } + }) + }, + open: function (config, callback){ + config = $.extend({ + // 是否多选 + multiSelect: false, + // 可选择的数量,当multiSelect为true时可用 + selectable: 1 + }, config); + $("#chooseImgModal").modal('show'); + this._loadData(config, function ($box) { + + $(".btn-confirm").unbind("click").click(function () { + var $this = $(this); + var imgUrls = []; + $box.find("li").each(function () { + var $thisLi = $(this); + if($thisLi.hasClass("active") || $thisLi.hasClass("selected") ){ + var imgUrl = $thisLi.attr("data-imgUrl"); + imgUrls.push(imgUrl); + } + }); + if(config.multiSelect) { + callback(imgUrls); + } else { + callback(imgUrls[0]); + } + }); + + $("#btn-material-upload").unbind("click").click(function () { + var $input = $("#input-material-upload"); + $input.click().unbind("change").change(function () { + var selectedFiles = document.getElementById("input-material-upload").files; + if(!selectedFiles || selectedFiles.length <= 0) { + return false; + } + var $form = $("#materialForm"); + if (validator.checkAll($form)) { + $form.ajaxSubmit({ + type: "post", + url: "/file/add", + success: function (json) { + if (json.status == 200) { + $.modal.material._loadData(config) + } else { + if (json.message) { + $.alert.error(json.message); + } + } + }, + error: $.alert.ajaxError + }); + } + }); + }); + }) + } + } + } + }); $.extend({ toastr: { initToastr: function () { diff --git a/blog-admin/src/main/resources/templates/file/list.ftl b/blog-admin/src/main/resources/templates/file/list.ftl index 2df9352f..d9e297cd 100644 --- a/blog-admin/src/main/resources/templates/file/list.ftl +++ b/blog-admin/src/main/resources/templates/file/list.ftl @@ -61,7 +61,7 @@
    - +
    @@ -74,26 +74,26 @@ type: "POST", success: function (json) { var tpl = '{{#list}}
    \n' + - '
    \n' + - '
    \n' + - ' {{originalFileName}}\n' + - '
    \n' + - '

    File Path: {{filePath}}
    File Hash: {{fileHash}}

    \n' + - '
    \n' + - ' \n' + - ' \n' + - ' \n' + - '
    \n' + - '
    \n' + - '
    \n' + - ' ' + - '
    \n' + - '
    \n' + - '
    \n' + - '

    {{originalFileName}}{{storageType}}

    \n' + + '
    \n' + + '
    \n' + + ' {{originalFileName}}\n' + + '
    \n' + + '

    点击选中

    \n' + + '
    \n' + + ' \n' + + ' \n' + + ' \n' + '
    \n' + '
    \n' + - '
    {{/list}}'; + '
    \n' + + ' ' + + '
    \n' + + '
    \n' + + '
    \n' + + '

    {{originalFileName}}{{storageType}}

    \n' + + '
    \n' + + '
    \n' + + '
    {{/list}}'; var html = Mustache.render(tpl, json); $("#file-container").html(html); gentelella.initiICheck(); diff --git a/blog-admin/src/main/resources/templates/include/macros.ftl b/blog-admin/src/main/resources/templates/include/macros.ftl index 28eb621c..77852455 100644 --- a/blog-admin/src/main/resources/templates/include/macros.ftl +++ b/blog-admin/src/main/resources/templates/include/macros.ftl @@ -87,7 +87,7 @@ <#-- 面包屑导航内容 + 系统通知 --> <#macro breadcrumb>
    -
    +
    -
    +
    <#nested>
    @@ -208,44 +208,36 @@ <#-- 发布文章时选择图片的弹窗模板 --> <#macro chooseImgModal> -