Skip to content

Commit 189f671

Browse files
committed
移除 yauaa 获取UA信息,采用hutoolUA工具类-UserAgentUtil 获取浏览器信息:elunez/eladmin-mp#5
1 parent 39d4809 commit 189f671

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
package me.zhengjie.utils;
1717

18+
import cn.hutool.http.useragent.UserAgent;
19+
import cn.hutool.http.useragent.UserAgentUtil;
1820
import lombok.extern.slf4j.Slf4j;
1921
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
2022
import net.dreamlu.mica.ip2region.core.IpInfo;
21-
import nl.basjes.parse.useragent.UserAgent;
22-
import nl.basjes.parse.useragent.UserAgentAnalyzer;
2323
import javax.servlet.http.HttpServletRequest;
2424
import java.net.InetAddress;
2525
import java.net.NetworkInterface;
@@ -43,14 +43,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
4343
*/
4444
private final static Ip2regionSearcher IP_SEARCHER = SpringContextHolder.getBean(Ip2regionSearcher.class);
4545

46-
47-
private static final UserAgentAnalyzer USER_AGENT_ANALYZER = UserAgentAnalyzer
48-
.newBuilder()
49-
.hideMatcherLoadStats()
50-
.withCache(10000)
51-
.withField(UserAgent.AGENT_NAME_VERSION)
52-
.build();
53-
5446
/**
5547
* 驼峰命名法工具
5648
*
@@ -178,8 +170,8 @@ public static String getCityInfo(String ip) {
178170
}
179171

180172
public static String getBrowser(HttpServletRequest request) {
181-
UserAgent.ImmutableUserAgent userAgent = USER_AGENT_ANALYZER.parse(request.getHeader("User-Agent"));
182-
return userAgent.get(UserAgent.AGENT_NAME_VERSION).getValue();
173+
UserAgent ua = UserAgentUtil.parse(request.getHeader("User-Agent"));
174+
return ua.getBrowser().toString() + " " + ua.getVersion();
183175
}
184176

185177
/**

pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,6 @@
188188
<artifactId>commons-text</artifactId>
189189
<version>1.10.0</version>
190190
</dependency>
191-
192-
<!-- 解析客户端操作系统、浏览器信息 -->
193-
<dependency>
194-
<groupId>nl.basjes.parse.useragent</groupId>
195-
<artifactId>yauaa</artifactId>
196-
<version>6.11</version>
197-
</dependency>
198191
</dependencies>
199192

200193
<build>

0 commit comments

Comments
 (0)