From f312cf7d1c7b7b00d9eb5209a9d2979c28ebe3f2 Mon Sep 17 00:00:00 2001 From: tim Date: Sun, 10 Aug 2025 17:41:20 +0800 Subject: [PATCH] Revert "fix: correct SSR mobile detection" This reverts commit 113cec1705622623c717683d1e83efa13648412d. --- frontend_nuxt/utils/screen.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend_nuxt/utils/screen.js b/frontend_nuxt/utils/screen.js index 455b0e257..f74afd03e 100644 --- a/frontend_nuxt/utils/screen.js +++ b/frontend_nuxt/utils/screen.js @@ -1,5 +1,5 @@ import { ref, computed, onUnmounted } from 'vue' -import { useRequestHeaders, useRequestEvent } from 'nuxt/app' +import { useRequestHeaders } from 'nuxt/app' export const useIsMobile = () => { const width = ref(0) @@ -7,15 +7,12 @@ export const useIsMobile = () => { const isMobileUserAgent = () => { let userAgent = '' - let mobileHint = '' if (typeof navigator !== 'undefined') { userAgent = navigator.userAgent.toLowerCase() } else { - const event = useRequestEvent() - const headers = event?.node?.req?.headers || useRequestHeaders() + const headers = useRequestHeaders(['user-agent']) userAgent = (headers['user-agent'] || '').toLowerCase() - mobileHint = (headers['sec-ch-ua-mobile'] || '').toLowerCase() } const mobileKeywords = [ @@ -23,7 +20,7 @@ export const useIsMobile = () => { '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') {