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,我们可以通过官网去下,但是官网在国外,我尝试了几次均下载 ...
随机推荐
- Codeforces 766E Mahmoud and a xor trip(树形DP)
题目链接 Mahmoud and a xor trip 树形DP.先考虑每个点到他本身的距离和,再算所有点两两距离和. 做的时候考虑二进制拆位即可. #include <bits/stdc++. ...
- Java---Static内存图详解
案例: 输出结果 内存图: 执行流程: java文件通过编译成class文件,class文件通过类加载器加载到方法区中,程序首先会加载核心类库,也就是你的程序想要运行所需要的一些最基本的类.接着程序会 ...
- Linux(二) 常用命令
Linux简介及Ubuntu安装 Linux,免费开源,多用户多任务系统.基于Linux有多个版本的衍生.RedHat.Ubuntu.Debianaa 安装VMware或VirtualBox虚拟机 ...
- c++ 幕客网
http://m.imooc.com/course/list.html?c=cplusplus http://coding.imooc.com/ http://www.imooc.com/act/al ...
- Linux下创建和删除用户
在Linux下创建用户和删除用户,必须在root用户下,如果你当前不是用根用户登录,你可以打开终端,输入"su root"命令,再输入根口令,就可以进入root用户模式下,如下所示 ...
- PHP amqp扩展安装
1.安装 rabbitmq-c下载地址:https://github.com/alanxz/rabbitmq-c> mkdir build > cd build> cmake -DO ...
- 聊聊、Zookeeper Linux 启动
Zookeeper 在 windows 下安装比较简单,属于无脑式安装,下载下来双击脚本就可以了.前面的文章中也有介绍,今天我来写写 Linux 下的安装,以及所碰到的坑. 首先,登陆 Linux 系 ...
- Mac. 文件夹赋予权限
1. click on your background to go to finder click on go and go to folder /usr right click on local a ...
- SQLite创建表并加入数据
- (void)viewDidLoad { [super viewDidLoad]; //创建表 [self creatTable]; //插入数据 [self insertTable]; } // ...
- java基础篇1之可变参数,增强for循环,自动装箱
1.java中可变参数应用 例如 add(int x,int... args) 1)只能放在参数列表的最后面 2)...位于变量类型和变量名之间,前后有无空格都可以 3)调用可变参数的方法时,编译器为 ...