url认证

This commit is contained in:
“wanyongkang”
2021-06-02 18:46:00 +08:00
parent 8ff14b5dd6
commit 297eb2f5d4
3 changed files with 27 additions and 2 deletions

View File

@@ -290,10 +290,30 @@ let router = new Router({
// 使用 router.beforeEach 注册一个全局前置守卫,判断用户是否登陆
router.beforeEach((to, from, next) => {
let userInfo = local.getUserByCache()
if(userInfo != null){
$.ajax({
type: 'GET',
url: 'http://juip.wyk/api/Allow/urlCheck',
dataType: "json",
contentType: "application/json",
data: {'url':to.fullPath,'id':userInfo.Manager.ID},
success: function (res) {
if(res.Code == -10000){
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
})
}
}
});
}
if (to.path === '/login' || to.path === '/' || to.path === '/r') {
next()
} else {
let userInfo = local.getUserByCache()// localStorage.getItem('etorcurrentuser');
// localStorage.getItem('etorcurrentuser');
if (!userInfo || userInfo === '') {
router.replace({
path: '/login',