detector icon indicating copy to clipboard operation
detector copied to clipboard

如何识别设备类型,Phone, Tablet(Pad) 和 Desktop ?

Open hotoo opened this issue 11 years ago • 7 comments

  • 按照 UA 识别『不准确』
  • 按照分辨率区分『不准确』
  • 按照物理尺寸『无法获得 DPI,可以结合 CSS 但不准确』
  • 按照有无 3G通信模块『无法获得』

参考

hotoo avatar Nov 21 '13 13:11 hotoo

可以增加苹果系列的区分,3、4、5、6可以通过屏幕高度window.screen.height辅助window.devicePixelRatio来判断。比如:

                var iosVersioin;
                if (detector.device.name == "iphone") {
                    var height = screen.height;
                    if (height == 480) {
                        iosVersioin = "4、4s"
                    } else {
                        if (height == 568) {
                            iosVersioin = "5、5s、5c"
                        } else {
                            if (height == 667) {
                                if(window.devicePixelRatio == 3){
                                    iosVersioin = '6 plus';
                                }else{
                                    iosVersioin = "6"
                                }

                            } else {
                                if (height == 736) {
                                    iosVersioin = "6 plus"
                                } else {
                                    iosVersioin = "unkown"
                                }
                            }
                        }
                    }
                }

fredshare avatar Dec 31 '14 03:12 fredshare

希望增加iPhone 4,5,6的检测

airyland avatar Apr 22 '15 03:04 airyland

什么用途?

hotoo avatar Apr 22 '15 03:04 hotoo

记录,用户反馈问题时可以知道是哪个型号的问题。日常error也可以快速找测试机来检查。

airyland avatar Apr 22 '15 04:04 airyland

一般跟硬件关系不大吧,主要看操作系统、浏览器及渲染引擎的软件。

hotoo avatar Apr 22 '15 05:04 hotoo

不是大家都需要这个,那我们就自己实现一下就好了。

airyland avatar Apr 22 '15 07:04 airyland

嗯。还没想清楚,detector 暂时还没有加入这个功能的计划。

hotoo avatar Apr 22 '15 07:04 hotoo