From 5c81761371ddfd78f6b8d4d2b6228824782e7eb4 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Thu, 4 Sep 2025 15:17:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(router):=20=E4=BF=AE=E5=A4=8D=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=8E=AF=E5=A2=83=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在小程序环境中正确判断是否使用微信登录逻辑,避免在非小程序环境误用该逻辑 --- src/router/config.ts | 2 +- src/router/interceptor.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/router/config.ts b/src/router/config.ts index f6afeea..7f4da64 100644 --- a/src/router/config.ts +++ b/src/router/config.ts @@ -24,4 +24,4 @@ export const EXCLUDE_LOGIN_PATH_LIST = [ // 在微信小程序里面是否使用小程序默认的登录,默认为true // 如果为 false 则复用 h5 的登录逻辑 -export const IS_USE_WX_LOGIN_IN_MP = true // 暂时还没用到,没想好怎么整合 +export const IS_USE_WX_LOGIN_IN_MP = true diff --git a/src/router/interceptor.ts b/src/router/interceptor.ts index 1daf783..94b6366 100644 --- a/src/router/interceptor.ts +++ b/src/router/interceptor.ts @@ -1,3 +1,4 @@ +import { isMp } from '@uni-helper/uni-env' /** * by 菲鸽 on 2025-08-19 * 路由拦截,通常也是登录拦截 @@ -46,8 +47,8 @@ export const navigateToInterceptor = { tabbarStore.setAutoCurIdx(path) // 小程序里面使用平台自带的登录,则不走下面的逻辑 - if (IS_USE_WX_LOGIN_IN_MP) { - return true + if (isMp && IS_USE_WX_LOGIN_IN_MP) { + return true // 明确表示允许路由继续执行 } const tokenStore = useTokenStore() @@ -67,7 +68,7 @@ export const navigateToInterceptor = { else { uni.navigateTo({ url }) } - return true // 明确表示阻止原路由继续执行 + return true } } let fullPath = path