|
@@ -181,16 +181,17 @@ export default {
|
|
//设置一个定时器,定时在距离过期前5min,这个定时器会发送refreshToken请求
|
|
//设置一个定时器,定时在距离过期前5min,这个定时器会发送refreshToken请求
|
|
|
|
|
|
this.expiresTime = localStorage.getItem('expiresTime')
|
|
this.expiresTime = localStorage.getItem('expiresTime')
|
|
- this.toExpiresTime = new Date(this.expiresTime).getTime() - new Date().getTime();
|
|
|
|
-
|
|
|
|
- let that = this;
|
|
|
|
- if(this.toExpiresTime < 5*60*1000){
|
|
|
|
- this.refreshToken()
|
|
|
|
- }else{
|
|
|
|
- if(this.toExpiresTime < 24*60*60*1000){ //当过期时间小于一天时才会定时执行,否则会因为过期时间过大无法执行
|
|
|
|
- this.tokenTimer = setTimeout(function(){
|
|
|
|
- that.refreshToken()
|
|
|
|
- }, this.toExpiresTime - 5*60*1000)
|
|
|
|
|
|
+ if(this.expiresTime){
|
|
|
|
+ this.toExpiresTime = new Date(this.expiresTime).getTime() - new Date().getTime();
|
|
|
|
+ let that = this;
|
|
|
|
+ if(this.toExpiresTime < 5*60*1000){
|
|
|
|
+ this.refreshToken()
|
|
|
|
+ }else{
|
|
|
|
+ if(this.toExpiresTime < 24*60*60*1000){ //当过期时间小于一天时才会定时执行,否则会因为过期时间过大无法执行
|
|
|
|
+ this.tokenTimer = setTimeout(function(){
|
|
|
|
+ that.refreshToken()
|
|
|
|
+ }, this.toExpiresTime - 5*60*1000)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|