소스 검색

没有 token 时删除本地缓存的 user 数据

reghao 7 달 전
부모
커밋
0b34691e2e
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      src/permission.js

+ 2 - 1
src/permission.js

@@ -1,5 +1,5 @@
 import router from './router'
-import { getAccessToken } from '@/utils/auth'
+import { getAccessToken, removeAll } from '@/utils/auth'
 
 router.beforeEach((to, from, next) => {
   const needAuth = to.meta.needAuth
@@ -11,6 +11,7 @@ router.beforeEach((to, from, next) => {
       next()
     }
   } else {
+    removeAll()
     if (needAuth) {
       next('/login')
     } else {