Add admin layout and pages: implement sidebar navigation and user role checks

This commit is contained in:
lucast committed 2025-12-10 21:43:32 +01:00
1 parent a9cb8c45d5
commit 0f76978a33
7 files changed
+121

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
<template>
<Sidebar>
<template #sidebar>
<p class="title">Music - Admin</p>
<div class="category">
<Button
full
variant="ghost"
to="/admin"
type="link"
icon-name="lucide:house"
>
Dashboard
</Button>
</div>
<div class="category">
<p>Manage</p>
<Button
full
variant="ghost"
to="/admin/artists"
type="link"
icon-name="lucide:mic-vocal"
>
Manage Artists
</Button>
<Button
full
variant="ghost"
to="/admin/albums"
type="link"
icon-name="lucide:gallery-vertical-end"
>
Manage Albums
</Button>
<Button
full
variant="ghost"
to="/admin/songs"
type="link"
icon-name="lucide:music"
>
Manage Songs
</Button>
</div>
<div class="category">
<p>Exit</p>
<Button
full
variant="ghost"
to="/"
type="link"
icon-name="lucide:settings-2"
>
Exit Admin Panel
</Button>
</div>
</template>
<template #default>
<slot />
</template>
</Sidebar>
</template>
<style lang="scss" scoped>
@use "@/styles/util" as *;
.title {
@include fontSize(24px);
}
.search-input,
.title {
margin-bottom: 1rem;
}
.category {
margin-bottom: 0.8rem;
& > p {
@include fontSize(13px);
font-weight: 600;
margin-bottom: 0.1rem;
}
}
</style>
+16
View File
@@ -11,6 +11,8 @@ const onSearchInput = (v: string) => {
else router.replace("/search")
}, 300)
}
const { data: user } = useApiFetch<any>("/user")
</script>
<template>
@@ -69,6 +71,20 @@ const onSearchInput = (v: string) => {
Songs
</Button>
</div>
<div v-if="user?.role == 'admin'" class="category">
<p>Secret stuff</p>
<Button
full
variant="ghost"
to="/admin"
type="link"
icon-name="lucide:settings-2"
>
Go To Admin Panel
</Button>
</div>
</template>
<template #default>