Sfoglia il codice sorgente

401状态清除token

chenjj 3 mesi fa
parent
commit
37aeceafac
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  1. 2 1
      utils/request.ts

+ 2 - 1
utils/request.ts

@@ -1,6 +1,6 @@
 import store from '@/store'
 import config from '@/config'
-import { getToken } from '@/utils/auth'
+import { getToken,removeToken } from '@/utils/auth'
 import errorCode from '@/utils/errorCode'
 import { toast, showConfirm, tansParams } from '@/utils/common'
 import { RequestConfig, ResponseData } from '@/types/request'
@@ -42,6 +42,7 @@ const request = <T>(config:RequestConfig):Promise<ResponseData<T>> => {
       // @ts-ignore
       const msg:string = errorCode[code] || data.msg || errorCode['default']
       if (code === 401) {
+        removeToken();
         showConfirm('您还未登陆系统,是否前往登陆?').then(res => {
           if (res.confirm) {
             store.dispatch('LogOut').then(res => {