80 lines
2.6 KiB
Vue
80 lines
2.6 KiB
Vue
<script setup lang="ts">
|
|
definePageMeta({ middleware: "auth" });
|
|
|
|
const route = useRoute();
|
|
const session = useSessionStore();
|
|
const { t } = useI18n();
|
|
|
|
const menuGroups = computed(() => [
|
|
{
|
|
title: t("user.orderCenter"),
|
|
items: [
|
|
{ label: t("user.myOrders"), to: "/user/orders" },
|
|
{ label: t("user.addresses"), to: "/user/addresses" },
|
|
{ label: t("user.coupons"), to: "/user/coupons" },
|
|
{ label: t("user.aftersalesTitle"), to: "/user/aftersales" },
|
|
],
|
|
},
|
|
{
|
|
title: t("user.memberCenter"),
|
|
items: [
|
|
{ label: t("user.dashboard"), to: "/user" },
|
|
{ label: t("user.favorites"), to: "/user/favorites" },
|
|
{ label: t("user.invoices"), to: "/user/invoices" },
|
|
],
|
|
},
|
|
]);
|
|
|
|
function isActive(to: string): boolean {
|
|
return to === "/user"
|
|
? route.path === "/user"
|
|
: route.path === to || route.path.startsWith(`${to}/`);
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="bg-bg text-text min-h-screen py-8 pb-16 font-sans">
|
|
<div
|
|
class="max-w-mall mx-auto grid w-full gap-5 px-4 lg:grid-cols-[234px_minmax(0,1fr)] lg:items-start"
|
|
>
|
|
<VCard :padded="false" class="min-h-[560px] pb-5">
|
|
<div class="border-border flex items-center gap-3 border-b px-4 py-5">
|
|
<img
|
|
class="h-[54px] w-[54px] rounded-full object-cover"
|
|
src="/mock/avatar.svg"
|
|
:alt="t('user.title')"
|
|
/>
|
|
<div class="min-w-0">
|
|
<!-- Session lives in localStorage, so the name is unknown at SSR time. -->
|
|
<ClientOnly
|
|
><strong class="text-text block truncate text-sm">{{
|
|
session.user?.display_name
|
|
}}</strong></ClientOnly
|
|
>
|
|
<NuxtLink
|
|
class="text-muted hover:text-primary mt-2 inline-block text-xs no-underline"
|
|
to="/user"
|
|
>{{ t("user.editProfile") }}</NuxtLink
|
|
>
|
|
</div>
|
|
</div>
|
|
<nav v-for="group in menuGroups" :key="group.title" class="pt-[18px]">
|
|
<h2 class="text-muted mb-2 px-5 text-[13px] font-semibold">{{ group.title }}</h2>
|
|
<NuxtLink
|
|
v-for="item in group.items"
|
|
:key="item.to"
|
|
:to="item.to"
|
|
class="text-text hover:bg-primary-soft hover:text-primary block border-l-[3px] border-transparent px-5 py-2.5 text-[13px] no-underline"
|
|
:class="isActive(item.to) ? 'border-primary bg-primary-soft text-primary' : ''"
|
|
>
|
|
{{ item.label }}
|
|
</NuxtLink>
|
|
</nav>
|
|
</VCard>
|
|
<main class="w-full min-w-0">
|
|
<NuxtPage />
|
|
</main>
|
|
</div>
|
|
</div>
|
|
</template>
|