File tree Expand file tree Collapse file tree 2 files changed +4
-19
lines changed
eladmin-common/src/main/java/me/zhengjie/utils Expand file tree Collapse file tree 2 files changed +4
-19
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package me .zhengjie .utils ;
17
17
18
+ import cn .hutool .http .useragent .UserAgent ;
19
+ import cn .hutool .http .useragent .UserAgentUtil ;
18
20
import lombok .extern .slf4j .Slf4j ;
19
21
import net .dreamlu .mica .ip2region .core .Ip2regionSearcher ;
20
22
import net .dreamlu .mica .ip2region .core .IpInfo ;
21
- import nl .basjes .parse .useragent .UserAgent ;
22
- import nl .basjes .parse .useragent .UserAgentAnalyzer ;
23
23
import javax .servlet .http .HttpServletRequest ;
24
24
import java .net .InetAddress ;
25
25
import java .net .NetworkInterface ;
@@ -43,14 +43,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
43
43
*/
44
44
private final static Ip2regionSearcher IP_SEARCHER = SpringContextHolder .getBean (Ip2regionSearcher .class );
45
45
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
-
54
46
/**
55
47
* 驼峰命名法工具
56
48
*
@@ -178,8 +170,8 @@ public static String getCityInfo(String ip) {
178
170
}
179
171
180
172
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 ();
183
175
}
184
176
185
177
/**
Original file line number Diff line number Diff line change 188
188
<artifactId >commons-text</artifactId >
189
189
<version >1.10.0</version >
190
190
</dependency >
191
-
192
- <!-- 解析客户端操作系统、浏览器信息 -->
193
- <dependency >
194
- <groupId >nl.basjes.parse.useragent</groupId >
195
- <artifactId >yauaa</artifactId >
196
- <version >6.11</version >
197
- </dependency >
198
191
</dependencies >
199
192
200
193
<build >
You can’t perform that action at this time.
0 commit comments