Commit f3e7902f by fengshuonan

新增系统名称全局变量

parent f9422b8b
...@@ -34,6 +34,6 @@ public class GunsApplication { ...@@ -34,6 +34,6 @@ public class GunsApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(GunsApplication.class, args); SpringApplication.run(GunsApplication.class, args);
logger.info("GunsApplication is success!"); logger.info(GunsApplication.class.getSimpleName() + " is success!");
} }
} }
...@@ -15,17 +15,15 @@ ...@@ -15,17 +15,15 @@
*/ */
package cn.stylefeng.guns.core.beetl; package cn.stylefeng.guns.core.beetl;
import cn.stylefeng.guns.core.util.DefaultImages;
import cn.stylefeng.guns.core.util.KaptchaUtil; import cn.stylefeng.guns.core.util.KaptchaUtil;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
import org.beetl.core.Context;
import org.beetl.core.Function;
import org.beetl.ext.spring.BeetlGroupUtilConfiguration; import org.beetl.ext.spring.BeetlGroupUtilConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import java.io.UnsupportedEncodingException; import java.util.HashMap;
import java.nio.charset.StandardCharsets; import java.util.Map;
import static cn.stylefeng.guns.core.common.constant.Const.DEFAULT_SYSTEM_NAME;
import static cn.stylefeng.guns.core.common.constant.Const.DEFAULT_WELCOME_TIP;
/** /**
* beetl拓展配置,绑定一些工具类,方便在模板中直接调用 * beetl拓展配置,绑定一些工具类,方便在模板中直接调用
...@@ -35,38 +33,18 @@ import java.nio.charset.StandardCharsets; ...@@ -35,38 +33,18 @@ import java.nio.charset.StandardCharsets;
*/ */
public class BeetlConfiguration extends BeetlGroupUtilConfiguration { public class BeetlConfiguration extends BeetlGroupUtilConfiguration {
@Autowired
private Environment env;
@Override @Override
public void initOther() { public void initOther() {
groupTemplate.registerFunctionPackage("images", new DefaultImages()); //全局共享变量
Map<String, Object> shared = new HashMap<>();
shared.put("systemName", DEFAULT_SYSTEM_NAME);
shared.put("welcomeTip", DEFAULT_WELCOME_TIP);
groupTemplate.setSharedVars(shared);
//全局共享方法
groupTemplate.registerFunctionPackage("shiro", new ShiroExt()); groupTemplate.registerFunctionPackage("shiro", new ShiroExt());
groupTemplate.registerFunctionPackage("tool", new ToolUtil()); groupTemplate.registerFunctionPackage("tool", new ToolUtil());
groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil()); groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil());
groupTemplate.registerFunction("env", new Function() {
@Override
public String call(Object[] paras, Context ctx) {
String key = (String) paras[0];
String value = env.getProperty(key);
if (value != null) {
return getStr(value);
}
if (paras.length == 2) {
return (String) paras[1];
}
return null;
}
String getStr(String str) {
try {
return new String(str.getBytes("iso8859-1"), StandardCharsets.UTF_8);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
});
} }
} }
...@@ -28,6 +28,16 @@ import java.util.List; ...@@ -28,6 +28,16 @@ import java.util.List;
public interface Const { public interface Const {
/** /**
* 默认管理系统的名称
*/
String DEFAULT_SYSTEM_NAME = "Guns管理系统";
/**
* 默认欢迎界面的提示
*/
String DEFAULT_WELCOME_TIP = "欢迎使用Guns管理系统!";
/**
* 系统默认的管理员密码 * 系统默认的管理员密码
*/ */
String DEFAULT_PWD = "111111"; String DEFAULT_PWD = "111111";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<title>Guns管理系统</title> <title>${systemName}</title>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="layui-logo"> <div class="layui-logo">
<!--<img src="${ctxPath}/assets/common/images/logo.png"/>--> <!--<img src="${ctxPath}/assets/common/images/logo.png"/>-->
<i class="layui-icon layui-icon-component"></i> <i class="layui-icon layui-icon-component"></i>
<cite>&nbsp;Guns管理系统&emsp;</cite> <cite>&nbsp;${systemName}&emsp;</cite>
</div> </div>
<ul class="layui-nav layui-layout-left"> <ul class="layui-nav layui-layout-left">
<li class="layui-nav-item" lay-unselect> <li class="layui-nav-item" lay-unselect>
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>${title!"Guns管理系统"}</title> <title>${systemName}</title>
<meta name="description" content="Guns管理系统"> <meta name="description" content="${systemName}">
<meta name="author" content="stylefeng"> <meta name="author" content="stylefeng">
<!--其他插件css--> <!--其他插件css-->
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="${ctxPath}/assets/common/images/favicon.ico" rel="icon"> <link href="${ctxPath}/assets/common/images/favicon.ico" rel="icon">
<title>Guns管理系统</title> <title>${systemName}</title>
<link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/> <link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/>
<link rel="stylesheet" href="${ctxPath}/assets/common/module/admin.css"/> <link rel="stylesheet" href="${ctxPath}/assets/common/module/admin.css"/>
</head> </head>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<div class="login-wrapper"> <div class="login-wrapper">
<div class="login-header"> <div class="login-header">
<img src="${ctxPath}/assets/common/images/logo.png"> Guns管理系统 <img src="${ctxPath}/assets/common/images/logo.png"> ${systemName}
</div> </div>
<div class=" login-body"> <div class=" login-body">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<title>Guns管理系统</title> <title>${systemName}</title>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</div> </div>
<div class="layui-card-body" style="text-align: center;"> <div class="layui-card-body" style="text-align: center;">
<h2 style="margin-top: 170px;margin-bottom: 20px;font-size: 28px;color: #91ADDC;">欢迎使用Guns管理系统 !</h2> <h2 style="margin-top: 170px;margin-bottom: 20px;font-size: 28px;color: #91ADDC;">${welcomeTip}</h2>
<img src="${ctxPath}/assets/common/images/welcome.png" style="max-width: 100%;"> <img src="${ctxPath}/assets/common/images/welcome.png" style="max-width: 100%;">
</div> </div>
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>${title!"Guns管理系统"}</title> <title>${systemName}</title>
<meta name="description" content="Guns管理系统"> <meta name="description" content="${systemName}">
<meta name="author" content="stylefeng"> <meta name="author" content="stylefeng">
<link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/> <link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/>
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>${title!"Guns管理系统"}</title> <title>${systemName}</title>
<meta name="description" content="Guns管理系统"> <meta name="description" content="${systemName}">
<meta name="author" content="stylefeng"> <meta name="author" content="stylefeng">
<link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/> <link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment