feat: 大量升级,v2.0.0
This commit is contained in:
@@ -21,7 +21,7 @@ const isDev = import.meta.env.DEV
|
||||
const navigateToInterceptor = {
|
||||
// 注意,这里的url是 '/' 开头的,如 '/pages/index/index',跟 'pages.json' 里面的 path 不同
|
||||
invoke({ url }: { url: string }) {
|
||||
console.log(url) // /pages/route-interceptor/index?name=feige&age=30
|
||||
// console.log(url) // /pages/route-interceptor/index?name=feige&age=30
|
||||
const path = url.split('?')[0]
|
||||
let needLoginPages: string[] = []
|
||||
// 为了防止开发时出现BUG,这里每次都获取一下。生产环境可以移到函数外,性能更好
|
||||
@@ -30,18 +30,17 @@ const navigateToInterceptor = {
|
||||
} else {
|
||||
needLoginPages = _needLoginPages
|
||||
}
|
||||
console.log(needLoginPages.includes(path))
|
||||
|
||||
if (needLoginPages.includes(path)) {
|
||||
const isLogin = isLogined()
|
||||
if (isLogin) {
|
||||
return true
|
||||
}
|
||||
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}`
|
||||
uni.navigateTo({ url: redirectRoute })
|
||||
return false
|
||||
const isNeedLogin = needLoginPages.includes(path)
|
||||
if (!isNeedLogin) {
|
||||
return true
|
||||
}
|
||||
return true
|
||||
const hasLogin = isLogined()
|
||||
if (hasLogin) {
|
||||
return true
|
||||
}
|
||||
const redirectRoute = `${loginRoute}?redirect=${encodeURIComponent(url)}`
|
||||
uni.navigateTo({ url: redirectRoute })
|
||||
return false
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user