|
@@ -78,7 +78,7 @@ export const navigateToInterceptor = {
|
|
|
}
|
|
}
|
|
|
const redirectUrl = `${LOGIN_PAGE}?redirect=${encodeURIComponent(fullPath)}`
|
|
const redirectUrl = `${LOGIN_PAGE}?redirect=${encodeURIComponent(fullPath)}`
|
|
|
|
|
|
|
|
- // #region 1/2 需要登录的情况(白名单策略) ---------------------------
|
|
|
|
|
|
|
+ // #region 1/2 默认需要登录的情况(白名单策略) ---------------------------
|
|
|
if (isNeedLoginMode) {
|
|
if (isNeedLoginMode) {
|
|
|
// 需要登录里面的 EXCLUDE_LOGIN_PATH_LIST 表示白名单,可以直接通过
|
|
// 需要登录里面的 EXCLUDE_LOGIN_PATH_LIST 表示白名单,可以直接通过
|
|
|
if (judgeIsExcludePath(path)) {
|
|
if (judgeIsExcludePath(path)) {
|
|
@@ -94,27 +94,18 @@ export const navigateToInterceptor = {
|
|
|
return false // 明确表示阻止原路由继续执行
|
|
return false // 明确表示阻止原路由继续执行
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // #endregion 1/2 需要登录的情况(白名单策略) ---------------------------
|
|
|
|
|
|
|
+ // #endregion 1/2 默认需要登录的情况(白名单策略) ---------------------------
|
|
|
|
|
|
|
|
- // #region 2/2 不需要登录的情况(黑名单策略) ---------------------------
|
|
|
|
|
|
|
+ // #region 2/2 默认不需要登录的情况(黑名单策略) ---------------------------
|
|
|
else {
|
|
else {
|
|
|
// 不需要登录里面的 EXCLUDE_LOGIN_PATH_LIST 表示黑名单,需要重定向到登录页
|
|
// 不需要登录里面的 EXCLUDE_LOGIN_PATH_LIST 表示黑名单,需要重定向到登录页
|
|
|
if (judgeIsExcludePath(path)) {
|
|
if (judgeIsExcludePath(path)) {
|
|
|
FG_LOG_ENABLE && console.log('2 isNeedLogin(黑名单策略) redirectUrl:', redirectUrl)
|
|
FG_LOG_ENABLE && console.log('2 isNeedLogin(黑名单策略) redirectUrl:', redirectUrl)
|
|
|
-
|
|
|
|
|
- // 如果当前路由是登录页,那就重定向走
|
|
|
|
|
- const { path, query } = parseUrlToObj(redirectUrl)
|
|
|
|
|
- if (path === LOGIN_PAGE) {
|
|
|
|
|
- console.log('path:', path)
|
|
|
|
|
- console.log('query:', query)
|
|
|
|
|
- uni.navigateTo({ url: query.redirect })
|
|
|
|
|
- return false // 明确表示阻止原路由继续执行
|
|
|
|
|
- }
|
|
|
|
|
uni.navigateTo({ url: redirectUrl })
|
|
uni.navigateTo({ url: redirectUrl })
|
|
|
return false // 修改为false,阻止原路由继续执行
|
|
return false // 修改为false,阻止原路由继续执行
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // #endregion 2/2 不需要登录的情况(黑名单策略) ---------------------------
|
|
|
|
|
|
|
+ // #endregion 2/2 默认不需要登录的情况(黑名单策略) ---------------------------
|
|
|
return true // 明确表示允许路由继续执行
|
|
return true // 明确表示允许路由继续执行
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|