2022-11-28 09:01:14 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { NuxtError } from '#app'
|
|
|
|
|
|
|
|
// prevent reactive update when clearing error
|
|
|
|
const { error } = defineProps<{
|
|
|
|
error: Partial<NuxtError>
|
|
|
|
}>()
|
|
|
|
|
2022-11-30 00:22:35 +00:00
|
|
|
setupPageHeader()
|
2022-11-28 09:01:14 +00:00
|
|
|
|
|
|
|
// add more custom status codes messages here
|
|
|
|
const errorCodes: Record<number, string> = {
|
|
|
|
404: 'Page not found',
|
|
|
|
}
|
|
|
|
|
|
|
|
const defaultMessage = 'Something went wrong'
|
|
|
|
|
|
|
|
const message = error.message ?? errorCodes[error.statusCode!] ?? defaultMessage
|
|
|
|
|
|
|
|
const state = ref<'error' | 'reloading'>('error')
|
2022-12-20 15:56:54 +00:00
|
|
|
const masto = useMasto()
|
2022-11-28 09:01:14 +00:00
|
|
|
const reload = async () => {
|
|
|
|
state.value = 'reloading'
|
|
|
|
try {
|
2022-12-20 15:56:54 +00:00
|
|
|
if (!masto.loggedIn.value)
|
|
|
|
await masto.loginTo(currentUser.value)
|
2022-12-04 20:05:11 +00:00
|
|
|
clearError({ redirect: currentUser.value ? '/home' : `/${currentServer.value}/public` })
|
2022-11-28 09:01:14 +00:00
|
|
|
}
|
|
|
|
catch {
|
|
|
|
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>
|
|
|
|
<span text-lg font-bold>Error</span>
|
|
|
|
</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'">
|
|
|
|
<span v-if="state === 'reloading'" i-ri:loader-2-fill animate-spin inline-block />
|
|
|
|
{{ state === 'reloading' ? 'Reloading' : 'Reload' }}
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</slot>
|
|
|
|
</MainContent>
|
|
|
|
</NuxtLayout>
|
2022-12-23 15:08:36 +00:00
|
|
|
<AriaAnnouncer />
|
2022-12-17 23:29:16 +00:00
|
|
|
<PWAPrompt />
|
2022-11-28 09:01:14 +00:00
|
|
|
</template>
|