35 lines
893 B
Vue
35 lines
893 B
Vue
<template>
|
|
<a-config-provider :locale="zhCN">
|
|
<router-view />
|
|
</a-config-provider>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { onMounted, onUnmounted } from 'vue'
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import { startIdleWatcher } from '@/utils/lastActive'
|
|
import { showErrorModal } from '@/utils/errorModal'
|
|
|
|
const router = useRouter()
|
|
const route = useRoute()
|
|
const authStore = useAuthStore()
|
|
|
|
let stopIdleWatcher = null
|
|
|
|
onMounted(() => {
|
|
stopIdleWatcher = startIdleWatcher(() => {
|
|
if (authStore.accessToken && route.path !== '/login') {
|
|
authStore.clear()
|
|
showErrorModal('您已长时间无操作,请重新登录')
|
|
router.replace('/login')
|
|
}
|
|
})
|
|
})
|
|
|
|
onUnmounted(() => {
|
|
stopIdleWatcher && stopIdleWatcher()
|
|
})
|
|
</script>
|