fix(router): 修复小程序登录逻辑并添加环境判断
在小程序环境中正确判断是否使用微信登录逻辑,避免在非小程序环境误用该逻辑
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user