From f4da698d5431e87bb01979df4a15aec34a379fdc Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Wed, 27 Jan 2021 23:01:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0html=E7=9A=84=E5=A4=9A?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomBeetlGroupUtilConfiguration.java | 7 +++-- src/main/webapp/pages/index.html | 30 +++++++++++++++++-- src/main/webapp/pages/layout/_header.html | 4 ++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java b/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java index b05abc3b..9c749142 100644 --- a/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java +++ b/src/main/java/cn/stylefeng/guns/core/beetl/CustomBeetlGroupUtilConfiguration.java @@ -5,6 +5,7 @@ import cn.stylefeng.guns.core.beetl.tag.SysDictCheckBoxTag; import cn.stylefeng.guns.core.beetl.tag.SysDictRadioTag; import cn.stylefeng.guns.core.beetl.tag.SysDictSelectTag; import cn.stylefeng.roses.kernel.auth.api.LoginUserApi; +import cn.stylefeng.roses.kernel.i18n.util.QuickTranslateUtil; import cn.stylefeng.roses.kernel.system.expander.SystemConfigExpander; import org.beetl.ext.spring.BeetlGroupUtilConfiguration; @@ -34,6 +35,9 @@ public class CustomBeetlGroupUtilConfiguration extends BeetlGroupUtilConfigurati // 获取基本信息的工具 groupTemplate.registerFunctionPackage("constants", SystemConfigExpander.class); + // 多语言 + groupTemplate.registerFunctionPackage("translate", QuickTranslateUtil.class); + // 下拉选字典 groupTemplate.registerTag("dict_select", SysDictSelectTag.class); @@ -42,9 +46,6 @@ public class CustomBeetlGroupUtilConfiguration extends BeetlGroupUtilConfigurati // 多选字典 groupTemplate.registerTag("dict_checkbox", SysDictCheckBoxTag.class); - - // todo 多语言 -// groupTemplate.registerFunctionPackage("lang", new UserTranslationContext()); } } diff --git a/src/main/webapp/pages/index.html b/src/main/webapp/pages/index.html index 82674252..90f22c2d 100644 --- a/src/main/webapp/pages/index.html +++ b/src/main/webapp/pages/index.html @@ -54,6 +54,31 @@ var ws = layui.ws; var notice = layui.notice; + //获取支持的语言列表 + var languageRequest = new HttpRequest(Feng.ctxPath + "/i18n/getAllLanguages", 'get', function (data) { + for (var i = 0; i < data.data.length; i++) { + var code = data.data[i].code; + var description = data.data[i].name; + $("#languageDiv").append('
' + description + '
'); + + //设置监听事件,设置点击按钮切换当前系统语言 + (function (code) { + $('#tran-' + code).click(function () { + var changeLanguageRequest = new HttpRequest(Feng.ctxPath + "/i18n/changeUserTranslation", 'post', function (data) { + window.location.href = Feng.ctxPath + "/"; + }, function (data) { + layer.msg("切换多语言失败!" + data.message, {icon: 5, anim: 6}); + }); + changeLanguageRequest.set("tranLanguageCode", code); + changeLanguageRequest.start(true); + }); + })(code); + } + }, function (data) { + layer.msg("获取语言列表失败!" + data.responseJSON.message, {icon: 5, anim: 6}); + }); + languageRequest.start(); + // 默认加载主页 index.loadHome({ menuPath: $("#firstPageAction").attr('lay-href'), @@ -106,7 +131,8 @@ timeout: false }); $('#messageDot').hide(); - } catch (e) {} + } catch (e) { + } }, onWsClose: function (event) { //关闭连接回调 @@ -163,4 +189,4 @@ - \ No newline at end of file + diff --git a/src/main/webapp/pages/layout/_header.html b/src/main/webapp/pages/layout/_header.html index 4fd3e04b..da2363de 100644 --- a/src/main/webapp/pages/layout/_header.html +++ b/src/main/webapp/pages/layout/_header.html @@ -55,7 +55,9 @@
个人中心
-
修改密码
+
${translate.get("MENU_CHANGE_PASSWORD","修改密码")}
+
+

退出