武田小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.1 KiB

var isBrowser = require('./isBrowser');
var isNode = require('./isNode');
exports = function(ua) {
if (!ua && isBrowser) {
ua = navigator.userAgent;
}
function detect(keyword) {
return ua.indexOf(keyword) > -1;
}
if (ua) {
ua = ua.toLowerCase();
if (detect('windows phone')) return 'windows phone';
if (detect('win')) return 'windows';
if (detect('android')) return 'android';
if (detect('ipad') || detect('iphone') || detect('ipod')) return 'ios';
if (detect('mac')) return 'os x';
if (detect('linux')) return 'linux';
} else if (isNode) {
var _process = process,
platform = _process.platform,
env = _process.env;
if (
platform === 'win32' ||
env.OSTYPE === 'cygwin' ||
env.OSTYPE === 'msys'
) {
return 'windows';
}
if (platform === 'darwin') {
return 'os x';
}
if (platform === 'linux') {
return 'linux';
}
}
return 'unknown';
};
module.exports = exports;