mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-24 02:06:12 +03:00
3c43a1cdd1
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
60 lines
1.6 KiB
Vue
60 lines
1.6 KiB
Vue
<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',
|
|
}
|
|
|
|
if (process.dev)
|
|
console.error(error)
|
|
|
|
const defaultMessage = 'Something went wrong'
|
|
|
|
const message = error.message ?? errorCodes[error.statusCode!] ?? defaultMessage
|
|
|
|
const state = ref<'error' | 'reloading'>('error')
|
|
async function reload() {
|
|
state.value = 'reloading'
|
|
try {
|
|
clearError({ redirect: currentUser.value ? '/home' : `/${currentServer.value}/public/local` })
|
|
}
|
|
catch (err) {
|
|
console.error(err)
|
|
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 timeline-title-style>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'" block animate-spin preserve-3d>
|
|
<span block i-ri:loader-2-fill />
|
|
</span>
|
|
{{ state === 'reloading' ? 'Reloading' : 'Reload' }}
|
|
</button>
|
|
</form>
|
|
</slot>
|
|
</MainContent>
|
|
</NuxtLayout>
|
|
<AriaAnnouncer />
|
|
</template>
|