-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.vue
102 lines (93 loc) · 2.44 KB
/
error.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
<div id="error" class="view">
<section class="view-item --bgColor-light">
<div class="holder">
<div class="flx --flxColumn --flx-center">
<div class="txt --txtAlign-center --gap">
<h1 class="--txtSize-mx">{{ error.statusCode }}</h1>
<h4>{{ errorMessage.replaceAll(".", "") }}.</h4>
<template v-if="error.statusCode >= 500 && error.statusCode <= 599">
<p>Puedes intentar:</p>
<div class="flx --flxRow-wrap --flx-center">
<XamuActionLink
aria-label="Reintentar"
:href="route.fullPath"
rel="noopener"
target="_self"
>
<span>Reintentar</span>
</XamuActionLink>
<XamuActionLink
v-if="SESSION.user"
aria-label="Cerrar sesion y reintentar"
@click="
clearError();
SESSION.unsetSession();
"
>
<span>Cerrar sesion y reintentar</span>
</XamuActionLink>
</div>
</template>
<XamuActionLink
v-else-if="SESSION.user"
rel="noopener"
@click="clearError({ redirect: '/cursos' })"
>
Volver al los cursos
</XamuActionLink>
<XamuActionLink
v-else
rel="noopener"
@click="clearError({ redirect: '/' })"
>
Volver al inicio
</XamuActionLink>
</div>
</div>
</div>
</section>
</div>
</template>
<script setup lang="ts">
const props = defineProps({
error: {
type: Object,
required: true,
},
});
const APP = useAppStore();
const SESSION = useSessionStore();
const route = useRoute();
const { indexable } = useRuntimeConfig().public;
const errorMessage = computed<string>(() => {
if (props.error.message) return props.error.message;
switch (props.error.statusCode) {
case 404:
return "La página que buscas esta errada o no existe";
case 503:
return "Error interno del servidor";
default:
return "Error desconocido";
}
});
// lifecycle
useHead(() => {
const newMeta: Record<string, any> = {
title: `Error ${props.error.statusCode} ⋅ ${APP.instance?.name || "NO DB"}`,
};
if (!indexable || !!route.meta.noindex) {
newMeta.meta = [{ name: "robots", content: "noindex, nofollow" }];
}
return newMeta;
});
</script>
<style lang="scss" scoped>
@use "@/assets/scss/overrides";
@use "@open-xamu-co/ui-styles/src/utils/module" as utils;
@media only screen {
#error .view-item {
min-height: 100dvh;
}
}
</style>