Переглянути джерело

没有 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 {