1 Star 0 Fork 310

SXLMY / yudao-ui-admin-uniapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
permission.js 825 Bytes
一键复制 编辑 原始数据 按行查看 历史
import { getAccessToken } from '@/utils/auth'
// 登录页面
const loginPage = "/pages/login"
// 页面白名单
const whiteList = [
'/pages/login', '/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 (getAccessToken()) {
if (to.path === loginPage) {
uni.reLaunch({ url: "/" })
}
return true
} else {
if (checkWhite(to.url)) {
return true
}
uni.reLaunch({ url: loginPage })
return false
}
},
fail(err) {
console.log(err)
}
})
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sxl_2_3209036917/yudao-ui-admin-uniapp.git
git@gitee.com:sxl_2_3209036917/yudao-ui-admin-uniapp.git
sxl_2_3209036917
yudao-ui-admin-uniapp
yudao-ui-admin-uniapp
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891