退出登录/token过期-清除本地储存

This commit is contained in:
bb_pan 2025-09-28 10:33:25 +08:00
parent c8f93c6d8b
commit d14a5b4335
2 changed files with 6 additions and 0 deletions

View File

@ -101,6 +101,8 @@ export default {
console.log('🚀 ~ process.env.VUE_APP_BASE_API:', process.env.VUE_APP_BASE_API) console.log('🚀 ~ process.env.VUE_APP_BASE_API:', process.env.VUE_APP_BASE_API)
if (process.env.VUE_APP_BASE_API == '/iws/jiju-api') { if (process.env.VUE_APP_BASE_API == '/iws/jiju-api') {
setTimeout(() => { setTimeout(() => {
localStorage.clear()
sessionStorage.clear()
window.location.replace( window.location.replace(
'http://sgwpdm.ah.sgcc.com.cn/iws/', 'http://sgwpdm.ah.sgcc.com.cn/iws/',
) )
@ -108,6 +110,8 @@ export default {
} else { } else {
this.$store.dispatch('LogOut').then(() => { this.$store.dispatch('LogOut').then(() => {
location.href = '/login' location.href = '/login'
localStorage.clear()
sessionStorage.clear()
}) })
} }
}).catch(() => {}); }).catch(() => {});

View File

@ -130,6 +130,8 @@ service.interceptors.response.use(res => {
router.push('/login') router.push('/login')
}) })
} }
localStorage.clear()
sessionStorage.clear()
return Promise.reject('无效的会话,或者会话已过期,请重新登录。') return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) { } else if (code === 500) {
Message({ message: msg, type: 'error' }) Message({ message: msg, type: 'error' })