From e69d96252111a32a26ffb628b0a02e9b1117f013 Mon Sep 17 00:00:00 2001 From: v6ole Date: Fri, 26 Jun 2026 16:03:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=8B=E5=8A=A8=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=B8=83=E5=B1=80=20=E2=80=94=20=E4=BB=85=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E5=8A=A0=E8=BD=BD=E8=87=AA=E5=8A=A8=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 检测 _from.name 区分「首次加载」和「应用内导航」: - 首次: 手机→/m, 桌面→/ - 手动点击切换按钮: 完全尊重用户选择, 不拦截 Co-Authored-By: Claude --- frontend/src/router/index.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 6cd06b8..e753ebc 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -75,16 +75,19 @@ router.beforeEach((to, _from, next) => { return } - // Auto-redirect: mobile devices hitting root → send to mobile home - // Allow manual override via ?view=desktop or ?view=mobile + // Auto-redirect on FIRST entry only (no previous route = fresh page load) + // Don't interfere with manual navigation (user clicked switch button) const viewOverride = to.query.view as string - if (!viewOverride) { + if (!viewOverride && !_from.name) { const onMobile = isMobile() - // Only redirect bare root — explicit paths are honored - if (onMobile && (to.path === '/' || to.path === '')) { + if (onMobile && to.path === '/') { next('/m') return } + if (!onMobile && to.path.startsWith('/m')) { + next('/') + return + } } next()