diff --git a/src/router/guards.js b/src/router/guards.js index 4bf0e62..98f632d 100644 --- a/src/router/guards.js +++ b/src/router/guards.js @@ -1,6 +1,7 @@ import {hasAuthority} from '@/utils/authority-utils' import {loginIgnore} from '@/router/index' import {checkAuthorization} from '@/utils/request' +import {logout} from '@/services/user' import NProgress from 'nprogress' NProgress.configure({ showSpinner: false }) @@ -28,7 +29,8 @@ const progressStart = (to, from, next) => { */ const loginGuard = (to, from, next, options) => { const {message} = options - if (!loginIgnore.includes(to) && !checkAuthorization()) { + if (!checkAuthorization() && !loginIgnore.includes(to)) { + logout() message.warning('登录已失效,请重新登录') next({path: '/login'}) } else {