Compare commits

...

2 Commits

  1. 20
      src/main.ts

@ -52,11 +52,15 @@ const useThemeStore = themeStore()
useThemeStore.initTheme() useThemeStore.initTheme()
const ua = navigator.userAgent.toLowerCase() const ua = navigator.userAgent.toLowerCase()
const isMobile = /iphone|android|ipad|mobile/.test(ua) const isMobile = /iphone|android|ipad|mobile/.test(ua)
if (isMobile) {
console.log('手机端') const currentHost = location.host
// location.href = import.meta.env.VITE_APP_MOBILE_URL const mobileHost = new URL(import.meta.env.VITE_APP_MOBILE_URL).host
} else if (!isMobile) { const pcHost = new URL(import.meta.env.VITE_APP_PC_URL).host
console.log('电脑端')
// location.href = import.meta.env.VITE_APP_PC_URL 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
}

Loading…
Cancel
Save