frontend/app.vue

36 lines
706 B
Vue

<template>
<ClientOnly>
<NuxtPage></NuxtPage>
<component :is="usePopup().get()"></component>
</ClientOnly>
</template>
<script setup lang="ts">
import type { RouteLocation } from 'vue-router';
import {usePopup} from "~/components/popup/Popup";
// Guard dashboard and redirect to login
useRouter().beforeEach((route: RouteLocation) => {
guard(route.fullPath);
});
onMounted(() => {
guard(useRoute().fullPath);
})
function guard(route: string)
{
if(route.startsWith('/account') && getToken() == null)
{
useRouter().push('/');
}
if(route === '/' && getToken() != null)
{
useRouter().push('/account/inspect/nodes/_all');
}
}
useHead({
title: 'Kubooboo'
})
</script>