-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.vue
72 lines (62 loc) · 1.48 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
<template>
<NuxtLayout>
<div class="container">
<CardImageComponent
:image-url="imageUrl"
:links="links"
:reversed="true"
:subtitle="subtitle"
:title="title"
/>
</div>
</NuxtLayout>
</template>
<script lang="ts" setup>
const props = defineProps({
error: Object
})
const handleError = () => clearError({ redirect: '/' })
const statusCode = computed(() => props.error.statusCode);
if(statusCode.value !== 404) {
handleError();
}
const title = computed(() => {
const code = statusCode.value;
switch (code) {
case 404:
return 'Spletna stran ne obstaja';
case 500:
return 'Napaka pri pridobivanju podatkov';
default:
return 'Napaka';
}
});
const subtitle = computed(() => {
const code = statusCode.value;
switch (code) {
case 404:
return 'Stran, ki jo iščete, ne obstaja. Morda sem jo pojedel.';
case 500:
return `Koda napake: ${code}`;
default:
return `Koda napake: ${code}`;
}
});
const imageUrl = computed(() => {
const code = statusCode.value;
switch (code) {
case 404:
return '/img/sportko.svg';
case 500:
default:
return '/img/zabavko.svg';
}
});
const links = [
{
title: 'Domov',
link: '/',
buttonType: 'is-primary'
}
]
</script>