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 546D Soldier and Number Game(数论)
类似筛素数的方法……求出前缀和.然后直接O(1)回答即可. #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) ...
- UVA 10827 Maximum sum on a torus 最大矩阵和
题目链接:UVA - 10827 题意描述:给出一个n*n矩阵,把第一行和最后一行粘一起,把第一列和最后一列粘一起,形成一个环面,求出这个环面中最大的矩阵和. 算法分析:首先复制n*n这个矩阵,形成由 ...
- Qt小结
(1)#include 报错fatal error: QHostInfo:No such file or directory, 解决办法 在.pro文件中添加 QT += core gui netwo ...
- Android Spinner In Toolbar
As the title of the post suggest in this tutorial we will see how to have spinner widget inside the ...
- 2016.6.20 在Eclipse配置Tomcat服务器的步骤
好久没接触,又忘记了如何在eclipse中配置tomcat. (1)打开eclispe的preference (2)找到Server下方的Runtime Environment,单击右方的Add按钮. ...
- [Golang] 从零開始写Socket Server(2): 自己定义通讯协议
在上一章我们做出来一个最基础的demo后,已经能够初步实现Server和Client之间的信息交流了~ 这一章我会介绍一下怎么在Server和Client之间实现一个简单的通讯协议.从而增强整个信息交 ...
- Android开发之布局文件里实现OnClick事件关联处理方法
一般监听OnClickListener事件,我们都是通过Button button = (Button)findViewById(....); button.setOClickLisener....这 ...
- html小知识,怎么实现一个td占据2行
<table border="1" width="100%"> <tr> <td rowspan="2"> ...
- UNP学习笔记(第十七章 ioctl操作)
ioctl相当于一个杂物箱,它一直作为那些不适合归入其他精细定义类别的特性的系统接口. 本章笔记先放着,到时候有需要再看 ioctl函数 #include <unistd.h> int i ...
- openssl之BIO系列之22---Cipher类型的BIO
Cipher类型BIO ---依据openssl doc\crypto\bio_f_cipher.pod翻译和自己的理解写成 (作者:DragonKing, Mail: wzhah@263.net , ...