feat: 前端增加token免续命白名单

This commit is contained in:
fit2cloud-chenyw 2021-07-19 11:08:00 +08:00
parent 65c4b67e68
commit aca2a9b19f
2 changed files with 7 additions and 3 deletions

View File

@ -15,5 +15,9 @@ module.exports = {
* @description Whether show the logo in sidebar
*/
sidebarLogo: false,
showSettings: true
showSettings: true,
interruptTokenContineUrls: [
'/api/sys_msg/list/',
'/dataset/taskLog/list/'
]
}

View File

@ -8,7 +8,7 @@ import i18n from '@/lang'
import { tryShowLoading, tryHideLoading } from './loading'
import { getLinkToken, setLinkToken } from '@/utils/auth'
// import router from '@/router'
const interruptTokenContineUrls = Config.interruptTokenContineUrls
const TokenKey = Config.TokenKey
const RefreshTokenKey = Config.RefreshTokenKey
const LinkTokenKey = Config.LinkTokenKey
@ -74,7 +74,7 @@ const checkAuth = response => {
})
}
// token到期后自动续命 刷新token
if (response.headers[RefreshTokenKey]) {
if (response.headers[RefreshTokenKey] && !interruptTokenContineUrls.some(item => response.config.url.indexOf(item) >= 0)) {
const refreshToken = response.headers[RefreshTokenKey]
store.dispatch('user/refreshToken', refreshToken)
}