修改判断token是否存在的写法。

当dashboard页面也是有权限存在的时候,当点击画面退出按钮后,会导致store.dispatch('GetInfo')再次调用。原因就是严格模式下,if(getToken())不能判断token不存在的情况。需要使用if (typeof (token) === 'undefined')来进行判断。
This commit is contained in:
phoenix110 2018-03-20 17:04:25 +08:00 committed by GitHub
parent d06d476b50
commit 18697f66e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -15,7 +15,8 @@ function hasPermission(roles, permissionRoles) {
const whiteList = ['/login', '/authredirect', '/reset', '/sendpwd']// 不重定向白名单
router.beforeEach((to, from, next) => {
NProgress.start() // 开启Progress
if (getToken()) { // 判断是否有token
const token = getToken()
if (typeof (token) === 'undefined') { // 判断是否有token
if (to.path === '/login') {
next({ path: '/' })
} else {