新增菜单导航显示风格(default为左侧导航菜单,topnav为顶部导航菜单)

This commit is contained in:
RuoYi
2020-09-03 10:03:49 +08:00
parent 947120d136
commit bf1e52fd9d
14 changed files with 707 additions and 33 deletions

View File

@ -30,6 +30,9 @@ public class Global
/** 获取地址开关 */
private static boolean addressEnabled;
/** 菜单导航显示风格 */
private static String menuStyle;
public static String getName()
{
return name;
@ -90,6 +93,16 @@ public class Global
Global.addressEnabled = addressEnabled;
}
public static String getMenuStyle()
{
return menuStyle;
}
public void setMenuStyle(String menuStyle)
{
Global.menuStyle = menuStyle;
}
/**
* 获取头像上传路径
*/

View File

@ -0,0 +1,138 @@
package com.ruoyi.common.utils;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Cookie工具类
*
* @author ruoyi
*/
public class CookieUtils
{
/**
* 设置 Cookie生成时间为1天
*
* @param name 名称
* @param value 值
*/
public static void setCookie(HttpServletResponse response, String name, String value)
{
setCookie(response, name, value, 60 * 60 * 24);
}
/**
* 设置 Cookie
*
* @param name 名称
* @param value 值
* @param maxAge 生存时间(单位秒)
* @param uri 路径
*/
public static void setCookie(HttpServletResponse response, String name, String value, String path)
{
setCookie(response, name, value, path, 60 * 60 * 24);
}
/**
* 设置 Cookie
*
* @param name 名称
* @param value 值
* @param maxAge 生存时间(单位秒)
* @param uri 路径
*/
public static void setCookie(HttpServletResponse response, String name, String value, int maxAge)
{
setCookie(response, name, value, "/", maxAge);
}
/**
* 设置 Cookie
*
* @param name 名称
* @param value 值
* @param maxAge 生存时间(单位秒)
* @param uri 路径
*/
public static void setCookie(HttpServletResponse response, String name, String value, String path, int maxAge)
{
Cookie cookie = new Cookie(name, null);
cookie.setPath(path);
cookie.setMaxAge(maxAge);
try
{
cookie.setValue(URLEncoder.encode(value, "utf-8"));
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
response.addCookie(cookie);
}
/**
* 获得指定Cookie的值
*
* @param name 名称
* @return 值
*/
public static String getCookie(HttpServletRequest request, String name)
{
return getCookie(request, null, name, false);
}
/**
* 获得指定Cookie的值并删除。
*
* @param name 名称
* @return 值
*/
public static String getCookie(HttpServletRequest request, HttpServletResponse response, String name)
{
return getCookie(request, response, name, true);
}
/**
* 获得指定Cookie的值
*
* @param request 请求对象
* @param response 响应对象
* @param name 名字
* @param isRemove 是否移除
* @return 值
*/
public static String getCookie(HttpServletRequest request, HttpServletResponse response, String name,
boolean isRemove)
{
String value = null;
Cookie[] cookies = request.getCookies();
if (cookies != null)
{
for (Cookie cookie : cookies)
{
if (cookie.getName().equals(name))
{
try
{
value = URLDecoder.decode(cookie.getValue(), "utf-8");
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
if (isRemove)
{
cookie.setMaxAge(0);
response.addCookie(cookie);
}
}
}
}
return value;
}
}

View File

@ -16,6 +16,11 @@ import com.ruoyi.common.core.text.Convert;
*/
public class ServletUtils
{
/**
* 定义移动端请求的所有可能类型
*/
private final static String[] agent = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
/**
* 获取String参数
*/
@ -132,4 +137,28 @@ public class ServletUtils
}
return false;
}
/**
* 判断User-Agent 是不是来自于手机
*/
public static boolean checkAgentIsMobile(String ua)
{
boolean flag = false;
if (!ua.contains("Windows NT") || (ua.contains("Windows NT") && ua.contains("compatible; MSIE 9.0;")))
{
// 排除 苹果桌面系统
if (!ua.contains("Windows NT") && !ua.contains("Macintosh"))
{
for (String item : agent)
{
if (ua.contains(item))
{
flag = true;
break;
}
}
}
}
return flag;
}
}