Skip to content

Commit

Permalink
1.5.21
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Apr 28, 2018
1 parent 766d095 commit d724d65
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 21 deletions.
43 changes: 33 additions & 10 deletions dist/xe-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,17 +909,37 @@
clone: clone
}

function isMobile () {
var agents = ['Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'SymbianOS', 'BlackBerry', 'Windows Phone']
for (var userAgentInfo = navigator.userAgent, i = 0; i < agents.length; i++) {
if (userAgentInfo.indexOf(agents[i]) > 0) {
return true
}
}
return false
}

/**
* 获取浏览器内核
* @return Object
*/
function browse () {
var result = {}
if (typeof document !== 'undefined') {
var $body = document.body || document.documentElement
baseExports.arrayEach(['webkit', 'khtml', 'moz', 'ms', 'o'], function (core) {
result['-' + core] = !!$body[core + 'MatchesSelector']
})
var result = {
isNode: false,
isMobile: false,
isPC: false
}
if (typeof window === 'undefined' && typeof process !== 'undefined') {
result.nodeJS = true
} else {
result.isMobile = isMobile()
result.isPC = !result.isMobile
if (typeof document !== 'undefined') {
var $body = document.body || document.documentElement
baseExports.arrayEach(['webkit', 'khtml', 'moz', 'ms', 'o'], function (core) {
result['-' + core] = !!$body[core + 'MatchesSelector']
})
}
}
return result
}
Expand Down Expand Up @@ -1244,13 +1264,16 @@
}

function getLocatOrigin () {
return $locat.origin || ($locat.protocol + '//' + $locat.host)
return $locat ? ($locat.origin || ($locat.protocol + '//' + $locat.host)) : ''
}

function getBaseURL () {
var pathname = $locat.pathname
var lastIndex = baseExports.lastIndexOf(pathname, '/') + 1
return getLocatOrigin() + (lastIndex === pathname.length ? pathname : pathname.substring(0, lastIndex))
if ($locat) {
var pathname = $locat.pathname
var lastIndex = baseExports.lastIndexOf(pathname, '/') + 1
return getLocatOrigin() + (lastIndex === pathname.length ? pathname : pathname.substring(0, lastIndex))
}
return ''
}

function parseUrl (url) {
Expand Down
Loading

0 comments on commit d724d65

Please sign in to comment.