-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
39 lines (35 loc) · 901 Bytes
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<template>
<div>
<Header/>
<NuxtPage/>
<SiteFooter/>
</div>
</template>
<script setup>
const router = useRouter()
const route = useRoute()
const user = useCurrentUser()
// we don't need this watcher on server
onMounted(() => {
watch(user, (user, prevUser) => {
console.log('user update', user, prevUser);
if (prevUser && !user) {
// user logged out
console.log('user logged out');
router.push('/');
} else if (user && typeof route.query.redirect === 'string') {
// user logged in
console.log('user logged in, query', route.query.redirect);
router.push(route.query.redirect);
}
})
});
const config = useRuntimeConfig();
router.afterEach((to) => {
if (typeof window.gtag !== 'undefined') {
window.gtag('config', config.public.gaMeasurementId, {
page_path: to.fullPath,
});
}
});
</script>