mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
feat: add session valid chack
This commit is contained in:
+13
-2
@@ -1,14 +1,25 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import api from '@/api';
|
||||||
import DefaultLayoutWithVerticalNav from './components/DefaultLayoutWithVerticalNav.vue'
|
import DefaultLayoutWithVerticalNav from './components/DefaultLayoutWithVerticalNav.vue'
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
document.addEventListener('visibilitychange', () => {
|
||||||
|
if (document.visibilityState === 'visible') {
|
||||||
|
api.get('user/current')
|
||||||
|
.catch(() => {
|
||||||
|
router.replace('/login')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DefaultLayoutWithVerticalNav>
|
<DefaultLayoutWithVerticalNav>
|
||||||
<router-view v-slot="{ Component }">
|
<router-view v-slot="{ Component }">
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<component :is="Component" v-if="$route.meta.keepAlive" :key="$route.fullPath" />
|
<component :is="Component" v-if="route.meta.keepAlive" :key="route.fullPath" />
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
<component :is="Component" v-if="!$route.meta.keepAlive" :key="$route.fullPath" />
|
<component :is="Component" v-if="!route.meta.keepAlive" :key="route.fullPath" />
|
||||||
</router-view>
|
</router-view>
|
||||||
</DefaultLayoutWithVerticalNav>
|
</DefaultLayoutWithVerticalNav>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user