diff --git a/README.md b/README.md index c31df735a1579c2101a515fa7d29b2a2fb4867e8..bcdfaa0803bd4e360feca23a20432650fcbcc121 100755 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Let's start: http://localhost:8090 ## Demo 婕旂ず -[鐣岄潰棰勮](https://halo-doc.ryanc.cc/preview) +[娴嬭瘯鍦板潃](http://39.105.26.52)锛孾娴嬭瘯鍚庡彴(admin,123456)](http://39.105.26.52/admin) [Ryan0up'S Blog](https://ryanc.cc) diff --git a/src/main/java/cc/ryanc/halo/model/dto/JsonResult.java b/src/main/java/cc/ryanc/halo/model/dto/JsonResult.java new file mode 100644 index 0000000000000000000000000000000000000000..8d2c9de96b794b1bd07e02d17200402c0893d67d --- /dev/null +++ b/src/main/java/cc/ryanc/halo/model/dto/JsonResult.java @@ -0,0 +1,49 @@ +package cc.ryanc.halo.model.dto; + +import lombok.Data; + +/** + * @author : RYAN0UP + * @version : 1.0 + * @date : 2018/5/24 + */ +@Data +public class JsonResult { + + /** + * 杩斿洖鐨勭姸鎬佺爜锛�0锛氬け璐ワ紝1锛氭垚鍔� + */ + private Integer code; + + /** + * 杩斿洖淇℃伅 + */ + private String msg; + + /** + * 杩斿洖鐨勬暟鎹� + */ + private Object result; + + /** + * 涓嶈繑鍥炴暟鎹殑鏋勯€犳柟娉� + * @param code 鐘舵€佺爜 + * @param msg 淇℃伅 + */ + public JsonResult(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + + /** + * 杩斿洖鏁版嵁鐨勬瀯閫犳柟娉� + * @param code 鐘舵€佺爜 + * @param msg 淇℃伅 + * @param result 鏁版嵁 + */ + public JsonResult(Integer code, String msg, Object result) { + this.code = code; + this.msg = msg; + this.result = result; + } +} diff --git a/src/main/java/cc/ryanc/halo/model/dto/LogsRecord.java b/src/main/java/cc/ryanc/halo/model/dto/LogsRecord.java index 737c5c24420ac50bebe7b09af909ff1313898043..3580cdbe1943f9880c28353decc6935abeac43a4 100644 --- a/src/main/java/cc/ryanc/halo/model/dto/LogsRecord.java +++ b/src/main/java/cc/ryanc/halo/model/dto/LogsRecord.java @@ -19,6 +19,8 @@ public interface LogsRecord { String PUSH_POST = "鍙戣〃鏂囩珷"; + String PUSH_PAGE = "鍙戣〃椤甸潰"; + String REMOVE_POST = "鍒犻櫎鏂囩珷"; String CHANGE_THEME = "鏇存崲涓婚"; diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java index 149d740788990c7ed028007fa65d19654002ce76..c4649cd6ec05c3eb3c1d91d8f565694a3dda57fe 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/AttachmentController.java @@ -3,6 +3,7 @@ package cc.ryanc.halo.web.controller.admin; import cc.ryanc.halo.model.domain.Attachment; import cc.ryanc.halo.model.domain.Logs; import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.model.dto.JsonResult; import cc.ryanc.halo.model.dto.LogsRecord; import cc.ryanc.halo.service.AttachmentService; import cc.ryanc.halo.service.LogsService; @@ -68,7 +69,6 @@ public class AttachmentController { Pageable pageable = PageRequest.of(page, size, sort); Page<Attachment> attachments = attachmentService.findAllAttachments(pageable); model.addAttribute("attachments", attachments); - return "admin/admin_attachment"; } @@ -216,8 +216,8 @@ public class AttachmentController { */ @GetMapping(value = "/remove") @ResponseBody - public boolean removeAttachment(@PathParam("attachId") Long attachId, - HttpServletRequest request) { + public JsonResult removeAttachment(@PathParam("attachId") Long attachId, + HttpServletRequest request) { Optional<Attachment> attachment = attachmentService.findByAttachId(attachId); String delFileName = attachment.get().getAttachName(); String delSmallFileName = delFileName.substring(0, delFileName.lastIndexOf('.')) + "_small" + attachment.get().getAttachSuffix(); @@ -249,13 +249,13 @@ public class AttachmentController { ); } else { log.error("鍒犻櫎闄勪欢[" + delFileName + "]澶辫触锛�"); - return false; + return new JsonResult(0,"鍒犻櫎澶辫触锛�"); } } } catch (Exception e) { log.error("鍒犻櫎闄勪欢[" + delFileName + "]澶辫触锛�:", e.getMessage()); - return false; + return new JsonResult(0,"鍒犻櫎澶辫触锛�"); } - return true; + return new JsonResult(1,"鍒犻櫎鎴愬姛锛�"); } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java index 12709ce8a3c802328af945fdf85344197ccfc7ab..1eb7f9990fb188b3b2d5a690875a6123dc550bf0 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/OptionController.java @@ -1,6 +1,7 @@ package cc.ryanc.halo.web.controller.admin; import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.model.dto.JsonResult; import cc.ryanc.halo.service.OptionsService; import freemarker.template.Configuration; import lombok.extern.slf4j.Slf4j; @@ -45,7 +46,7 @@ public class OptionController { */ @PostMapping(value = "/save") @ResponseBody - public boolean saveOptions(@RequestParam Map<String, String> options) { + public JsonResult saveOptions(@RequestParam Map<String, String> options) { try { optionsService.saveOptions(options); //鍒锋柊options @@ -53,10 +54,10 @@ public class OptionController { HaloConst.OPTIONS.clear(); HaloConst.OPTIONS = optionsService.findAllOptions(); log.info("鎵€淇濆瓨鐨勮缃€夐」鍒楄〃锛�" + options); - return true; + return new JsonResult(1,"淇濆瓨鎴愬姛锛�"); } catch (Exception e) { log.error("鏈煡閿欒锛歿0}", e.getMessage()); - return false; + return new JsonResult(0,"淇濆瓨澶辫触锛�"); } } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java index 080b11746e5a441d9d7cce852af50b96a5193847..a40d3b53abc36efeba7b36fd5f8e72862a884b23 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/PageController.java @@ -219,8 +219,16 @@ public class PageController { User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY); post.setUser(user); post.setPostType(HaloConst.POST_TYPE_PAGE); + if(null!=post.getPostId()){ + post.setPostViews(postService.findByPostId(post.getPostId()).get().getPostViews()); + post.setPostDate(postService.findByPostId(post.getPostId()).get().getPostDate()); + post.setPostUpdate(new Date()); + }else{ + post.setPostDate(new Date()); + post.setPostUpdate(new Date()); + } postService.saveByPost(post); - logsService.saveByLogs(new Logs(LogsRecord.PUSH_POST, post.getPostTitle(), HaloUtils.getIpAddr(request), new Date())); + logsService.saveByLogs(new Logs(LogsRecord.PUSH_PAGE, post.getPostTitle(), HaloUtils.getIpAddr(request), new Date())); } catch (Exception e) { log.error("鏈煡閿欒锛歿0}", e.getMessage()); } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java index 7e504c653dceccbc7b1027c983fe6f29571f3486..3ea3f73e9e58a542a61ab35eca9063c4788b8cbe 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/ThemeController.java @@ -2,6 +2,7 @@ package cc.ryanc.halo.web.controller.admin; import cc.ryanc.halo.model.domain.Logs; import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.model.dto.JsonResult; import cc.ryanc.halo.model.dto.LogsRecord; import cc.ryanc.halo.service.LogsService; import cc.ryanc.halo.service.OptionsService; @@ -66,8 +67,8 @@ public class ThemeController extends BaseController { */ @GetMapping(value = "/set") @ResponseBody - public boolean activeTheme(@PathParam("siteTheme") String siteTheme, - HttpServletRequest request) { + public JsonResult activeTheme(@PathParam("siteTheme") String siteTheme, + HttpServletRequest request) { try { //淇濆瓨涓婚璁剧疆椤� optionsService.saveOption("theme", siteTheme); @@ -77,10 +78,10 @@ public class ThemeController extends BaseController { logsService.saveByLogs( new Logs(LogsRecord.CHANGE_THEME, "鏇存崲涓�" + siteTheme, HaloUtils.getIpAddr(request), new Date()) ); - return true; + return new JsonResult(1,"涓婚宸茶缃负"+siteTheme); } catch (Exception e) { log.error("涓婚璁剧疆澶辫触锛屽綋鍓嶄富棰樹负锛�" + siteTheme); - return false; + return new JsonResult(0,"涓婚璁剧疆澶辫触"); } } @@ -93,7 +94,7 @@ public class ThemeController extends BaseController { */ @RequestMapping(value = "/upload", method = RequestMethod.POST) @ResponseBody - public boolean uploadTheme(@RequestParam("file") MultipartFile file, + public JsonResult uploadTheme(@RequestParam("file") MultipartFile file, HttpServletRequest request) { try { if (!file.isEmpty()) { @@ -109,14 +110,15 @@ public class ThemeController extends BaseController { HaloUtils.removeFile(themePath.getAbsolutePath()); HaloConst.THEMES.clear(); HaloConst.THEMES = HaloUtils.getThemes(); - return true; } else { log.error("涓婁紶涓婚澶辫触锛屾病鏈夐€夋嫨鏂囦欢"); + return new JsonResult(0,"璇烽€夋嫨涓婁紶鐨勪富棰橈紒"); } } catch (Exception e) { log.error("涓婁紶涓婚澶辫触锛歿0}", e.getMessage()); + return new JsonResult(0,"涓婚涓婁紶澶辫触锛�"); } - return false; + return new JsonResult(1,"涓婚涓婁紶鎴愬姛锛�"); } /** @@ -194,10 +196,10 @@ public class ThemeController extends BaseController { */ @PostMapping(value = "/editor/save") @ResponseBody - public boolean saveTpl(@RequestParam("tplName") String tplName, + public JsonResult saveTpl(@RequestParam("tplName") String tplName, @RequestParam("tplContent") String tplContent) { if (StringUtils.isBlank(tplContent)) { - return false; + return new JsonResult(0,"妯℃澘涓嶈兘涓虹┖锛�"); } try { //鑾峰彇椤圭洰鏍硅矾寰� @@ -207,9 +209,9 @@ public class ThemeController extends BaseController { byte[] tplContentByte = tplContent.getBytes("UTF-8"); Files.write(Paths.get(tplPath.getAbsolutePath()), tplContentByte); } catch (Exception e) { - log.error("鏂囦欢淇濆瓨澶辫触锛歿0}", e.getMessage()); - return false; + log.error("妯℃澘淇濆瓨澶辫触锛歿0}", e.getMessage()); + return new JsonResult(0,"妯℃澘淇濆瓨澶辫触锛�"); } - return true; + return new JsonResult(1,"妯℃澘淇濆瓨鎴愬姛锛�"); } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java index cd9ef5b4ce4ecc39893ef2600d89e80a6d75db42..8e398c0e8bb8510a837edfe6b95e49d402eb53ec 100644 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/UserController.java @@ -1,6 +1,7 @@ package cc.ryanc.halo.web.controller.admin; import cc.ryanc.halo.model.domain.User; +import cc.ryanc.halo.model.dto.JsonResult; import cc.ryanc.halo.service.UserService; import cc.ryanc.halo.utils.HaloUtils; import freemarker.template.Configuration; @@ -47,20 +48,20 @@ public class UserController { */ @PostMapping(value = "save") @ResponseBody - public boolean saveProfile(@ModelAttribute User user, HttpSession session) { + public JsonResult saveProfile(@ModelAttribute User user, HttpSession session) { try { if (null != user) { userService.saveByUser(user); configuration.setSharedVariable("user", userService.findUser()); session.invalidate(); } else { - return false; + return new JsonResult(0,"淇敼澶辫触锛�"); } } catch (Exception e) { log.error("鏈煡閿欒锛歿0}", e.getMessage()); - return false; + return new JsonResult(0,"淇敼澶辫触锛�"); } - return true; + return new JsonResult(1,"淇敼鎴愬姛锛�"); } /** @@ -74,7 +75,7 @@ public class UserController { */ @PostMapping(value = "changePass") @ResponseBody - public boolean changePass(@ModelAttribute("beforePass") String beforePass, + public JsonResult changePass(@ModelAttribute("beforePass") String beforePass, @ModelAttribute("newPass") String newPass, @ModelAttribute("userId") Long userId, HttpSession session) { @@ -85,12 +86,12 @@ public class UserController { userService.saveByUser(user); session.invalidate(); } else { - return false; + return new JsonResult(0,"鍘熷瘑鐮侀敊璇紒"); } } catch (Exception e) { log.error("淇敼瀵嗙爜锛氭湭鐭ラ敊璇紝{0}", e.getMessage()); - return false; + return new JsonResult(0,"瀵嗙爜淇敼澶辫触锛�"); } - return true; + return new JsonResult(1,"淇敼瀵嗙爜鎴愬姛锛�"); } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/front/FrontCommentController.java b/src/main/java/cc/ryanc/halo/web/controller/front/FrontCommentController.java index 9b11fe7f2dad7e5efea3bdc70d8c384fe366331a..33ece86a3b86a9a89a6b5bbb4044aa3629856038 100644 --- a/src/main/java/cc/ryanc/halo/web/controller/front/FrontCommentController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/front/FrontCommentController.java @@ -3,6 +3,7 @@ package cc.ryanc.halo.web.controller.front; import cc.ryanc.halo.model.domain.Comment; import cc.ryanc.halo.model.domain.Post; import cc.ryanc.halo.model.dto.HaloConst; +import cc.ryanc.halo.model.dto.JsonResult; import cc.ryanc.halo.service.CommentService; import cc.ryanc.halo.service.MailService; import cc.ryanc.halo.service.PostService; @@ -90,33 +91,37 @@ public class FrontCommentController { */ @PostMapping(value = "/newComment") @ResponseBody - public boolean newComment(@ModelAttribute("comment") Comment comment, + public JsonResult newComment(@ModelAttribute("comment") Comment comment, @ModelAttribute("post") Post post, HttpServletRequest request) { - Comment lastComment = null; - post = postService.findByPostId(post.getPostId()).get(); - comment.setCommentAuthorEmail(comment.getCommentAuthorEmail().toLowerCase()); - comment.setPost(post); - comment.setCommentDate(new Date()); - comment.setCommentAuthorIp(HaloUtils.getIpAddr(request)); - comment.setIsAdmin(0); - if(comment.getCommentParent()>0){ - lastComment = commentService.findCommentById(comment.getCommentParent()).get(); - String lastContent = " //<a href='#comment-id-"+lastComment.getCommentId()+"'>@"+lastComment.getCommentAuthor()+"</a>:"+lastComment.getCommentContent(); - comment.setCommentContent(StringUtils.substringAfter(comment.getCommentContent(),":")+lastContent); - } - if(StringUtils.isNotEmpty(comment.getCommentAuthorUrl())){ - if(!StringUtils.containsAny(comment.getCommentAuthorUrl(),"https://") || !StringUtils.containsAny(comment.getCommentAuthorUrl(),"http://")){ - comment.setCommentAuthorUrl("http://"+comment.getCommentAuthorUrl()); + try{ + Comment lastComment = null; + post = postService.findByPostId(post.getPostId()).get(); + comment.setCommentAuthorEmail(comment.getCommentAuthorEmail().toLowerCase()); + comment.setPost(post); + comment.setCommentDate(new Date()); + comment.setCommentAuthorIp(HaloUtils.getIpAddr(request)); + comment.setIsAdmin(0); + if(comment.getCommentParent()>0){ + lastComment = commentService.findCommentById(comment.getCommentParent()).get(); + String lastContent = " //<a href='#comment-id-"+lastComment.getCommentId()+"'>@"+lastComment.getCommentAuthor()+"</a>:"+lastComment.getCommentContent(); + comment.setCommentContent(StringUtils.substringAfter(comment.getCommentContent(),":")+lastContent); } + if(StringUtils.isNotEmpty(comment.getCommentAuthorUrl())){ + if(!StringUtils.containsAny(comment.getCommentAuthorUrl(),"https://") || !StringUtils.containsAny(comment.getCommentAuthorUrl(),"http://")){ + comment.setCommentAuthorUrl("http://"+comment.getCommentAuthorUrl()); + } + } + commentService.saveByComment(comment); + if(comment.getCommentParent()>0){ + //new EmailToParent(comment,lastComment,post).start(); + }else{ + new EmailToAdmin(comment,post).start(); + } + return new JsonResult(1,"浣犵殑璇勮宸茬粡鎻愪氦锛屽緟鍗氫富瀹℃牳涔嬪悗鍙樉绀恒€�"); + }catch (Exception e){ + return new JsonResult(0,"璇勮澶辫触锛�"); } - commentService.saveByComment(comment); - if(comment.getCommentParent()>0){ - //new EmailToParent(comment,lastComment,post).start(); - }else{ - new EmailToAdmin(comment,post).start(); - } - return true; } /** diff --git a/src/main/resources/static/js/app.js b/src/main/resources/static/js/app.js index 038abda5f34fd0a0ba6c3bb3284da7bdb0c7909e..e710b9541a29d3d24db018b536362a967f8233f2 100755 --- a/src/main/resources/static/js/app.js +++ b/src/main/resources/static/js/app.js @@ -44,8 +44,12 @@ function saveOptions(option) { type: 'post', url: '/admin/option/save', data: param, - success: function (result) { - showMsg("淇濆瓨鎴愬姛锛�","success",1000); + success: function (data) { + if(data.code==1){ + showMsg(data.msg,"success",1000); + }else { + showMsg(data.msg,"error",1000); + } } }); } \ No newline at end of file diff --git a/src/main/resources/templates/admin/admin_page_md_editor.ftl b/src/main/resources/templates/admin/admin_page_md_editor.ftl index 4cdeb12bf2a6f44a4e8f1020f0ea95ad9a54a249..f53bb3998fe3eeacf5759a74fb77477a3f375df6 100755 --- a/src/main/resources/templates/admin/admin_page_md_editor.ftl +++ b/src/main/resources/templates/admin/admin_page_md_editor.ftl @@ -232,7 +232,11 @@ }, success: function (data) { $.toast({ - text: "鍙戝竷鎴愬姛锛�", + <#if post??> + text: "鏇存柊鎴愬姛锛�", + <#else> + text: "鍙戣〃鎴愬姛锛�", + </#if> heading: '鎻愮ず', icon: 'success', showHideTransition: 'fade', diff --git a/src/main/resources/templates/admin/admin_post_md_editor.ftl b/src/main/resources/templates/admin/admin_post_md_editor.ftl index 09793d6140fa9bfc562a216afbce5d10de442890..e7e1fdf3e0fe5de259a618842c92ec8baacb2881 100755 --- a/src/main/resources/templates/admin/admin_post_md_editor.ftl +++ b/src/main/resources/templates/admin/admin_post_md_editor.ftl @@ -324,7 +324,11 @@ }, success: function (data) { $.toast({ - text: "鍙戝竷鎴愬姛锛�", + <#if post??> + text: "鏇存柊鎴愬姛锛�", + <#else> + text: "鍙戣〃鎴愬姛锛�", + </#if> heading: '鎻愮ず', icon: 'success', showHideTransition: 'fade', diff --git a/src/main/resources/templates/admin/admin_profile.ftl b/src/main/resources/templates/admin/admin_profile.ftl index 334028ec143a68bb712c9b1875509535dd35d773..dd4c357533f13bb6602d6483f888e339455268db 100644 --- a/src/main/resources/templates/admin/admin_profile.ftl +++ b/src/main/resources/templates/admin/admin_profile.ftl @@ -155,10 +155,10 @@ type: 'post', url: '/admin/profile/save', data: param, - success: function (result) { - if(result==true){ + success: function (data) { + if(data.code==1){ $.toast({ - text: "淇濆瓨鎴愬姛锛�", + text: data.msg, heading: '鎻愮ず', icon: 'success', showHideTransition: 'fade', @@ -174,7 +174,7 @@ } }); }else{ - showMsg("淇濆瓨澶辫触锛�","error",2000); + showMsg(data.msg,"error",2000); } } }); @@ -196,10 +196,10 @@ type: 'post', url: '/admin/profile/changePass', data: param, - success: function (result) { - if(result==true){ + success: function (data) { + if(data.code==1){ $.toast({ - text: "淇敼瀵嗙爜鎴愬姛锛�", + text: data.msg, heading: '鎻愮ず', icon: 'success', showHideTransition: 'fade', @@ -215,7 +215,7 @@ } }); }else{ - showMsg("鍘熷瘑鐮侀敊璇紒","error",2000); + showMsg(data.msg,"error",2000); } } }); diff --git a/src/main/resources/templates/admin/admin_theme-editor.ftl b/src/main/resources/templates/admin/admin_theme-editor.ftl index e9d747a801a98b3dd89e7ac6aab6457bb2b1895c..c5c31e4afdd08ca5599ba4ded4d1ef8d9453f2a5 100644 --- a/src/main/resources/templates/admin/admin_theme-editor.ftl +++ b/src/main/resources/templates/admin/admin_theme-editor.ftl @@ -127,9 +127,9 @@ 'tplContent': editor.getValue() }, success: function (data) { - if(data==true){ + if(data.code==1){ $.toast({ - text: "淇濆瓨鎴愬姛锛�", + text: data.msg, heading: '鎻愮ず', icon: 'success', showHideTransition: 'fade', @@ -143,7 +143,7 @@ }); }else{ $.toast({ - text: "淇濆瓨澶辫触锛�", + text: data.msg, heading: '鎻愮ず', icon: 'error', showHideTransition: 'fade', diff --git a/src/main/resources/templates/admin/admin_theme.ftl b/src/main/resources/templates/admin/admin_theme.ftl index 666cafb6b58d6b4efee1a0c0ea1f13a8d8e3f4ec..a6c9d4f363a469a1cf055015f1cd239ea21ab0bb 100755 --- a/src/main/resources/templates/admin/admin_theme.ftl +++ b/src/main/resources/templates/admin/admin_theme.ftl @@ -146,11 +146,10 @@ dropZoneTitle: '鎷栨嫿涓婚鍘嬬缉鍖呭埌杩欓噷 …<br>涓嶆敮鎸佸涓富棰樺悓鏃朵笂浼�', showClose: false }).on("fileuploaded",function (event,data,previewId,index) { - var data = data.jqXHR.responseJSON; - if(data==true){ + if(data.code==1){ $("#uploadForm").hide(400); $.toast({ - text: "涓婁紶鎴愬姛锛�", + text: data.msg, heading: '鎻愮ず', icon: 'success', showHideTransition: 'fade', @@ -165,6 +164,20 @@ window.location.reload(); } }); + }else{ + $.toast({ + text: data.msg, + heading: '鎻愮ず', + icon: 'error', + showHideTransition: 'fade', + allowToastClose: true, + hideAfter: 1000, + stack: 1, + position: 'top-center', + textAlign: 'left', + loader: true, + loaderBg: '#ffffff' + }); } }); }); @@ -189,11 +202,11 @@ 'siteTheme': site_theme }, success: function (data) { - if(data==true){ + if(data.code==1){ $.toast({ - text: "璁剧疆涓�...", + text: data.msg, heading: '鎻愮ず', - icon: 'info', + icon: 'success', showHideTransition: 'fade', allowToastClose: true, hideAfter: 1000, @@ -206,6 +219,20 @@ window.location.reload(); } }); + }else{ + $.toast({ + text: data.msg, + heading: '鎻愮ず', + icon: 'error', + showHideTransition: 'fade', + allowToastClose: true, + hideAfter: 2000, + stack: 1, + position: 'top-center', + textAlign: 'left', + loader: true, + loaderBg: '#ffffff' + }); } } }); diff --git a/src/main/resources/templates/admin/widget/_attachment-detail.ftl b/src/main/resources/templates/admin/widget/_attachment-detail.ftl index ff71a5f2505c085e58a552da2ce2ef4fc04018a8..239b6b904933e1eda36c22901e2a888948dd77c6 100644 --- a/src/main/resources/templates/admin/widget/_attachment-detail.ftl +++ b/src/main/resources/templates/admin/widget/_attachment-detail.ftl @@ -94,9 +94,9 @@ attachId : ${attachment.attachId?c} }, success: function (data) { - if(data==true){ + if(data.code==1){ $.toast({ - text: "鍒犻櫎鎴愬姛锛�", + text: data.msg, heading: '鎻愮ず', icon: 'success', showHideTransition: 'fade', @@ -112,7 +112,7 @@ } }); }else{ - showMsg("鍒犻櫎澶辫触","error",2000); + showMsg(data.msg,"error",2000); } } }); diff --git a/src/main/resources/templates/common/comment/_native_comment.ftl b/src/main/resources/templates/common/comment/_native_comment.ftl index fe54eafbc1acba2e338ad878605c0100359418f5..c8b27a4eb3dcab39c65b0ebdd79df80cd278698f 100644 --- a/src/main/resources/templates/common/comment/_native_comment.ftl +++ b/src/main/resources/templates/common/comment/_native_comment.ftl @@ -284,13 +284,14 @@ 'commentParent': $('input[name=commentParent]').val() }, success: function (data) { - if (data == true) { - $(".native-message").html("<span>浣犵殑璇勮宸茬粡鎻愪氦锛屽緟鍗氫富瀹℃牳涔嬪悗鍙樉绀恒€�</span>"); - $(".native-message").fadeIn(1000); - setTimeout(function () { - window.location.reload(); - },1500); + if(data.code==1){ + $('.comment-input-content').val(""); } + $(".native-message").html("<span>"+data.msg+"</span>"); + $(".native-message").fadeIn(1000); + setTimeout(function () { + window.location.reload(); + },1500); } }); }); diff --git a/src/main/resources/templates/themes/anatole/module/options.ftl b/src/main/resources/templates/themes/anatole/module/options.ftl index f9559c87e6cbfc5e7bffa9b477b7e0ddc76cf826..b658c5b7313f5770178e6e473ffc3f22b057023f 100644 --- a/src/main/resources/templates/themes/anatole/module/options.ftl +++ b/src/main/resources/templates/themes/anatole/module/options.ftl @@ -214,7 +214,11 @@ url: '/admin/option/save', data: param, success: function (data) { - showMsg("淇濆瓨鎴愬姛锛�","success",1000); + if(data.code==1){ + showMsg(data.msg,"success",1000); + }else{ + showMsg(data.msg,"error",1000); + } } }); } diff --git a/src/main/resources/templates/themes/material/module/options.ftl b/src/main/resources/templates/themes/material/module/options.ftl index 4af0d3c40c711df8f8edd76ffb01fb7ed3b8db17..1e5c4d5c8666dea2555f239e7ad637c83425066b 100644 --- a/src/main/resources/templates/themes/material/module/options.ftl +++ b/src/main/resources/templates/themes/material/module/options.ftl @@ -543,7 +543,11 @@ url: '/admin/option/save', data: param, success: function (data) { - showMsg("淇濆瓨鎴愬姛锛�","success",1000); + if(data.code==1){ + showMsg(data.msg,"success",1000); + }else{ + showMsg(data.msg,"error",1000); + } } }); }