2022-11-28 18:01:14 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { NuxtError } from '#app'
|
|
|
|
|
|
|
|
// prevent reactive update when clearing error
|
|
|
|
const { error } = defineProps<{
|
|
|
|
error: Partial<NuxtError>
|
|
|
|
}>()
|
|
|
|
|
|
|
|
// add more custom status codes messages here
|
|
|
|
const errorCodes: Record<number, string> = {
|
|
|
|
404: 'Page not found',
|
|
|
|
}
|
|
|
|
|
2023-01-14 18:55:09 +09:00
|
|
|
if (process.dev)
|
|
|
|
console.error(error)
|
|
|
|
|
2022-11-28 18:01:14 +09:00
|
|
|
const defaultMessage = 'Something went wrong'
|
|
|
|
|
|
|
|
const message = error.message ?? errorCodes[error.statusCode!] ?? defaultMessage
|
|
|
|
|
|
|
|
const state = ref<'error' | 'reloading'>('error')
|
2023-03-31 04:01:24 +09:00
|
|
|
async function reload() {
|
2022-11-28 18:01:14 +09:00
|
|
|
state.value = 'reloading'
|
|
|
|
try {
|
2023-01-08 06:35:42 +09:00
|
|
|
clearError({ redirect: currentUser.value ? '/home' : `/${currentServer.value}/public/local` })
|
2022-11-28 18:01:14 +09:00
|
|
|
}
|
2023-01-12 14:39:22 +09:00
|
|
|
catch (err) {
|
|
|
|
console.error(err)
|
2022-11-28 18:01:14 +09:00
|
|
|
state.value = 'error'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<NuxtLoadingIndicator color="repeating-linear-gradient(to right,var(--c-primary) 0%,var(--c-primary-active) 100%)" />
|
|
|
|
<NuxtLayout>
|
|
|
|
<MainContent>
|
|
|
|
<template #title>
|
2023-01-05 08:17:30 +09:00
|
|
|
<span timeline-title-style>Error</span>
|
2022-11-28 18:01:14 +09:00
|
|
|
</template>
|
|
|
|
<slot>
|
|
|
|
<form p5 grid gap-y-4 @submit="reload">
|
|
|
|
<div text-lg>
|
|
|
|
Something went wrong
|
|
|
|
</div>
|
|
|
|
<div text-secondary>
|
|
|
|
{{ message }}
|
|
|
|
</div>
|
|
|
|
<button flex items-center gap-2 justify-center btn-solid text-center :disabled="state === 'reloading'">
|
2023-01-14 01:00:32 +09:00
|
|
|
<span v-if="state === 'reloading'" block animate-spin preserve-3d>
|
|
|
|
<span block i-ri:loader-2-fill />
|
|
|
|
</span>
|
2022-11-28 18:01:14 +09:00
|
|
|
{{ state === 'reloading' ? 'Reloading' : 'Reload' }}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</slot>
|
|
|
|
</MainContent>
|
|
|
|
</NuxtLayout>
|
2022-12-24 00:08:36 +09:00
|
|
|
<AriaAnnouncer />
|
2022-11-28 18:01:14 +09:00
|
|
|
</template>
|