174 lines
4.5 KiB
Vue
174 lines
4.5 KiB
Vue
<script setup lang="ts">
|
|
import { AlertTriangle, ArrowLeft, RefreshCw } from "lucide-vue-next";
|
|
|
|
const props = defineProps<{
|
|
error: {
|
|
statusCode?: number;
|
|
statusMessage?: string;
|
|
message?: string;
|
|
};
|
|
}>();
|
|
|
|
const { t } = useI18n();
|
|
|
|
const clearErrorAndGoHome = async () => {
|
|
await clearError({
|
|
redirect: "/",
|
|
});
|
|
};
|
|
|
|
const reloadPage = () => {
|
|
window.location.reload();
|
|
};
|
|
|
|
const statusCode = computed(() => {
|
|
return props.error?.statusCode || 500;
|
|
});
|
|
|
|
const errorTitle = computed(() => {
|
|
if (statusCode.value === 404) {
|
|
return t("error.notFound.title");
|
|
}
|
|
|
|
if (statusCode.value === 403) {
|
|
return t("error.forbidden.title");
|
|
}
|
|
|
|
if (statusCode.value === 500) {
|
|
return t("error.server.title");
|
|
}
|
|
|
|
return t("error.default.title");
|
|
});
|
|
|
|
const errorDescription = computed(() => {
|
|
if (statusCode.value === 404) {
|
|
return t("error.notFound.description");
|
|
}
|
|
|
|
if (statusCode.value === 403) {
|
|
return t("error.forbidden.description");
|
|
}
|
|
|
|
if (statusCode.value === 500) {
|
|
return t("error.server.description");
|
|
}
|
|
|
|
return t("error.default.description");
|
|
});
|
|
|
|
useHead({
|
|
title: computed(() => `${statusCode.value} — ${errorTitle.value}`),
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<NuxtLayout name="err">
|
|
<main
|
|
class="flex min-h-[calc(100vh-220px)] items-center justify-center px-5 py-20 sm:px-8"
|
|
>
|
|
<section class="w-full max-w-2xl text-center">
|
|
<!-- Technical label -->
|
|
<div
|
|
class="mb-6 flex items-center justify-center gap-3 text-[10px] font-semibold uppercase tracking-[0.25em]"
|
|
:style="{ color: 'var(--text-muted)' }"
|
|
>
|
|
<span>{{ t("error.system") }}</span>
|
|
|
|
<span>/</span>
|
|
|
|
<span>{{ t("error.status") }}</span>
|
|
</div>
|
|
|
|
<!-- Status code -->
|
|
<div
|
|
class="text-7xl font-bold tracking-[-0.06em] sm:text-9xl"
|
|
:style="{ color: 'var(--text)' }"
|
|
>
|
|
{{ statusCode }}
|
|
</div>
|
|
|
|
<!-- Icon -->
|
|
<div
|
|
class="mx-auto mt-5 flex h-14 w-14 items-center justify-center rounded-2xl border"
|
|
:style="{
|
|
backgroundColor: 'var(--surface)',
|
|
borderColor: 'var(--border)',
|
|
color: 'var(--text)',
|
|
}"
|
|
>
|
|
<AlertTriangle class="h-6 w-6" />
|
|
</div>
|
|
|
|
<!-- Title -->
|
|
<h1
|
|
class="mt-6 text-2xl font-bold tracking-tight sm:text-3xl"
|
|
:style="{ color: 'var(--text)' }"
|
|
>
|
|
{{ errorTitle }}
|
|
</h1>
|
|
|
|
<!-- Description -->
|
|
<p
|
|
class="mx-auto mt-4 max-w-lg text-sm leading-7 sm:text-base"
|
|
:style="{ color: 'var(--text-muted)' }"
|
|
>
|
|
{{ errorDescription }}
|
|
</p>
|
|
|
|
<!-- Error information -->
|
|
<div
|
|
class="mx-auto mt-7 max-w-lg rounded-xl border px-4 py-3 text-left"
|
|
:style="{
|
|
backgroundColor: 'var(--surface)',
|
|
borderColor: 'var(--border)',
|
|
}"
|
|
>
|
|
<div
|
|
class="flex items-center justify-between gap-4 text-[9px] font-semibold uppercase tracking-[0.2em]"
|
|
:style="{ color: 'var(--text-muted)' }"
|
|
>
|
|
<span>{{ t("error.code") }}</span>
|
|
|
|
<span>{{ statusCode }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Actions -->
|
|
<div class="mt-8 flex flex-col justify-center gap-3 sm:flex-row">
|
|
<button
|
|
type="button"
|
|
@click="clearErrorAndGoHome"
|
|
class="inline-flex h-11 items-center justify-center gap-2 rounded-xl border px-5 text-sm font-semibold transition-all duration-200 hover:-translate-y-0.5"
|
|
:style="{
|
|
backgroundColor: 'var(--surface)',
|
|
borderColor: 'var(--border)',
|
|
color: 'var(--text)',
|
|
}"
|
|
>
|
|
<ArrowLeft class="h-4 w-4" />
|
|
|
|
{{ t("error.backHome") }}
|
|
</button>
|
|
|
|
<button
|
|
type="button"
|
|
@click="reloadPage"
|
|
class="inline-flex h-11 items-center justify-center gap-2 rounded-xl border px-5 text-sm font-semibold transition-all duration-200 hover:-translate-y-0.5"
|
|
:style="{
|
|
backgroundColor: 'var(--text)',
|
|
borderColor: 'var(--text)',
|
|
color: 'var(--bg)',
|
|
}"
|
|
>
|
|
<RefreshCw class="h-4 w-4" />
|
|
|
|
{{ t("error.retry") }}
|
|
</button>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
</NuxtLayout>
|
|
<CustomCursor />
|
|
</template>
|