From d2cfb6f12573eab3c203c35376ae8d68347279d3 Mon Sep 17 00:00:00 2001 From: JayChou Date: Mon, 19 May 2025 09:16:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=BF=E9=97=AE=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=BE=AA=E7=8E=AF=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 8710397..b219fd7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,11 +52,15 @@ const useThemeStore = themeStore() useThemeStore.initTheme() const ua = navigator.userAgent.toLowerCase() const isMobile = /iphone|android|ipad|mobile/.test(ua) -if (isMobile) { - console.log('手机端') + +const currentHost = location.host +const mobileHost = new URL(import.meta.env.VITE_APP_MOBILE_URL).host +const pcHost = new URL(import.meta.env.VITE_APP_PC_URL).host + +if (isMobile && currentHost !== mobileHost) { + console.log('手机端,跳转到移动站') location.href = import.meta.env.VITE_APP_MOBILE_URL -} else if (!isMobile) { - console.log('电脑端') +} else if (!isMobile && currentHost !== pcHost) { + console.log('电脑端,跳转到 PC 站') location.href = import.meta.env.VITE_APP_PC_URL - }