mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
[fix] TypeError: navigator.userAgentData.mobile is undefined
This commit is contained in:
27
lib/utils.js
27
lib/utils.js
@@ -124,3 +124,30 @@ export const getListByPage = function (list, pageIndex, pageSize) {
|
||||
pageIndex * pageSize
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否移动设备
|
||||
*/
|
||||
export const isMobile = () => {
|
||||
let isMobile = false
|
||||
if (!isBrowser()) {
|
||||
return isMobile
|
||||
}
|
||||
// if (!isMobile && navigator.userAgentData.mobile) {
|
||||
// isMobile = true
|
||||
// }
|
||||
|
||||
if (!isMobile && (/Mobi|Android|iPhone/i.test(navigator.userAgent))) {
|
||||
isMobile = true
|
||||
}
|
||||
|
||||
if (/Android|iPhone|iPad|iPod/i.test(navigator.platform)) {
|
||||
isMobile = true
|
||||
}
|
||||
|
||||
if (typeof window.orientation !== 'undefined') {
|
||||
isMobile = true
|
||||
}
|
||||
|
||||
return isMobile
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user