2026-10-28 16:57:43 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
const { user, logout } = useAuth()
|
|
|
|
|
const notices = useNotices()
|
|
|
|
|
|
|
|
|
|
const connection = computed(() =>
|
2026-10-28 18:04:21 +00:00
|
|
|
isMockServer
|
|
|
|
|
? { text: t('app.mock'), tone: 'bg-amber-100 text-amber-800' }
|
|
|
|
|
: ws.is_opened.value
|
|
|
|
|
? { text: t('app.connected'), tone: 'bg-emerald-100 text-emerald-800' }
|
|
|
|
|
: { text: t('app.offline'), tone: 'bg-rose-100 text-rose-800' },
|
2026-10-28 16:57:43 +00:00
|
|
|
)
|
|
|
|
|
|
2026-10-28 18:04:21 +00:00
|
|
|
const toastTone = {
|
|
|
|
|
success: 'border-emerald-200 bg-emerald-50 text-emerald-900',
|
|
|
|
|
error: 'border-rose-200 bg-rose-50 text-rose-900',
|
|
|
|
|
warning: 'border-amber-200 bg-amber-50 text-amber-900',
|
|
|
|
|
info: 'border-parchment-300 bg-white text-ink-900',
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-28 16:57:43 +00:00
|
|
|
useHead({ title: () => t('app.title') })
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2026-10-28 18:04:21 +00:00
|
|
|
<div class="min-h-dvh">
|
|
|
|
|
<header class="border-b border-parchment-300/70 bg-parchment-50/90">
|
2026-10-28 18:54:29 +00:00
|
|
|
<div class="flex items-center gap-2 px-4 py-2.5 sm:gap-3 sm:px-6">
|
2026-10-28 18:04:21 +00:00
|
|
|
<NuxtLink to="/" class="flex min-w-0 items-center gap-2">
|
|
|
|
|
<span class="grid size-8 shrink-0 place-items-center rounded-lg bg-amber-700 text-amber-50 shadow-sm">
|
|
|
|
|
<IconBuilding type="headquarters" class="size-5" />
|
|
|
|
|
</span>
|
|
|
|
|
<span class="hidden font-display text-lg font-semibold sm:inline">{{ t('app.title') }}</span>
|
|
|
|
|
</NuxtLink>
|
2026-10-28 16:57:43 +00:00
|
|
|
|
2026-10-28 18:04:21 +00:00
|
|
|
<nav v-if="user" class="ml-1">
|
|
|
|
|
<NuxtLink to="/worlds" class="btn btn-ghost" active-class="bg-parchment-200/70">
|
|
|
|
|
<IconUi name="globe" class="size-4" />
|
|
|
|
|
{{ t('app.worlds') }}
|
|
|
|
|
</NuxtLink>
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
<div class="ml-auto flex min-w-0 items-center gap-2">
|
2026-10-28 18:27:17 +00:00
|
|
|
<!-- The socket opens with the first request after login, so before that there is nothing to show. -->
|
|
|
|
|
<span v-if="user" class="badge" :class="connection.tone">
|
2026-10-28 18:04:21 +00:00
|
|
|
<span class="size-1.5 rounded-full bg-current" />
|
|
|
|
|
{{ connection.text }}
|
|
|
|
|
</span>
|
|
|
|
|
<template v-if="user">
|
|
|
|
|
<span class="hidden truncate text-sm text-ink-500 md:inline">{{ user.name }}</span>
|
|
|
|
|
<button type="button" class="btn btn-ghost px-2" :title="t('app.logout')" @click="logout()">
|
|
|
|
|
<IconUi name="logout" class="size-4" />
|
|
|
|
|
<span class="hidden sm:inline">{{ t('app.logout') }}</span>
|
|
|
|
|
</button>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
2026-10-28 16:57:43 +00:00
|
|
|
|
|
|
|
|
<main>
|
|
|
|
|
<NuxtPage />
|
|
|
|
|
</main>
|
2026-10-28 18:04:21 +00:00
|
|
|
|
|
|
|
|
<div class="pointer-events-none fixed inset-x-4 bottom-4 z-50 flex flex-col items-end gap-2">
|
|
|
|
|
<TransitionGroup
|
|
|
|
|
enter-from-class="translate-y-2 opacity-0"
|
|
|
|
|
leave-to-class="opacity-0"
|
|
|
|
|
enter-active-class="transition duration-200"
|
|
|
|
|
leave-active-class="transition duration-200"
|
|
|
|
|
>
|
|
|
|
|
<button
|
|
|
|
|
v-for="n in notices.list.value"
|
|
|
|
|
:key="n.id"
|
|
|
|
|
type="button"
|
|
|
|
|
class="pointer-events-auto w-full max-w-sm rounded-lg border px-3 py-2 text-left text-sm shadow-md"
|
|
|
|
|
:class="toastTone[n.type]"
|
|
|
|
|
@click="notices.dismiss(n.id)"
|
|
|
|
|
>
|
|
|
|
|
{{ n.text }}
|
|
|
|
|
</button>
|
|
|
|
|
</TransitionGroup>
|
|
|
|
|
</div>
|
2026-10-28 16:57:43 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|