-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoPC.js
39 lines (39 loc) · 1012 Bytes
/
toPC.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable no-useless-escape */
// 判断是否是移动端,如果非移动端则跳转到pc页面
window.OS = (function() {
let a = navigator.userAgent
const b = /(?:Android)/.test(a)
const d = /(?:Firefox)/.test(a)
const e = /(?:Mobile)/.test(a)
const f = b && e
const g = b && !f
const c = /(?:iPad.*OS)/.test(a)
const h = !c && /(?:iPhone\sOS)/.test(a)
const k = c || g || /(?:PlayBook)/.test(a) || (d && /(?:Tablet)/.test(a))
a =
!k &&
(b ||
h ||
/(?:(webOS|hpwOS)[\s\/]|BlackBerry.*Version\/|BB10.*Version\/|CriOS\/)/.test(
a
) ||
(d && e))
return {
android: b,
androidPad: g,
androidPhone: f,
ipad: c,
iphone: h,
tablet: k,
phone: a
}
})()
if (!window.OS.phone && !window.OS.ipad) {
if (process.env.NODE_ENV === 'production') {
const url = `${location.origin}${location.pathname.replace(
'/blogNuxtM',
'/blogNuxt'
)}${location.search}${location.hash}`
location.href = url
}
}