mirror of
https://github.com/yangzongzhuan/RuoYi-Cloud.git
synced 2025-09-06 05:02:45 +00:00
token续期调整到后端&默认有效期延长
This commit is contained in:
@@ -35,7 +35,6 @@ import LineChart from './dashboard/LineChart'
|
||||
import RaddarChart from './dashboard/RaddarChart'
|
||||
import PieChart from './dashboard/PieChart'
|
||||
import BarChart from './dashboard/BarChart'
|
||||
import { getToken, getExpiresIn, setExpiresIn } from '@/utils/auth'
|
||||
|
||||
const lineChartData = {
|
||||
newVisitis: {
|
||||
@@ -67,39 +66,12 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
//刷新token锁
|
||||
refreshLock: false,
|
||||
//刷新token的时间
|
||||
refreshTime: '',
|
||||
lineChartData: lineChartData.newVisitis
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.refreshToken()
|
||||
},
|
||||
methods: {
|
||||
handleSetLineChartData(type) {
|
||||
this.lineChartData = lineChartData[type]
|
||||
},
|
||||
// 实时检测刷新token
|
||||
refreshToken() {
|
||||
this.refreshTime = setInterval(() => {
|
||||
if (null === getToken()) {
|
||||
return;
|
||||
}
|
||||
const expires_in = getExpiresIn();
|
||||
if (expires_in <= 1200 && !this.refreshLock) {
|
||||
this.refreshLock = true
|
||||
this.$store
|
||||
.dispatch('RefreshToken')
|
||||
.catch(() => {
|
||||
clearInterval(this.refreshTime)
|
||||
});
|
||||
this.refreshLock = false
|
||||
}
|
||||
this.$store.commit("SET_EXPIRES_IN", expires_in - 10);
|
||||
setExpiresIn(expires_in - 10);
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user