1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00

close #491 Wechat mobile device

This commit is contained in:
Yu 2021-11-16 11:02:56 +08:00
parent e7c45782e7
commit ff7ab98bcf

View File

@ -39,18 +39,20 @@ public class MobileDevice {
+ "|mobile|up.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\\b"; + "|mobile|up.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";
static String tableReg = "\\b(ipad|tablet|(Nexus 7)|up.browser" static String tableReg = "\\b(ipad|tablet|(Nexus 7)|up.browser"
+ "|[1-4][0-9]{2}x[1-4][0-9]{2})\\b"; + "|[1-4][0-9]{2}x[1-4][0-9]{2})\\b";
static String wechatReg = "MicroMessenger";
//移动设备正则匹配手机端平板 //移动设备正则匹配手机端平板
static Pattern phonePat = Pattern.compile(phoneReg, Pattern.CASE_INSENSITIVE); static Pattern phonePat = Pattern.compile(phoneReg, Pattern.CASE_INSENSITIVE);
static Pattern tablePat = Pattern.compile(tableReg, Pattern.CASE_INSENSITIVE); static Pattern tablePat = Pattern.compile(tableReg, Pattern.CASE_INSENSITIVE);
static Pattern wechatPat = Pattern.compile(wechatReg, Pattern.CASE_INSENSITIVE);
/** /**
* 检测是否是移动设备访问 * 检测是否是移动设备访问
* *
* @Title: isMobile
* @Date : 2014-7-7 下午01:29:07
* @param userAgent 浏览器标识 * @param userAgent 浏览器标识
* @return true:移动设备接入false:pc端接入 * @return true:移动设备接入false:pc端接入
* @Title: isMobile
* @Date : 2014-7-7 下午01:29:07
*/ */
public static boolean isMobile(String userAgent) { public static boolean isMobile(String userAgent) {
if (null == userAgent) { if (null == userAgent) {
@ -59,7 +61,8 @@ public class MobileDevice {
// 匹配 // 匹配
Matcher matcherPhone = phonePat.matcher(userAgent); Matcher matcherPhone = phonePat.matcher(userAgent);
Matcher matcherTable = tablePat.matcher(userAgent); Matcher matcherTable = tablePat.matcher(userAgent);
if(matcherPhone.find() || matcherTable.find()){ Matcher matcherWechat = wechatPat.matcher(userAgent);
if (matcherPhone.find() || matcherTable.find() || matcherWechat.find()) {
return true; return true;
} else { } else {
return false; return false;