标签: device-detection

如何检测 NestJs/NodeJs 中的浏览器详细信息

我正在尝试将设备检测器 npm 模块集成到我的应用程序中,以便检测浏览器详细信息。为此,我正在使用这个模块npm i device-detector-js

我已经将它集成到我的代码中,因为它是代码片段。

下面是我的代码:

应用程序控制器.ts

import { Controller, Get, Req } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

@Get()
getHello(@Req() req): string {
  console.log(req.headers);
  return this.appService.getHello();
  }
}
Run Code Online (Sandbox Code Playgroud)

应用程序服务.ts

import { Inject, Injectable } from '@nestjs/common';
import DeviceDetector = require("device-detector-js");

@Injectable()
export class AppService {
private readonly deviceDetector = new DeviceDetector();

getHello(): string {
const userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 …
Run Code Online (Sandbox Code Playgroud)

device-detection node.js nestjs

4
推荐指数
1
解决办法
7812
查看次数

如何使用ionic.Platform

我是使用ionic/AngularJS的新手,我想知道如何使用ionic.Platform打印当前设备.现在我有

var currentPlatform = ionic.Platform.platform();  
Run Code Online (Sandbox Code Playgroud)

在我的main.html ctrl中.有没有办法将它发送到html页面,或者我接近它是完全错误的?

device-detection ionic-framework ionic

3
推荐指数
1
解决办法
4360
查看次数

在服务器上预渲染 Angular 通用应用程序时检测设备类型

我正在使用ngx-device- detector库来检测设备类型(移动设备、平板电脑或台式机)。该库在客户端模式下完美工作,但当角度通用应用程序在服务器上预渲染时无法检测设备类型(在服务器上预渲染后,在客户端模式下完美工作)。

  1. 如果有人给我一个适用于这个库的解决方案,我很感激
  2. 最后,如果这个库没有任何解决方案,请给我另一个解决方案

谢谢。

device-detection angular-universal angular

3
推荐指数
1
解决办法
4603
查看次数

如何使用javascript检测触摸设备浏览器与桌面?

检测触摸设备(智能手机和平板电脑)与使用userAgent.match的桌面浏览器并返回布尔变量(例如'isipad')的代码是什么?

我需要主要针对Android和Apple设备进行测试.如果设备浏览器是Android或Apple,则返回isipad = false.否则,返回isipad = true.

到目前为止,我这样做了(对于iDevice浏览器检测):

if( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) ||navigator.userAgent.match(/iPad/i) )
{var isipad = true;}
else
{var isipad = false;}
Run Code Online (Sandbox Code Playgroud)

它似乎工作,但我希望能够添加Android浏览器,在这种情况下.

提前致谢.亚历克斯

javascript user-agent browser-detection device-detection

2
推荐指数
1
解决办法
1万
查看次数

检测显示分辨率

我需要人们使用PHP检测设备显示分辨率的帮助.

切换界面时我的代码出现问题我有以下代码:

 $_page="home";
 if(get('page'))
    $_page=strtolower(get('page'));
 // Check if larger than 800px screen will show this code.
 $_pagePath='Includes/desktop/'.$_page.'_left.php';
 // Check if the screen is smaller than 800px will display this code.
 $_pagePath='Includes/mobile/'.$_page.'_left.php';  
 if(file_exists($_pagePath))
            include $_pagePath;
 else
    echo 'File '.$_pagePath.' not found';
Run Code Online (Sandbox Code Playgroud)

请帮我完成这段代码.

php mobile device-detection

2
推荐指数
1
解决办法
1万
查看次数

如何检测移动设备

我正在使用 ionic 框架构建一个移动网站。我想用 AngularJS(或 ionic)检测移动设备(Android 和 iOS)。

\n\n

如果访问设备是Android \xe2\x86\x92 #/android\n如果访问设备是iOS \xe2\x86\x92 #/ios

\n\n

控制器.js

\n\n
function uaCtrl(\'$scope\', \'$location\', ($scope, $location) {\n$scope = function () {\n  var isMobile = {\n    Android: function() {\n      return navigator.userAgent.match(/Android/i);\n    },\n    iOS: function() {\n      return navigator.userAgent.match(/iPhone | iPad | iPod/i)\n    }\n  }\n\n  if(isMobile.Android()) {\n    $location.path(\'#/android\');\n  }else if(isMobile.iOS()) {\n    $location.path(\'#/ios\');\n  }else{\n    $location.path(\'#/ios\');\n  }\n\n};\n
Run Code Online (Sandbox Code Playgroud)\n\n

};

\n\n

应用程序.js

\n\n
.config(function($stateProvider, $urlRouterProvider) {\n  $urlRouterProvider.otherwise(\'/dash\');\n\n  $stateProvider\n\n  .state(\'home\', {\n      url: \'/dash\',\n      templateUrl: \'templates/dash.html\'\n    })\n\n  .state(\'android-home\', {\n    url: \'/android\',\n    templateUrl:\'templates/dash-android.html\'\n  })\n\n …
Run Code Online (Sandbox Code Playgroud)

android device-detection ios angularjs ionic-framework

0
推荐指数
1
解决办法
2万
查看次数