mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-19 09:43:32 +00:00
feat: 请求时刷新session age
This commit is contained in:
@@ -65,3 +65,7 @@ export function logout() {
|
|||||||
method: 'post'
|
method: 'post'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function refreshSessionIdAge() {
|
||||||
|
return getProfile()
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import i18n from '@/i18n/i18n'
|
import i18n from '@/i18n/i18n'
|
||||||
import { getTokenFromCookie } from '@/utils/auth'
|
import { getTokenFromCookie } from '@/utils/auth'
|
||||||
|
import { refreshSessionIdAge } from '@/api/users'
|
||||||
import { Message, MessageBox } from 'element-ui'
|
import { Message, MessageBox } from 'element-ui'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
|
|
||||||
@@ -88,6 +89,19 @@ export function flashErrorMsg({ response, error }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let timer = null
|
||||||
|
function refreshSessionAgeDelay(response) {
|
||||||
|
if (response.request.responseURL.indexOf('/users/profile/') !== -1) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer)
|
||||||
|
}
|
||||||
|
timer = setTimeout(function() {
|
||||||
|
refreshSessionIdAge()
|
||||||
|
}, 60 * 10)
|
||||||
|
}
|
||||||
|
|
||||||
// response interceptor
|
// response interceptor
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
/**
|
/**
|
||||||
@@ -102,6 +116,7 @@ service.interceptors.response.use(
|
|||||||
*/
|
*/
|
||||||
response => {
|
response => {
|
||||||
// NProgress.done()
|
// NProgress.done()
|
||||||
|
refreshSessionAgeDelay(response)
|
||||||
const res = response.data
|
const res = response.data
|
||||||
|
|
||||||
if (response.config.raw === 1) {
|
if (response.config.raw === 1) {
|
||||||
|
Reference in New Issue
Block a user