Skip to content

Commit ceebf4e

Browse files
authored
fix: auto jump avoid login page (#473)
1 parent cb30ecd commit ceebf4e

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

src/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Config = {
66
showSidebarSearch: true, // 默认打开侧边栏搜索
77
notLoginRoute: ['login'], // 无需登录即可访问的路由 name,
88
useFrontEndErrorMsg: false, // 默认采用后端返回异常
9-
stagnateTime: 1 * 60 * 60 * 1000, // 无操作停滞时间,默认1小时
9+
stagnateTime: 60 * 60 * 1000, // 无操作停滞时间,默认1小时
1010
baseURL: process.env.VUE_APP_BASE_URL, // API接口baseURL,在根目录.env文件查找对应环境变量配置
1111
}
1212

src/lin/plugin/axios.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import axios from 'axios'
55
import { ElMessage } from 'element-plus'
66

77
import store from '@/store'
8+
import router from '@/router'
89
import Config from '@/config'
910
import autoJump from '@/lin/util/auto-jump'
1011
import ErrorCode from '@/config/error-code'
@@ -37,7 +38,7 @@ const _axios = axios.create(config)
3738
_axios.interceptors.request.use(
3839
originConfig => {
3940
// 有 API 请求重新计时
40-
autoJump()
41+
autoJump(router)
4142

4243
const reqConfig = { ...originConfig }
4344

src/lin/util/auto-jump.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import store from '@/store'
55
import Config from '@/config'
66

7-
export default () => {
7+
export default router => {
88
let timer
99

10-
if (!Config.openAutoJumpOut) return
1110
if (timer) clearTimeout(timer)
11+
if (!Config.openAutoJumpOut) return
12+
if (router?.currentRoute.value.path === '/' || router?.currentRoute.value.path === '/login') {
13+
return
14+
}
1215

1316
timer = setTimeout(() => {
1417
store.dispatch('loginOut')

src/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ router.beforeEach((to, from, next) => {
6262
}
6363

6464
// 路由发生变化重新计时
65-
autoJump()
65+
autoJump(router)
6666

6767
// 路由发生变化修改页面title
6868
if (to.meta.title) {

0 commit comments

Comments
 (0)