mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-16 09:00:47 +08:00
Revert "fix: correct SSR mobile detection"
This reverts commit 113cec1705.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { ref, computed, onUnmounted } from 'vue'
|
import { ref, computed, onUnmounted } from 'vue'
|
||||||
import { useRequestHeaders, useRequestEvent } from 'nuxt/app'
|
import { useRequestHeaders } from 'nuxt/app'
|
||||||
|
|
||||||
export const useIsMobile = () => {
|
export const useIsMobile = () => {
|
||||||
const width = ref(0)
|
const width = ref(0)
|
||||||
@@ -7,15 +7,12 @@ export const useIsMobile = () => {
|
|||||||
|
|
||||||
const isMobileUserAgent = () => {
|
const isMobileUserAgent = () => {
|
||||||
let userAgent = ''
|
let userAgent = ''
|
||||||
let mobileHint = ''
|
|
||||||
|
|
||||||
if (typeof navigator !== 'undefined') {
|
if (typeof navigator !== 'undefined') {
|
||||||
userAgent = navigator.userAgent.toLowerCase()
|
userAgent = navigator.userAgent.toLowerCase()
|
||||||
} else {
|
} else {
|
||||||
const event = useRequestEvent()
|
const headers = useRequestHeaders(['user-agent'])
|
||||||
const headers = event?.node?.req?.headers || useRequestHeaders()
|
|
||||||
userAgent = (headers['user-agent'] || '').toLowerCase()
|
userAgent = (headers['user-agent'] || '').toLowerCase()
|
||||||
mobileHint = (headers['sec-ch-ua-mobile'] || '').toLowerCase()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mobileKeywords = [
|
const mobileKeywords = [
|
||||||
@@ -23,7 +20,7 @@ export const useIsMobile = () => {
|
|||||||
'mobile', 'tablet', 'opera mini', 'iemobile'
|
'mobile', 'tablet', 'opera mini', 'iemobile'
|
||||||
]
|
]
|
||||||
|
|
||||||
return mobileHint.includes('?1') || mobileKeywords.some(keyword => userAgent.includes(keyword))
|
return mobileKeywords.some(keyword => userAgent.includes(keyword))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
|
|||||||
Reference in New Issue
Block a user