-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.vue
59 lines (50 loc) · 1.46 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
<template>
<VEmptyState
:headline="headline"
:title="title"
:action-text="actionText"
:image="errorImage"
bg-color="surface"
height="100vh"
@click:action="onActionClick"
/>
</template>
<script setup lang="ts">
import type { NuxtError } from '#app';
import errorImage from '~/assets/icons/error.svg';
const props = defineProps<{ error: NuxtError & { data: { to?: string } } }>();
const route = useRoute();
const errorData = computed(() => {
if (typeof props.error.data === 'string') {
try {
return JSON.parse(props.error.data);
} catch (error) {
return {};
}
} else {
return props.error.data;
}
});
const headline = computed<string>(() => String(route.query.code || props.error.statusCode || 404));
const title = computed<string>(
() => route.query.message?.toString() || props.error.statusMessage || 'Oops! Something went wrong, try again',
);
const actionText = computed<string>(() => {
switch (route.query.to?.toString() || errorData.value?.to) {
case '/articles':
return 'all articles';
case '/signup':
return 'go to sign up';
case '/login':
return 'go to log in';
default:
return 'go home';
}
});
const onActionClick = () => navigateTo(route.query.to?.toString() || errorData.value?.to || '/');
</script>
<style>
.v-empty-state.v-theme--dark .v-img__img {
filter: invert(99%) sepia(7%) saturate(24%) hue-rotate(282deg) brightness(108%) contrast(100%);
}
</style>