Explorar o código

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

reghao hai 7 meses
pai
achega
0b34691e2e
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  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 {