|
|
@ -176,6 +176,7 @@ |
|
|
|
}, |
|
|
|
deleteDialog: false, |
|
|
|
dialog: false, |
|
|
|
expireTime: new Date(), |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
@ -192,7 +193,10 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
created(){ |
|
|
|
|
|
|
|
if(this.$auth.$storage.getUniversal('userAccount') && this.$auth.$storage.getUniversal('userPassword')){ |
|
|
|
this.checkExpireTime(); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
mounted(){ |
|
|
|
if(this.$auth.$storage.getUniversal('userAccount') && this.$auth.$storage.getUniversal('userPassword')){ |
|
|
@ -236,6 +240,9 @@ |
|
|
|
that.$auth.$storage.setUniversal('authtoken', authtoken); |
|
|
|
that.$auth.loggedIn ? that.$router.push({path: that.$auth.$storage.getUniversal('userBeforePath')}) : that.$auth.redirect('login'); |
|
|
|
} |
|
|
|
}else if(response.data.STATUSCODE==200 && this.remember == true){ |
|
|
|
|
|
|
|
|
|
|
|
}else if(response.data.STATUSCODE==500){ |
|
|
|
that.$auth.redirect('login'); |
|
|
|
}else if(response.data.STATUSCODE==401){ |
|
|
@ -299,6 +306,35 @@ |
|
|
|
this.valid = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
checkExpireTime(){ |
|
|
|
console.log("給我時間"); |
|
|
|
console.log("帳號:" + this.$auth.$storage.getUniversal('userAccount')); |
|
|
|
this.$axios |
|
|
|
.get(`/trending/api/System/RememberMe?Account=${this.$auth.$storage.getUniversal('userAccount')}`) |
|
|
|
.then((response) => { |
|
|
|
//console.log(response); |
|
|
|
const data = response.data.DATA.authtoken; |
|
|
|
this.expireTime = new Date(data.ExpireTime); |
|
|
|
const now = new Date(Date.now()); |
|
|
|
|
|
|
|
const saveTime = this.expireTime - now; |
|
|
|
if(saveTime >= 0){ |
|
|
|
const hour = saveTime / (60 * 60 * 1000); |
|
|
|
|
|
|
|
if(hour == 0){ |
|
|
|
this.$auth.$storage.removeUniversal('userPassword'); |
|
|
|
this.$auth.$storage.removeUniversal('userAccount'); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
this.$auth.$storage.removeUniversal('userPassword'); |
|
|
|
this.$auth.$storage.removeUniversal('userAccount'); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
console.log(error); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
beforeUnmount() { |
|
|
|
if(this.timer!=null){ |
|
|
|