优化移动端适配和路由处理逻辑
This commit is contained in:
@ -5,8 +5,11 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
||||
// 在客户端处理路由
|
||||
// 是否是移动端设备
|
||||
const isMobile = /(Android|webOS|iPhone|iPod|tablet|BlackBerry|Mobile)/i.test(navigator.userAgent)
|
||||
// 是否是手机端路由
|
||||
const isRouterMobile = /^\/m\//.test(to.fullPath)
|
||||
// 是否是手机端路由开头
|
||||
const isRouterMobile = to.path.startsWith('/m')
|
||||
|
||||
console.log(isMobile, isRouterMobile);
|
||||
|
||||
// 移动端并且 不是/m开头路由
|
||||
if (isMobile && !isRouterMobile) {
|
||||
return navigateTo(`/m`)
|
||||
|
||||
Reference in New Issue
Block a user