определение браузера и ос пользователя
This commit is contained in:
parent
611b0282d3
commit
2a594d958b
@ -6,18 +6,33 @@ import device from "current-device";
|
|||||||
import type { AxiosError } from "axios";
|
import type { AxiosError } from "axios";
|
||||||
import { replaceSpacesToEmptyLines } from "../components/ViewPublicationPage/tools/replaceSpacesToEmptyLines";
|
import { replaceSpacesToEmptyLines } from "../components/ViewPublicationPage/tools/replaceSpacesToEmptyLines";
|
||||||
import { QuizSettings } from "@model/settingsData";
|
import { QuizSettings } from "@model/settingsData";
|
||||||
|
import * as Bowser from "bowser";
|
||||||
let SESSIONS = "";
|
let SESSIONS = "";
|
||||||
|
|
||||||
const domain = location.hostname === "hbpn.link" ? "" : "https://s.hbpn.link";
|
const domain = location.hostname === "hbpn.link" ? "" : "https://s.hbpn.link";
|
||||||
|
|
||||||
const md = new MobileDetect(window.navigator.userAgent);
|
const md = new MobileDetect(window.navigator.userAgent);
|
||||||
|
|
||||||
const userAgent = navigator.userAgent
|
const userAgent = navigator.userAgent
|
||||||
let OSDevice = md.os()
|
//операционная система
|
||||||
if (OSDevice === null) {OSDevice = userAgent}
|
let OSDevice:string | undefined
|
||||||
|
if (userAgent.toLowerCase().includes("linux")) {OSDevice = "Linux"}
|
||||||
|
if (userAgent.toLowerCase().includes("windows")) {OSDevice = "Windows"}
|
||||||
|
if (/iPad|iPhone|iPod/.test(userAgent)){OSDevice = "IOS"}
|
||||||
|
if (userAgent.toLowerCase().includes("macintosh")) {OSDevice = "Mac OS"}
|
||||||
|
if (OSDevice === undefined) {OSDevice = userAgent}
|
||||||
|
|
||||||
|
//браузер
|
||||||
|
let browserUser:string
|
||||||
|
if(Bowser.name === "Chrome") {
|
||||||
|
browserUser = "Chrome"
|
||||||
|
} else if(Bowser.name === "Firefox") {
|
||||||
|
browserUser = "Firefox"
|
||||||
|
}else if(Bowser.name === "Safari") {
|
||||||
|
browserUser = "Safari"
|
||||||
|
}else{browserUser = userAgent}
|
||||||
|
|
||||||
const DeviceType = device.type
|
const DeviceType = device.type
|
||||||
|
|
||||||
let Device = md.mobile()
|
let Device = md.mobile()
|
||||||
if (Device === null) {Device = userAgent}
|
if (Device === null) {Device = userAgent}
|
||||||
|
|
||||||
@ -30,7 +45,7 @@ export const publicationMakeRequest = ({ url, body }: any) => {
|
|||||||
"DeviceType" : DeviceType,
|
"DeviceType" : DeviceType,
|
||||||
"Device" : Device,
|
"Device" : Device,
|
||||||
"OS": OSDevice,
|
"OS": OSDevice,
|
||||||
"Browser" : userAgent
|
"Browser" : browserUser
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|||||||
@ -85,6 +85,7 @@
|
|||||||
"zustand": "^4.3.8"
|
"zustand": "^4.3.8"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"bowser": "1.9.4",
|
||||||
"country-flag-emoji-polyfill": "^0.1.8",
|
"country-flag-emoji-polyfill": "^0.1.8",
|
||||||
"current-device": "^0.10.2",
|
"current-device": "^0.10.2",
|
||||||
"hex-rgb": "^5.0.0",
|
"hex-rgb": "^5.0.0",
|
||||||
|
|||||||
@ -1337,6 +1337,11 @@ bluebird@^3.7.2:
|
|||||||
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
|
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
|
||||||
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
|
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
|
||||||
|
|
||||||
|
bowser@1.9.4:
|
||||||
|
version "1.9.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/bowser/-/bowser-1.9.4.tgz#890c58a2813a9d3243704334fa81b96a5c150c9a"
|
||||||
|
integrity sha512-9IdMmj2KjigRq6oWhmwv1W36pDuA4STQZ8q6YO9um+x07xgYNCD3Oou+WP/3L1HNz7iqythGet3/p4wvc8AAwQ==
|
||||||
|
|
||||||
brace-expansion@^1.1.7:
|
brace-expansion@^1.1.7:
|
||||||
version "1.1.11"
|
version "1.1.11"
|
||||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user