fix: 手动切换布局失效 — 仅首页自动适配
- 只对根路径 / 做手机→/m 跳转,不再拦截桌面访问 /m - 支持 ?view=desktop 或 ?view=mobile 强制覆盖自动检测 - 手动输入的具体路径完全不受影响 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -75,16 +75,16 @@ router.beforeEach((to, _from, next) => {
|
||||
return
|
||||
}
|
||||
|
||||
// Auto-redirect to mobile layout for mobile devices accessing desktop routes
|
||||
const onMobile = isMobile()
|
||||
if (onMobile && to.path === '/' && !to.path.startsWith('/m')) {
|
||||
next('/m')
|
||||
return
|
||||
}
|
||||
// Desktop user accidentally on mobile route → redirect to desktop
|
||||
if (!onMobile && to.path.startsWith('/m')) {
|
||||
next('/')
|
||||
return
|
||||
// Auto-redirect: mobile devices hitting root → send to mobile home
|
||||
// Allow manual override via ?view=desktop or ?view=mobile
|
||||
const viewOverride = to.query.view as string
|
||||
if (!viewOverride) {
|
||||
const onMobile = isMobile()
|
||||
// Only redirect bare root — explicit paths are honored
|
||||
if (onMobile && (to.path === '/' || to.path === '')) {
|
||||
next('/m')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
next()
|
||||
|
||||
Reference in New Issue
Block a user