From cc7552d98922c03a9166bd3387c2aaa6862fee65 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Thu, 13 Sep 2018 20:18:07 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E7=BF=BB=E8=AF=91=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-en-US.md | 2 ++ README.md | 2 ++ .../halo/web/controller/admin/PageController.java | 14 +++++++++----- .../halo/web/controller/admin/PostController.java | 14 +++++++++----- .../halo/web/controller/admin/UserController.java | 14 +++++++++----- src/main/resources/i18n/messages_en_US.properties | 13 +++++++++++++ src/main/resources/i18n/messages_zh_CN.properties | 15 ++++++++++++++- src/main/resources/static/js/app.js | 2 +- .../resources/templates/admin/module/_macro.ftl | 1 + 9 files changed, 60 insertions(+), 17 deletions(-) diff --git a/README-en-US.md b/README-en-US.md index e628a33f7..718cf47d4 100755 --- a/README-en-US.md +++ b/README-en-US.md @@ -61,6 +61,8 @@ Let's start: http://localhost:8090 [宋浩志博客](http://songhaozhi.com) +[KingYiFan'S Blog](https://blog.cnbuilder.cn) + ## Download > For deployment to the server, please refer to [Halo部署教程](https://ryanc.cc/archives/halo-run-with-git-maven) or [Wiki](https://github.com/ruibaby/halo/wiki). diff --git a/README.md b/README.md index c46dac7e4..a768abc73 100755 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ Let's start: http://localhost:8090 [宋浩志博客](http://songhaozhi.com) +[KingYiFan'S Blog](https://blog.cnbuilder.cn) + ## 下载部署 > 如需部署到服务器,请参考[Halo部署教程](https://ryanc.cc/archives/halo-run-with-git-maven)或者[Wiki](https://github.com/ruibaby/halo/wiki)。 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 06833fae5..db3bae694 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 @@ -11,6 +11,7 @@ import cc.ryanc.halo.service.GalleryService; import cc.ryanc.halo.service.LinkService; import cc.ryanc.halo.service.LogsService; import cc.ryanc.halo.service.PostService; +import cc.ryanc.halo.utils.LocaleMessageUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.extra.servlet.ServletUtil; @@ -59,6 +60,9 @@ public class PageController { @Autowired private HttpServletRequest request; + @Autowired + LocaleMessageUtil localeMessageUtil; + /** * 页面管理页面 * @@ -193,9 +197,9 @@ public class PageController { galleryService.removeByGalleryId(galleryId); } catch (Exception e) { log.error("删除图片失败:{}", e.getMessage()); - return new JsonResult(ResultCodeEnum.FAIL.getCode(), "删除失败!"); + return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.delete-failed")); } - return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "删除成功!"); + return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), localeMessageUtil.getMessage("code.admin.common.delete-success")); } @@ -218,7 +222,7 @@ public class PageController { @PostMapping(value = "/new/push") @ResponseBody public JsonResult pushPage(@ModelAttribute Post post, HttpSession session) { - String msg = "发表成功"; + String msg = localeMessageUtil.getMessage("code.admin.common.save-success"); try { post.setPostDate(DateUtil.date()); //发表用户 @@ -229,7 +233,7 @@ public class PageController { post.setPostViews(postService.findByPostId(post.getPostId()).get().getPostViews()); post.setPostDate(postService.findByPostId(post.getPostId()).get().getPostDate()); post.setPostUpdate(DateUtil.date()); - msg = "更新成功"; + msg = localeMessageUtil.getMessage("code.admin.common.update-success"); } else { post.setPostDate(DateUtil.date()); post.setPostUpdate(DateUtil.date()); @@ -243,7 +247,7 @@ public class PageController { return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), msg); } catch (Exception e) { log.error("保存页面失败:{}", e.getMessage()); - return new JsonResult(ResultCodeEnum.FAIL.getCode(), "保存失败"); + return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.save-failed")); } } diff --git a/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java b/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java index f29dc6a30..8bf044299 100755 --- a/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java +++ b/src/main/java/cc/ryanc/halo/web/controller/admin/PostController.java @@ -13,6 +13,7 @@ import cc.ryanc.halo.service.LogsService; import cc.ryanc.halo.service.PostService; import cc.ryanc.halo.service.TagService; import cc.ryanc.halo.utils.HaloUtils; +import cc.ryanc.halo.utils.LocaleMessageUtil; import cc.ryanc.halo.web.controller.core.BaseController; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; @@ -64,6 +65,9 @@ public class PostController extends BaseController { @Autowired private HttpServletRequest request; + @Autowired + private LocaleMessageUtil localeMessageUtil; + /** * 去除html,htm后缀,以及将空格替换成- * @@ -165,7 +169,7 @@ public class PostController extends BaseController { @ResponseBody public JsonResult pushPost(@ModelAttribute Post post, @RequestParam("cateList") List cateList, @RequestParam("tagList") String tagList, HttpSession session) { User user = (User) session.getAttribute(HaloConst.USER_SESSION_KEY); - String msg = "发表成功"; + String msg = localeMessageUtil.getMessage("code.admin.common.save-success"); try { //提取摘要 int postSummary = 50; @@ -186,7 +190,7 @@ public class PostController extends BaseController { post.setPostDate(oldPost.getPostDate()); post.setPostUpdate(DateUtil.date()); post.setPostViews(oldPost.getPostViews()); - msg = "更新成功"; + msg = localeMessageUtil.getMessage("code.admin.common.update-success"); } else { post.setPostDate(DateUtil.date()); post.setPostUpdate(DateUtil.date()); @@ -208,7 +212,7 @@ public class PostController extends BaseController { return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), msg); } catch (Exception e) { log.error("保存文章失败:{}", e.getMessage()); - return new JsonResult(ResultCodeEnum.FAIL.getCode(), "保存失败"); + return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.save-failed")); } } @@ -261,9 +265,9 @@ public class PostController extends BaseController { post.setUser(user); } catch (Exception e) { log.error("未知错误:{}", e.getMessage()); - return new JsonResult(ResultCodeEnum.FAIL.getCode(), "保存失败"); + return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.save-failed")); } - return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "保存成功", postService.saveByPost(post)); + return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), localeMessageUtil.getMessage("code.admin.common.save-success"), postService.saveByPost(post)); } 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 220f96e7e..c0db2dc18 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 @@ -4,6 +4,7 @@ import cc.ryanc.halo.model.domain.User; import cc.ryanc.halo.model.dto.JsonResult; import cc.ryanc.halo.model.enums.ResultCodeEnum; import cc.ryanc.halo.service.UserService; +import cc.ryanc.halo.utils.LocaleMessageUtil; import cn.hutool.crypto.SecureUtil; import freemarker.template.Configuration; import lombok.extern.slf4j.Slf4j; @@ -35,6 +36,9 @@ public class UserController { @Autowired private Configuration configuration; + @Autowired + private LocaleMessageUtil localeMessageUtil; + /** * 获取用户信息并跳转 * @@ -66,9 +70,9 @@ public class UserController { session.invalidate(); } catch (Exception e) { log.error("修改用户资料失败:{}", e.getMessage()); - return new JsonResult(ResultCodeEnum.FAIL.getCode(), "修改失败!"); + return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.common.edit-failed")); } - return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "修改成功!"); + return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), localeMessageUtil.getMessage("code.admin.common.edit-success")); } /** @@ -93,12 +97,12 @@ public class UserController { userService.saveByUser(user); session.invalidate(); } else { - return new JsonResult(ResultCodeEnum.FAIL.getCode(), "原密码错误!"); + return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.user.old-password-error")); } } catch (Exception e) { log.error("修改密码失败:{}", e.getMessage()); - return new JsonResult(ResultCodeEnum.FAIL.getCode(), "密码修改失败!"); + return new JsonResult(ResultCodeEnum.FAIL.getCode(), localeMessageUtil.getMessage("code.admin.user.update-password-failed")); } - return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), "修改密码成功!"); + return new JsonResult(ResultCodeEnum.SUCCESS.getCode(), localeMessageUtil.getMessage("code.admin.user.update-password-success")); } } diff --git a/src/main/resources/i18n/messages_en_US.properties b/src/main/resources/i18n/messages_en_US.properties index 39f0e192a..a87da2290 100644 --- a/src/main/resources/i18n/messages_en_US.properties +++ b/src/main/resources/i18n/messages_en_US.properties @@ -72,6 +72,11 @@ admin.index.widgets.logs-lastest = Newest logs admin.index.widgets.btn.clear-logs = Clear logs admin.index.blog-data.motto = Come on! Don’t forget why you left because you’re too far away. admin.index.blog-data.during = During this period: +admin.index.blog-data.posts-count-text = A total of %s posts has been published. +admin.index.blog-data.tags-count-text = A total of {0} tags has been created. +admin.index.blog-data.comments-count-text = A total of {0} comments was received. +admin.index.blog-data.links-count-text = A total of {0} friend chains have been added. +admin.index.blog-data.views-count-text = The posts was visited {0} times in total. # attachments page admin.attachments.title = Attachments manage @@ -266,9 +271,17 @@ code.admin.backup.have-new-backup = Have a new backup! code.admin.theme.change-success = Theme has been set to {0} code.admin.theme.change-failed = Theme settings failed! +code.admin.user.old-password-error = The original password is wrong! +code.admin.user.update-password-failed = Failed to change password! +code.admin.user.update-password-success = Password has been updated! + code.admin.common.delete-success = Deleted successfully! code.admin.common.delete-failed = Deleted Failed! code.admin.common.no-post = The mailing mailbox is not configured! code.admin.common.save-success = Saved successfully! code.admin.common.save-failed = Save failed! +code.admin.common.update-success = Updated successfully! + +code.admin.common.edit-success = Successfully modified! +code.admin.common.edit-failed = Fail to update! diff --git a/src/main/resources/i18n/messages_zh_CN.properties b/src/main/resources/i18n/messages_zh_CN.properties index b41431cbe..8a170c0a9 100644 --- a/src/main/resources/i18n/messages_zh_CN.properties +++ b/src/main/resources/i18n/messages_zh_CN.properties @@ -72,6 +72,11 @@ admin.index.widgets.logs-lastest = 最新日志 admin.index.widgets.btn.clear-logs = 清空日志 admin.index.blog-data.motto = 加油!不要因为走的太远,而忘了当初为什么出发。 admin.index.blog-data.during = 在此期间: +admin.index.blog-data.posts-count-text = 累计发表了 {0} 篇文章。 +admin.index.blog-data.tags-count-text = 累计创建了 {0} 个标签。 +admin.index.blog-data.comments-count-text = 累计获得了 {0} 条评论。 +admin.index.blog-data.links-count-text = 累计添加了 {0} 个友链。 +admin.index.blog-data.views-count-text = 文章总访问 {0} 次。 # 附件管理页面 admin.attachments.title = 附件管理 @@ -229,7 +234,7 @@ common.th.file-type = 文件类型 common.status.published = 已发布 common.status.checking = 待审核 common.status.recycle-bin = 回收站 -common.status.draft = 草 稿 +common.status.draft = 草 稿 common.text.no-data = 暂无数据 common.text.tips = 提示 @@ -266,9 +271,17 @@ code.admin.backup.have-new-backup = 有新的备份! code.admin.theme.change-success = 主题已设置为{0} code.admin.theme.change-failed = 主题设置失败! +code.admin.user.old-password-error = 原密码错误! +code.admin.user.update-password-failed = 修改密码失败! +code.admin.user.update-password-success = 修改密码成功! + code.admin.common.delete-success = 删除成功! code.admin.common.delete-failed = 删除失败! code.admin.common.no-post = 发信邮箱没有配置! code.admin.common.save-success = 保存成功! code.admin.common.save-failed = 保存失败! +code.admin.common.update-success = 更新成功! + +code.admin.common.edit-success = 修改成功! +code.admin.common.edit-failed = 修改失败! diff --git a/src/main/resources/static/js/app.js b/src/main/resources/static/js/app.js index dbbfc719d..a466e8ebc 100755 --- a/src/main/resources/static/js/app.js +++ b/src/main/resources/static/js/app.js @@ -67,7 +67,7 @@ function initMenu() { function showMsg(text,icon,hideAfter) { $.toast({ text: text, - heading: '提示', + heading: heading, icon: icon, showHideTransition: 'fade', allowToastClose: true, diff --git a/src/main/resources/templates/admin/module/_macro.ftl b/src/main/resources/templates/admin/module/_macro.ftl index bbe57b8d9..6b82d89df 100644 --- a/src/main/resources/templates/admin/module/_macro.ftl +++ b/src/main/resources/templates/admin/module/_macro.ftl @@ -68,6 +68,7 @@ },500); }); + var heading = "<@spring.message code='common.text.tips' />";