修改pc 移动端跳转切换

This commit is contained in:
浅念 2026-02-09 13:50:38 +08:00
parent 2198380c9f
commit 50684e42b9

View File

@ -5,24 +5,19 @@
<script setup> <script setup>
import { onMounted } from 'vue' import { onMounted } from 'vue'
// const MOBILE_URL = 'https://bsh.yw.m.hnzhwlkj.cn'
function isMobile() {
// 1:
const userAgent = navigator.userAgent || navigator.vendor || window.opera
const mobileRegex = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i
const isMobileByUA = mobileRegex.test(userAgent.toLowerCase())
// 2: onMounted(() => {
const isMobileByWidth = window.innerWidth <= 768 // 1. URL = =
if (window.location.search.includes('from_mobile=1')) {
return isMobileByUA || isMobileByWidth return // URL
} }
// // 2. +
onMounted(() => { const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
if (isMobile()) {
// if (isMobile) {
window.location.href = 'https://bsh.yw.m.hnzhwlkj.cn/' window.location.replace(`${MOBILE_URL}?from_pc=1`)
} }
}) })
</script> </script>