730 Star 5.9K Fork 4.6K

若依 / RuoYi-App

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
permission.js 870 Bytes
一键复制 编辑 原始数据 按行查看 历史
若依 提交于 2023-07-11 17:09 . 新增是否开启用户注册功能
import { getToken } from '@/utils/auth'
// 登录页面
const loginPage = "/pages/login"
// 页面白名单
const whiteList = [
'/pages/login', '/pages/register', '/pages/common/webview/index'
]
// 检查地址白名单
function checkWhite(url) {
const path = url.split('?')[0]
return whiteList.indexOf(path) !== -1
}
// 页面跳转验证拦截器
let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"]
list.forEach(item => {
uni.addInterceptor(item, {
invoke(to) {
if (getToken()) {
if (to.url === loginPage) {
uni.reLaunch({ url: "/" })
}
return true
} else {
if (checkWhite(to.url)) {
return true
}
uni.reLaunch({ url: loginPage })
return false
}
},
fail(err) {
console.log(err)
}
})
})
Java
1
https://gitee.com/y_project/RuoYi-App.git
git@gitee.com:y_project/RuoYi-App.git
y_project
RuoYi-App
RuoYi-App
master

搜索帮助