75 lines
2.7 KiB
Vue
75 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
const session = useSessionStore();
|
|
const { locale, locales, setLocale } = useI18n();
|
|
const route = useRoute();
|
|
const { boot } = useAccent();
|
|
|
|
onMounted(() => {
|
|
session.hydrate();
|
|
boot();
|
|
});
|
|
|
|
const isAuthPage = computed(() => route.path === "/login");
|
|
const navItems = [
|
|
{ to: "/", label: "nav.dashboard" },
|
|
{ to: "/users", label: "nav.users" },
|
|
{ to: "/shops", label: "nav.shops" },
|
|
{ to: "/orders", label: "nav.orders" },
|
|
{ to: "/aftersales", label: "nav.aftersales" },
|
|
{ to: "/content", label: "nav.content" },
|
|
{ to: "/brands", label: "nav.brands" },
|
|
{ to: "/currencies", label: "nav.currencies" },
|
|
{ to: "/points-products", label: "nav.pointsProducts" },
|
|
{ to: "/points-orders", label: "nav.pointsOrders" },
|
|
];
|
|
</script>
|
|
|
|
<template>
|
|
<div v-if="isAuthPage" class="bg-bg text-text min-h-screen font-sans">
|
|
<NuxtPage />
|
|
</div>
|
|
<div v-else class="bg-bg text-text min-h-screen font-sans md:flex">
|
|
<aside
|
|
class="border-border bg-surface w-full shrink-0 border-b p-4 md:min-h-screen md:w-60 md:border-r md:border-b-0"
|
|
>
|
|
<div class="text-primary mb-6 text-lg font-bold">{{ $t("common.appName") }} · Admin</div>
|
|
<nav class="grid gap-1" aria-label="Admin navigation">
|
|
<NuxtLink
|
|
v-for="item in navItems"
|
|
:key="item.to"
|
|
:to="item.to"
|
|
class="text-muted hover:bg-primary-soft hover:text-primary rounded-md px-3 py-2 text-sm font-medium transition-colors"
|
|
:class="route.path === item.to ? 'bg-primary-soft text-primary' : ''"
|
|
>
|
|
{{ $t(item.label) }}
|
|
</NuxtLink>
|
|
</nav>
|
|
</aside>
|
|
<main class="min-w-0 flex-1">
|
|
<header
|
|
class="border-border bg-surface flex flex-wrap items-center justify-end gap-3 border-b px-4 py-3 md:px-6"
|
|
>
|
|
<select
|
|
:value="locale"
|
|
class="border-border bg-surface text-text focus:border-primary focus:outline-primary/30 rounded-md border px-3 py-2 text-sm focus:outline-2"
|
|
:aria-label="$t('common.language')"
|
|
@change="setLocale(($event.target as HTMLSelectElement).value as 'en' | 'zh')"
|
|
>
|
|
<option v-for="l in locales" :key="l.code" :value="l.code">{{ l.name }}</option>
|
|
</select>
|
|
<VAccentSwatch />
|
|
<template v-if="session.isLoggedIn">
|
|
<span class="text-muted text-sm">{{ session.user?.display_name }}</span>
|
|
<VBtn size="sm" @click="session.logout()">{{ $t("common.logout") }}</VBtn>
|
|
</template>
|
|
<VBtn v-else size="sm" variant="primary" @click="navigateTo('/login')">{{
|
|
$t("common.login")
|
|
}}</VBtn>
|
|
</header>
|
|
<div class="mx-auto w-full max-w-7xl px-4 md:px-6">
|
|
<NuxtPage />
|
|
</div>
|
|
</main>
|
|
</div>
|
|
</template>
|