mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-08 17:26:41 +08:00
fix user/current 调用过多
This commit is contained in:
+1
-11
@@ -1,17 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import DefaultLayoutWithVerticalNav from './components/DefaultLayoutWithVerticalNav.vue'
|
import DefaultLayoutWithVerticalNav from './components/DefaultLayoutWithVerticalNav.vue'
|
||||||
import api from '@/api'
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
document.addEventListener('visibilitychange', () => {
|
|
||||||
if (document.visibilityState === 'visible') {
|
|
||||||
api.get('user/current')
|
|
||||||
.catch(() => {
|
|
||||||
router.replace('/login')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -27,5 +17,5 @@ document.addEventListener('visibilitychange', () => {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
// As we are using `layouts` plugin we need its styles to be imported
|
// As we are using `layouts` plugin we need its styles to be imported
|
||||||
@use "@layouts/styles/default-layout";
|
@use '@layouts/styles/default-layout';
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user