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,我们可以通过官网去下,但是官网在国外,我尝试了几次均下载 ...
随机推荐
- 使用Git Gui从Bonobo服务器中克隆Repository(仓库)
刚开始在使用Git Gui从Bonobo服务器中克隆Repository(仓库)中遇到一些问题,如下图所示: 后来百度,有人遇到类似的问题,得到解决思路,请大家参考这里.大意说出现这个问题是因为要克隆 ...
- ios开发 - 获取从http上下载文件的大小
- (void)connectionNSURLConnection *)connection didReceiveResponseNSURLResponse *)response{ NSHTTPURL ...
- win7安装mysql解压缩版
http://blog.csdn.net/u013067166/article/details/49951577
- kali渗透测试基础
一侦查 研究如何收集有关目标的情报,比如开发那些端口用来通信,托管在哪里,提供给客户的服务类型等. 交付内容应该包括需要攻击的所有目标资产清单,与那些资产关联的应用,使用的服务以及可能的资产所有者. ...
- python traceback学习(转)
1. Python中的异常栈跟踪 之前在做Java的时候,异常对象默认就包含stacktrace相关的信息,通过异常对象的相关方法printStackTrace()和getStackTrace()等方 ...
- z pre-pass 相关问题的讨论
z pre-pass 是指在渲染流程中,第一个pass先画一张深度buffer出来,得到需要绘制的最前面这层深度,用这个在接下来的pass中做深度剔出,这样在第二个pass中会省略很多绘制. 这项技术 ...
- spring batch的使用和定时器Quart的使用
Spring Batch是一个基于Spring的企业级批处理框架,它通过配合定时器Quartz来轻易实现大批量的数据读取或插入,并且全程自动化,无需人员管理. 在使用spring batch之前,得对 ...
- oracle行锁select for update
oracle行锁select for update 学习了:https://blog.csdn.net/zdwzzu2006/article/details/50490157 学习了:https:// ...
- linux中expr用法
名称:expr ### 字串长度 shell>> expr length "this is a test" 14 ### 数字商数 shell>> ...
- phonegap(cordova) 自己定义插件代码篇(三)----支付宝支付工具整合
建议读者,先阅读官方文档,知晓其支付流程之后再来使用此代码,比方客户须要做什么,服务端须要做什么(非常重要!非常重要! 非常重要!),由于这几个篇幅都是纯代码篇,由于阅读前面的入门篇之后看这些应该毫无 ...