Commit 165455ea845de0dda56ab3ac708991c640aa86be

Authored by zhangdaiscott
1 parent b76e3338

解决token失效 ,登录页面重复跳转登录页面问题

ant-design-vue-jeecg/src/utils/request.js
... ... @@ -32,13 +32,9 @@ const err = (error) => {
32 32 notification.error({ message: '系统提示', description: '拒绝访问',duration: 4})
33 33 break
34 34 case 500:
35   - let path = window.location.href
36 35 //notification.error({ message: '系统提示', description:'Token失效,请重新登录!',duration: 4})
37   - if(token && data.message.includes("Token失效") && path.indexOf('/user/login') < 0){
  36 + if(token && data.message.includes("Token失效")){
38 37 // update-begin- --- author:scott ------ date:20190225 ---- for:Token失效采用弹框模式,不直接跳转----
39   - // store.dispatch('Logout').then(() => {
40   - // window.location.reload()
41   - // })
42 38 Modal.error({
43 39 title: '登录已过期',
44 40 content: '很抱歉,登录已过期,请重新登录',
... ... @@ -48,7 +44,9 @@ const err = (error) =&gt; {
48 44 store.dispatch('Logout').then(() => {
49 45 Vue.ls.remove(ACCESS_TOKEN)
50 46 try {
51   - if(path.indexOf('/user/login')==-1){
  47 + let path = window.document.location.pathname
  48 + console.log("location pathname -> "+path)
  49 + if(path!="/" && path.indexOf('/user/login')==-1){
52 50 window.location.reload()
53 51 }
54 52 }catch (e) {
... ...