From 7aa844bffdc2ec23f9099e2df23be185bd1abf8f Mon Sep 17 00:00:00 2001 From: JayChou Date: Wed, 28 May 2025 19:55:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BF=E9=97=AE=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 5 ++++- .env.production | 4 +++- src/main.ts | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.env.development b/.env.development index 564630e..fb241aa 100644 --- a/.env.development +++ b/.env.development @@ -3,4 +3,7 @@ NODE_ENV = 'development' VITE_APP_TITLE = '教学一体化平台' VITE_APP_BASE_API = http://localhost:18085/jeecg-boot # VITE_APP_BASE_API = 'http://127.0.0.1:8080' -VITE_APP_BASE_API_JEECG = '/student' \ No newline at end of file +VITE_APP_BASE_API_JEECG = '/student' +VITE_APP_PC_URL = http://115.190.99.211:803/#/home + +VITE_APP_MOBILE_URL = http://115.190.99.211:8030/#/home diff --git a/.env.production b/.env.production index 05f4c00..3b8f259 100644 --- a/.env.production +++ b/.env.production @@ -2,4 +2,6 @@ NODE_ENV = 'development' VITE_APP_TITLE = '河南青少年阅读大赛' VITE_APP_BASE_API = http://115.190.99.211:18186/jeecg-boot -# VITE_APP_BASE_API = 'http://127.0.0.1:8080' \ No newline at end of file +# VITE_APP_BASE_API = 'http://127.0.0.1:8080' +VITE_APP_PC_URL = http://115.190.99.211:814/#/home +VITE_APP_MOBILE_URL = http://115.190.99.211:8014 \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 95fb7d0..3add9b8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,3 +42,17 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue' for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } +const ua = navigator.userAgent.toLowerCase() +const isMobile = /iphone|android|ipad|mobile/.test(ua) + +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 && currentHost !== pcHost) { + console.log('电脑端,跳转到 PC 站') + location.href = import.meta.env.VITE_APP_PC_URL +}