File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 328328 UploadData: {
329329 location: LocationCityName,
330330 ip: ip,
331- time: dateString
331+ time: dateString,
332+ browser: that .getSQBrowser ()
332333 },
333334 Success : function () {
334335 that .setSQCookie (' sunqBlog' ,' 统计访问量' ,12 ); // 12个小时内同一个浏览器算一个访问量
Original file line number Diff line number Diff line change @@ -197,6 +197,53 @@ CommonFunction.install = function (Vue) {
197197 }
198198 return '' ;
199199 } ;
200+ Vue . prototype . getSQBrowser = function ( ) {
201+ var userAgent = navigator . userAgent ; //取得浏览器的userAgent字符串
202+ var isOpera = userAgent . indexOf ( 'Opera' ) > - 1 ; //判断是否Opera浏览器
203+ var isIE = userAgent . indexOf ( 'compatible' ) > - 1
204+ && userAgent . indexOf ( 'MSIE' ) > - 1 && ! isOpera ; //判断是否IE浏览器
205+ var isEdge = userAgent . indexOf ( 'Edge' ) > - 1 ; //判断是否IE的Edge浏览器
206+ var isFF = userAgent . indexOf ( 'Firefox' ) > - 1 ; //判断是否Firefox浏览器
207+ var isSafari = userAgent . indexOf ( 'Safari' ) > - 1
208+ && userAgent . indexOf ( 'Chrome' ) == - 1 ; //判断是否Safari浏览器
209+ var isChrome = userAgent . indexOf ( 'Chrome' ) > - 1
210+ && userAgent . indexOf ( 'Safari' ) > - 1 ; //判断Chrome浏览器
211+
212+ if ( isIE ) {
213+ var reIE = new RegExp ( 'MSIE (\\d+\\.\\d+);' ) ;
214+ reIE . test ( userAgent ) ;
215+ var fIEVersion = parseFloat ( RegExp [ '$1' ] ) ;
216+ if ( fIEVersion == 7 ) {
217+ return 'IE7' ;
218+ } else if ( fIEVersion == 8 ) {
219+ return 'IE8' ;
220+ } else if ( fIEVersion == 9 ) {
221+ return 'IE9' ;
222+ } else if ( fIEVersion == 10 ) {
223+ return 'IE10' ;
224+ } else if ( fIEVersion == 11 ) {
225+ return 'IE11' ;
226+ } else {
227+ return '0' ;
228+ } //IE版本过低
229+ return 'IE' ;
230+ }
231+ if ( isOpera ) {
232+ return 'Opera' ;
233+ }
234+ if ( isEdge ) {
235+ return 'Edge' ;
236+ }
237+ if ( isFF ) {
238+ return 'FF' ;
239+ }
240+ if ( isSafari ) {
241+ return 'Safari' ;
242+ }
243+ if ( isChrome ) {
244+ return 'Chrome' ;
245+ }
246+ } ;
200247} ;
201248
202249export default CommonFunction ;
You can’t perform that action at this time.
0 commit comments