tj
2025-06-05 bba272999cc546f65781bf3d20245a3f819af67f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
 * 定时自动登出功能, 启用后一段时间无用户操作, 则自动登出. 需在项目 config 中配置
 */
import store from '@/store'
import Config from '@/config'
 
 
let timer
 
export default router => {
  if (timer) clearTimeout(timer)
  if (!Config.openAutoJumpOut) return
  if (router?.currentRoute.value.path === '/' || router?.currentRoute.value.path === '/login') {
    return
  }
 
  timer = setTimeout(() => {
    store.dispatch('loginOut')
    const { origin } = window.location
    window.location.href = origin
  }, Config.stagnateTime)
}