zoukankan      html  css  js  c++  java
  • 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 () {
    
    };





  • 相关阅读:
    痞子衡嵌入式:MCUXpresso IDE下SDK工程在Build配置上与IAR,MDK差异
    13万字详细分析JDK中Stream的实现原理
    扫码登录是这样登录的
    [Vue深入组件-边界情况处理] 控制更新
    [Vue深入组件-边界情况处理] 模板定义的替代品
    [Vue深入组件]:递归组件和组件的循环引用
    #antdv 清除指定字段验证 #antdv表单验证指定清除
    [Vue深入组件-边界情况处理] 程序化的事件监听器
    [Vue深入组件-边界情况处理] 访问元素 & 组件
    [Vue深入组件]:Slot插槽
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9614167.html
Copyright © 2011-2022 走看看