-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
36 lines (33 loc) · 1.03 KB
/
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
<script lang="ts" setup>
import ErrorPage from './error.vue'
const { gtag, disableAnalytics, enableAnalytics, initialize } = useGtag();
const cookies = useCookie("consent", { maxAge: 60 * 60 * 24 * 30 });
onMounted(() => {
if (cookies.value && cookies.value !== "rejected") {
initialize();
enableAnalytics();
}
});
const modalOpen = useState("modalOpen", () => false);
const error = useState("error", () => null);
const handleError = (error: any) => {
modalOpen.value = true;
error.value = error;
console.error("Global error:", error);
};
const resetError = () => clearError({ redirect: "/" });
</script>
<template>
<NuxtLayout>
<NuxtErrorBoundary @error="handleError">
<NuxtPage />
<template #error="{ error }">
<dialog :open="modalOpen" class="fixed inset-0 bg-black/50">
<NuxtErrorBoundary>
<ErrorPage :error="error" @reset="resetError" class="fixed inset-0" />
</NuxtErrorBoundary>
</dialog>
</template>
</NuxtErrorBoundary>
</NuxtLayout>
</template>