wepy/packages/wepy-web/src/helper/device.js
wepy/packages/wepy-web/src/helper/device.js
https://github.com/Tencent/wepy/blob/bd0003dca2bfb9581134e1b05d4aa1d80fc53858/packages/wepy-web/src/helper/device.js
/**
* Tencent is pleased to support the open source community by making WePY available.
* Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/ const MOBILE_DEVICE = ['android', 'iphone', 'symbianos', 'windows phone', 'ipad', 'ipod']; export function system () {
let ua = window.navigator.userAgent.toLowerCase(); for (let i = 0; i < MOBILE_DEVICE.length; i++) {
if (ua.indexOf(MOBILE_DEVICE[i]) !== -1) {
switch (MOBILE_DEVICE[i]) {
case 'iphone':
return 'mobile_iPhone';
case 'symbianos':
return 'mobile_SymbianOS';
case 'windows phone':
return 'mobile_WindowsPhone';
case 'iPad':
return 'pad_iPad';
case 'iPod':
return 'pad_iPod';
case 'Android':
if (ua.indexOf('Mobile') !== -1) {
return 'mobile_Android';
} else {
return 'pad_Android';
} }
}
} let sys; if (ua.indexOf('nt 5.1') > -1) {
sys = 'Windows xp';
} else if (ua.indexOf('nt 6.1') > -1) {
sys = 'Windows 7';
} else if (ua.indexOf('nt 6.3') > -1) {
sys = 'Windows 8';
} else if (ua.indexOf('nt 10.0') > -1) {
sys = 'Windows 10';
} else if (ua.indexOf('nt 6.0') > -1) {
sys = 'Windows Vista';
} else if (ua.indexOf('nt 5.2') > -1) {
sys = 'Windows 2003';
} else if (ua.indexOf('nt 5.0') > -1) {
sys = 'Windows 2000';
} else if ((ua.indexOf('windows') !== -1 || ua.indexOf('win32') !== -1)) {
sys = 'Windows';
} else if ((ua.indexOf('macintosh') !== -1 || ua.indexOf('mac os x') !== -1)) {
sys = 'Macintosh';
} else if ((ua.indexOf('adobeair') !== -1)) {
sys = 'Adobeair';
} else {
sys = 'Unknow';
} return sys;
}; export function mobile () {
let ua = window.navigator.userAgent.toLowerCase();
return MOBILE_DEVICE.some(v => ua.indexOf(v) !== -1);
}; export function browser () { };
wepy/packages/wepy-web/src/helper/device.js的更多相关文章
- [转] Creating a Simple RESTful Web App with Node.js, Express, and MongoDB
You can find/fork the sample project on GitHub Hey! This and all my other tutorials will soon be mov ...
- Device.js – 快速检测平台、操作系统和方向信息
在 Web 项目中,有时候我们需要根据程序运行的环境采取特定操作.Device.js 是一个很小的 JavaScript 库,它简化了编写和平台,操作系统或浏览器相关的条件 CSS 或 JavaScr ...
- Device.js——检测设备平台、操作系统的Javascript 库
http://segmentfault.com/a/1190000000373735 Device.js 是一个可以让你检测设备的平台,操作系统和方向 JavaScript 库,它会自动在 <h ...
- 使用device.js检测设备并实现不同设备展示不同网页
现在很多时候会用@media来控制页面在不同分辨率的设备商展示不同效果,但是有些时候想在直接在PC上展示一个做好的页面,在mobile展示另一个页面.这个时候可以借助device.js来检测设备,然后 ...
- 通过Web Api 和 Angular.js 构建单页面的web 程序
通过Web Api 和 Angular.js 构建单页面的web 程序 在传统的web 应用程序中,浏览器端通过向服务器端发送请求,然后服务器端根据这个请求发送HTML到浏览器,这个响应将会影响整个的 ...
- 检测设备平台,操作系统,方向 Javascript 库:Device.js
Device.js 是一个可以让你检测设备的平台,操作系统和方向 JavaScript 库,它会自动在 <html> 标签添加一些设备平台,操作系统,方向相关的 CSS class,这样就 ...
- WEB前段(HTML+JS),后端(MYSQL+PHP)开发基础
一.HTML HTML:超文本标记语言,可以加载JS/CSS/图片/链接等非文字的内容 一切的网页开发技术都需要建立在HTML的基础之上 HTML的结构和语法 HTML元素 注释: <!-- ...
- App.js – 用于移动 Web App 开发的 JS 界面库
App.js 是一个轻量级的 JavaScript UI 库,用于创建像本地应用程序的移动 Web 应用而不牺牲性能和体验.它是跨平台的,特定的UI设计,配置类似原生的过渡效果.App.js 的目的是 ...
- Web视频播放之video.js
h5这么火是有它的理由的,支持原生视频播放,但是目前兼容性还不是很好,因此使用js框架支持网站视频播放是比较不错的选择. 下载video.js,我们可以通过官网去下,但是官网在国外,我尝试了几次均下载 ...
随机推荐
- CSU-ACM2018寒假集训选拔-入门题
[题目链接]:http://vj.bit-studio.cn/contest/205664#overview A: [给你一个长度为n的序列,尾部插入再反转,求n次后最终序列][规律/思维] [分析] ...
- Network | 802.1x
IEEE 802.1X是IEEE制定关于用户接入网络的认证标准(注意:此处X是大写),全称是“基于端口的网络接入控制”,属于IEEE 802.1网络协议组的一部分.于2001年标准化,之后为了配合无线 ...
- Network | HTTP protocol
版本 HTTP/1.0这是第一个在通讯中指定版本号的HTTP协议版本,至今仍被广泛采用,特别是在代理服务器中. HTTP/1.1当前版本.持久连接被默认采用,并能很好地配合代理服务器工作.还支持以管道 ...
- luogu P2043 质因子分解
题目描述 对N!进行质因子分解. 输入输出格式 输入格式: 输入数据仅有一行包含一个正整数N,N<=10000. 输出格式: 输出数据包含若干行,每行两个正整数p,a,中间用一个空格隔开.表示N ...
- 从int 3探索Windows应用程序调试原理
http://www.cnblogs.com/xuanyuan/p/3998408.html
- ios内存管理笔记(二)
1)实现部分: 复制代码 @synthesize window=_window; @synthesize viewController=_viewController; 通常看到的都没有包含=部分,@ ...
- 第十八章 Python批量管理主机(paramiko、fabric与pexpect)
这个人的文章不错:http://lizhenliang.blog.51cto.com/all/7876557 转载:http://lizhenliang.blog.51cto.com/7876557/ ...
- python+tesseract验证码识别的一点小心得
由于公司需要,最近开始学习验证码的识别 我选用的是tesseract-ocr进行识别,据说以前是惠普公司开发的排名前三的,现在开源了.到目前为止已经出到3.0.2了 当然了,前期我们还是需要对验证码进 ...
- SQL must not be null(低级错误)
提醒一下: 数据库数据源配置出错,也会发生这种低级错误的.
- js aop 拦载实现
var run = function(){ //is run } var aopBefore = function(){ //aopBefore } var tmpFn=run; run = func ...