瀏覽代碼

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