permission.js 676 B

123456789101112131415161718192021222324252627
  1. /*
  2. * @Author : yuanrunwei
  3. * @Date : 2020-05-18 12:05:37
  4. * @LastEditors : yuanrunwei
  5. * @LastEditTime : 2020-05-18 19:29:52
  6. * @FilePath : \ambre-admin-noob\src\permission.js
  7. */
  8. import router from './router'
  9. import cookiesDeploy from './common/utils/cookiesDeploy'
  10. const whiteList = ['/login'] // 不重定向白名单
  11. router.beforeEach((to, from, next) => {
  12. if (cookiesDeploy.getCookies() && JSON.parse(cookiesDeploy.getCookies()).managerid) {
  13. if (to.path === '/login') {
  14. next({ path: '/' })
  15. } else {
  16. next()
  17. }
  18. } else {
  19. if (whiteList.indexOf(to.path) !== -1) {
  20. next()
  21. } else {
  22. next('/login')
  23. }
  24. }
  25. })