合并代码
This commit is contained in:
@@ -64,11 +64,20 @@ api.interceptors.response.use(
|
||||
|
||||
switch (status) {
|
||||
case 401:
|
||||
// 未授权,清除token并跳转到登录页
|
||||
// 未授权,清除token并根据当前路由跳转到相应的登录页
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('agentInfo') // 清除代理信息
|
||||
delete api.defaults.headers.common['Authorization']
|
||||
router.push({ name: 'Login' })
|
||||
ElMessage.error('登录已过期,请重新登录')
|
||||
|
||||
// 判断当前是否在代理相关页面
|
||||
const currentPath = router.currentRoute.value.path
|
||||
if (currentPath.startsWith('/agent')) {
|
||||
router.push('/agent/login')
|
||||
ElMessage.error('代理登录已过期,请重新登录')
|
||||
} else {
|
||||
router.push({ name: 'Login' })
|
||||
ElMessage.error('登录已过期,请重新登录')
|
||||
}
|
||||
break
|
||||
|
||||
case 403:
|
||||
|
||||
Reference in New Issue
Block a user