Browse Source

已解决目前所有登录问题

已解决目前所有登录问题
dangyunlong 5 days ago
parent
commit
09def29b79
1 changed files with 23 additions and 0 deletions
  1. 23 0
      src/permission.js

+ 23 - 0
src/permission.js

@@ -77,6 +77,29 @@ router.beforeEach(async (to, from, next) => {
                     window.location.href = backurl + '?backurl=' + backurl + '&admintoken=' + getToken()
                 }
             }
+            //出现这种情况,说明用户使用的是管理员登录
+            if(loginType == null){
+                const userInfo = await getInfo();
+                //此时不需要返回C端
+                if(userInfo.code == 400){
+                    console.log("用户没有访问权限,将跳转到无权限页面!")
+                    if (to.path !== '/no-permission') {
+                        //到达此页面后直接清理token,避免出现用户直接从url返回login导致无限循环
+                        removeToken()
+                        //避免重复跳转
+                        next({path:'/no-permission'})
+                    } else {
+                        //已经在无权限页面,不再跳转
+                        next()
+                    }
+                    NProgress.done()
+                }else{
+                    setUseType(userInfo.data.type_id, 86400)
+                    setWebSiteId(userInfo.data.website_id, 86400)
+                    console.log("用户有访问权限,访问继续!")
+                    next()
+                }
+            }
         } else {
             //3.4.2 如果有token,但是没在登录页面
             const hasRoles = store.getters.roles && store.getters.roles.length > 0