fix(router): 修复小程序登录逻辑并添加环境判断

在小程序环境中正确判断是否使用微信登录逻辑,避免在非小程序环境误用该逻辑
This commit is contained in:
feige996
2025-09-04 15:17:13 +08:00
parent c31090e389
commit 5c81761371
2 changed files with 5 additions and 4 deletions

View File

@@ -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

View File

@@ -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