zoukankan      html  css  js  c++  java
  • 系统--登陆权限校验

    // permission.js 在main.js的引入 就会被执行
    
    const whiteList =['/login']
    
    router.beforeEach(to ,from, next) => {
      if(checkPermission()){
          if(to.path === '/'&& router.options.routes.length>2){
          // 一般有两个默认菜单 /login和* 多余两个说明此用户有可看的菜单权限,默认选中要第一个
    
            const route = router.options.routes[0]
            next({
                 path: route.redirect||route.path
            })  
            return
          }   
      } else {
           // 如果没有这句判断会进入login循环
          if (whiteList.indexOf(to.path) !== -1){
             next()
          } else {
          next({path:'/login'})
          }
      }
    }
    

      

  • 相关阅读:
    MySQL Create table as / Create table like
    Oracle CAST() 函数 数据类型的转换
    day 12
    day 11
    day 10
    day 9
    day 8
    day 7
    day 6
    day 5
  • 原文地址:https://www.cnblogs.com/cs122/p/12692645.html
Copyright © 2011-2022 走看看