支持回话过期自动登录

This commit is contained in:
wuxw 2025-07-11 08:50:08 +08:00
parent 567327652a
commit 5e59e7c314
3 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,5 @@
{
"name": "micro-community-web",
"name": "物业管理系统",
"version": "1.0.0",
"private": true,
"scripts": {

View File

@ -2,7 +2,7 @@
<el-dialog
:title="$t('scheduleClassesPage.selectOrg')"
:visible.sync="dialogVisible"
width="60%"
width="40%"
>
<el-tree
ref="orgTree"

View File

@ -54,8 +54,20 @@ service.interceptors.response.use(
},
error => {
console.log(error)
//localStorage.removeItem('token')
//window.location.href = '/#/views/user/login'
// 判断是否为401未授权错误
if (error.response && error.response.status === 401) {
// 清除本地存储的token
localStorage.removeItem('token')
// 跳转到登录页面
window.location.href = '/#/views/user/login'
Message({
message: '登录已过期,请重新登录',
type: 'error',
duration: 5 * 1000
})
}
return Promise.reject(error)
}