From 576e37762acb47ba1d7083006b1ed9d1a72579cd Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 25 Oct 2017 17:37:42 +0800 Subject: [PATCH] fix: next to login when token is not right --- src/permission.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/permission.js b/src/permission.js index 4cd4105..4b9e5b1 100644 --- a/src/permission.js +++ b/src/permission.js @@ -2,6 +2,7 @@ import router from './router' import store from './store' import NProgress from 'nprogress' // Progress 进度条 import 'nprogress/nprogress.css'// Progress 进度条样式 +import { Message } from 'element-ui' import { getToken } from '@/utils/auth' // 验权 const whiteList = ['/login'] // 不重定向白名单 @@ -14,6 +15,11 @@ router.beforeEach((to, from, next) => { if (store.getters.roles.length === 0) { store.dispatch('GetInfo').then(res => { // 拉取用户信息 next() + }).catch(() => { + store.dispatch('FedLogOut').then(() => { + Message.error('验证失败,请重新登录') + next({ path: '/login' }) + }) }) } else { next()