2022-12-07 13:31:38 +00:00
|
|
|
<template>
|
2024-03-15 15:09:50 +00:00
|
|
|
<nav
|
|
|
|
id="sidebar"
|
|
|
|
v-koel-clickaway="closeIfMobile"
|
|
|
|
:class="{ collapsed, 'tmp-showing': tmpShowing, showing: mobileShowing }"
|
|
|
|
class="side side-nav"
|
|
|
|
@mouseenter="onMouseEnter"
|
|
|
|
@mouseleave="onMouseLeave"
|
|
|
|
>
|
2024-01-08 22:52:25 +00:00
|
|
|
<section class="search-wrapper">
|
2024-03-12 06:14:43 +00:00
|
|
|
<SearchForm />
|
2022-12-07 13:31:38 +00:00
|
|
|
</section>
|
|
|
|
|
2024-03-12 06:14:43 +00:00
|
|
|
<section v-koel-overflow-fade class="menu-wrapper">
|
2024-01-08 22:52:25 +00:00
|
|
|
<section class="music">
|
|
|
|
<h1>Your Music</h1>
|
|
|
|
|
|
|
|
<ul class="menu">
|
|
|
|
<SidebarItem screen="Home" href="#/home" :icon="faHome">Home</SidebarItem>
|
2024-03-12 06:14:43 +00:00
|
|
|
<QueueSidebarItem />
|
2024-01-08 22:52:25 +00:00
|
|
|
<SidebarItem screen="Songs" href="#/songs" :icon="faMusic">All Songs</SidebarItem>
|
|
|
|
<SidebarItem screen="Albums" href="#/albums" :icon="faCompactDisc">Albums</SidebarItem>
|
|
|
|
<SidebarItem screen="Artists" href="#/artists" :icon="faMicrophone">Artists</SidebarItem>
|
|
|
|
<SidebarItem screen="Genres" href="#/genres" :icon="faTags">Genres</SidebarItem>
|
2024-03-12 06:14:43 +00:00
|
|
|
<YouTubeSidebarItem v-show="showYouTube" />
|
2024-01-08 22:52:25 +00:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
|
2024-03-12 06:14:43 +00:00
|
|
|
<PlaylistList />
|
2024-01-08 22:52:25 +00:00
|
|
|
|
|
|
|
<section v-if="showManageSection" class="manage">
|
|
|
|
<h1>Manage</h1>
|
|
|
|
|
|
|
|
<ul class="menu">
|
2024-03-12 06:14:43 +00:00
|
|
|
<SidebarItem v-if="isAdmin" screen="Settings" href="#/settings" :icon="faTools">Settings</SidebarItem>
|
2024-01-08 22:52:25 +00:00
|
|
|
<SidebarItem screen="Upload" href="#/upload" :icon="faUpload">Upload</SidebarItem>
|
2024-03-12 06:14:43 +00:00
|
|
|
<SidebarItem v-if="isAdmin" screen="Users" href="#/users" :icon="faUsers">Users</SidebarItem>
|
2024-01-08 22:52:25 +00:00
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section v-if="!isPlus && isAdmin" class="plus-wrapper">
|
2024-03-12 06:14:43 +00:00
|
|
|
<BtnUpgradeToPlus />
|
2022-12-07 13:31:38 +00:00
|
|
|
</section>
|
2024-03-15 15:09:50 +00:00
|
|
|
|
|
|
|
<button class="btn-toggle" @click.prevent="toggleNavbar">
|
|
|
|
<Icon v-if="collapsed" :icon="faAngleRight" />
|
|
|
|
<Icon v-else :icon="faAngleLeft" />
|
|
|
|
</button>
|
2022-12-07 13:31:38 +00:00
|
|
|
</nav>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import {
|
|
|
|
faCompactDisc,
|
|
|
|
faHome,
|
|
|
|
faMicrophone,
|
|
|
|
faMusic,
|
|
|
|
faTags,
|
|
|
|
faTools,
|
|
|
|
faUpload,
|
2024-03-15 15:09:50 +00:00
|
|
|
faUsers,
|
|
|
|
faAngleLeft,
|
|
|
|
faAngleRight
|
2022-12-07 13:31:38 +00:00
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
import { eventBus } from '@/utils'
|
2024-03-15 15:09:50 +00:00
|
|
|
import { useAuthorization, useKoelPlus, useRouter, useThirdPartyServices, useUpload, useLocalStorage } from '@/composables'
|
2022-12-07 13:31:38 +00:00
|
|
|
|
|
|
|
import SidebarItem from './SidebarItem.vue'
|
|
|
|
import QueueSidebarItem from './QueueSidebarItem.vue'
|
|
|
|
import YouTubeSidebarItem from './YouTubeSidebarItem.vue'
|
|
|
|
import PlaylistList from './PlaylistSidebarList.vue'
|
|
|
|
import SearchForm from '@/components/ui/SearchForm.vue'
|
2024-01-13 17:57:24 +00:00
|
|
|
import BtnUpgradeToPlus from '@/components/koel-plus/BtnUpgradeToPlus.vue'
|
2022-12-07 13:31:38 +00:00
|
|
|
|
|
|
|
const { onRouteChanged } = useRouter()
|
|
|
|
const { useYouTube } = useThirdPartyServices()
|
|
|
|
const { isAdmin } = useAuthorization()
|
2024-01-04 11:35:36 +00:00
|
|
|
const { allowsUpload } = useUpload()
|
2024-01-08 22:52:25 +00:00
|
|
|
const { isPlus } = useKoelPlus()
|
2024-03-15 15:09:50 +00:00
|
|
|
const { get: lsGet, set: lsSet } = useLocalStorage()
|
2022-12-07 13:31:38 +00:00
|
|
|
|
2024-03-15 15:09:50 +00:00
|
|
|
const collapsed = ref(lsGet('sidebar-collapsed', false))
|
2022-12-07 13:31:38 +00:00
|
|
|
const mobileShowing = ref(false)
|
|
|
|
const youTubePlaying = ref(false)
|
|
|
|
|
|
|
|
const showYouTube = computed(() => useYouTube.value && youTubePlaying.value)
|
2024-01-04 11:35:36 +00:00
|
|
|
const showManageSection = computed(() => isAdmin.value || allowsUpload.value)
|
2022-12-07 13:31:38 +00:00
|
|
|
|
|
|
|
const closeIfMobile = () => (mobileShowing.value = false)
|
2024-03-15 15:09:50 +00:00
|
|
|
const toggleNavbar = () => {
|
|
|
|
collapsed.value = !collapsed.value
|
|
|
|
lsSet('sidebar-collapsed', collapsed.value)
|
|
|
|
}
|
|
|
|
|
|
|
|
let tmpShowingHandler: number | undefined
|
|
|
|
const tmpShowing = ref(false)
|
|
|
|
|
|
|
|
const onMouseEnter = () => {
|
|
|
|
if (!collapsed.value) return;
|
|
|
|
|
|
|
|
tmpShowingHandler = window.setTimeout(() => {
|
|
|
|
if (!collapsed.value) return
|
|
|
|
tmpShowing.value = true
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
|
|
|
|
const onMouseLeave = (e: MouseEvent) => {
|
|
|
|
if (!e.relatedTarget) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmpShowingHandler) {
|
|
|
|
clearTimeout(tmpShowingHandler)
|
|
|
|
tmpShowingHandler = undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
tmpShowing.value = false
|
|
|
|
}
|
2022-12-07 13:31:38 +00:00
|
|
|
|
|
|
|
onRouteChanged(_ => (mobileShowing.value = false))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to toggle sidebar event to show or hide the sidebar.
|
|
|
|
* This should only be triggered on a mobile device.
|
|
|
|
*/
|
|
|
|
eventBus.on('TOGGLE_SIDEBAR', () => (mobileShowing.value = !mobileShowing.value))
|
|
|
|
.on('PLAY_YOUTUBE_VIDEO', _ => (youTubePlaying.value = true))
|
|
|
|
</script>
|
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
<style lang="postcss" scoped>
|
2022-12-07 13:31:38 +00:00
|
|
|
nav {
|
2024-01-08 22:52:25 +00:00
|
|
|
position: relative;
|
2022-12-07 13:31:38 +00:00
|
|
|
width: var(--sidebar-width);
|
|
|
|
background-color: var(--color-bg-secondary);
|
|
|
|
-ms-overflow-style: -ms-autohiding-scrollbar;
|
|
|
|
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1);
|
2024-01-08 22:52:25 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2024-03-15 15:09:50 +00:00
|
|
|
will-change: width;
|
|
|
|
|
|
|
|
&.collapsed {
|
|
|
|
transition: width .2s;
|
|
|
|
width: 24px;
|
|
|
|
|
|
|
|
> *:not(.btn-toggle) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.tmp-showing {
|
|
|
|
position: absolute;
|
|
|
|
background-color: var(--color-bg-primary);
|
|
|
|
width: var(--sidebar-width);
|
|
|
|
height: 100vh;
|
|
|
|
z-index: 100;
|
|
|
|
|
|
|
|
> *:not(.btn-toggle) {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-12-07 13:31:38 +00:00
|
|
|
|
2024-01-08 22:52:25 +00:00
|
|
|
form[role=search] {
|
|
|
|
min-height: 38px;
|
2022-12-07 13:31:38 +00:00
|
|
|
}
|
|
|
|
|
2024-01-08 22:52:25 +00:00
|
|
|
.search-wrapper {
|
2024-01-14 12:43:53 +00:00
|
|
|
padding: 1.8rem 1.5rem;
|
2024-01-08 22:52:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.menu-wrapper {
|
|
|
|
flex: 1;
|
2024-01-14 12:43:53 +00:00
|
|
|
padding: 0 1.5rem;
|
2024-01-08 22:52:25 +00:00
|
|
|
overflow-y: auto;
|
|
|
|
|
|
|
|
@media (hover: none) {
|
2024-04-04 20:13:35 +00:00
|
|
|
/* Enable scroll with momentum on touch devices */
|
2024-01-08 22:52:25 +00:00
|
|
|
overflow-y: scroll;
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.plus-wrapper {
|
|
|
|
padding: 1rem 1.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-wrapper > * + * {
|
|
|
|
margin-top: 2.25rem;
|
2022-12-07 13:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.droppable {
|
|
|
|
box-shadow: inset 0 0 0 1px var(--color-accent);
|
|
|
|
border-radius: 4px;
|
|
|
|
cursor: copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
.queue > span {
|
|
|
|
display: flex;
|
|
|
|
align-items: baseline;
|
|
|
|
justify-content: space-between;
|
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
:deep(h1) {
|
|
|
|
text-transform: uppercase;
|
|
|
|
letter-spacing: 1px;
|
|
|
|
margin-bottom: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
:deep(a svg) {
|
|
|
|
opacity: .7;
|
|
|
|
}
|
|
|
|
|
|
|
|
:deep(a) {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
gap: .7rem;
|
|
|
|
height: 36px;
|
|
|
|
line-height: 36px;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
padding: 2px 0 0 2px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.active, &:hover {
|
|
|
|
color: var(--color-text-primary);
|
|
|
|
}
|
|
|
|
|
2024-01-25 18:02:10 +00:00
|
|
|
&::before {
|
|
|
|
content: '';
|
|
|
|
right: -1.5rem;
|
|
|
|
top: 25%;
|
|
|
|
width: 4px;
|
|
|
|
height: 50%;
|
|
|
|
position: absolute;
|
|
|
|
transition: box-shadow .5s ease-in-out, background-color .5s ease-in-out;
|
|
|
|
border-radius: 9999rem;
|
|
|
|
}
|
|
|
|
|
2022-12-07 13:31:38 +00:00
|
|
|
&.active {
|
|
|
|
&::before {
|
|
|
|
background-color: var(--color-highlight);
|
|
|
|
box-shadow: 0 0 40px 10px var(--color-highlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
span {
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
:deep(li li a) { /* submenu items */
|
2022-12-07 13:31:38 +00:00
|
|
|
padding-left: 11px;
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
padding: 2px 0 0 13px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-15 15:09:50 +00:00
|
|
|
.btn-toggle {
|
|
|
|
width: 24px;
|
|
|
|
aspect-ratio: 1 / 1;
|
|
|
|
position: absolute;
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
background-color: var(--color-bg-secondary);
|
|
|
|
border: 1px solid var(--color-border);
|
|
|
|
border-radius: 50%;
|
|
|
|
right: -12px;
|
|
|
|
top: 30px;
|
|
|
|
z-index: 5;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--color-text-primary);
|
|
|
|
background-color: var(--color-bg-secondary);
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-07 13:31:38 +00:00
|
|
|
@media screen and (max-width: 768px) {
|
2024-04-04 20:13:35 +00:00
|
|
|
background-color: var(--color-bg-primary);
|
|
|
|
background-image: var(--bg-image);
|
|
|
|
background-attachment: var(--bg-attachment);
|
|
|
|
background-size: var(--bg-size);
|
|
|
|
background-position: var(--bg-position);
|
|
|
|
|
2022-12-07 13:31:38 +00:00
|
|
|
transform: translateX(-100vw);
|
|
|
|
transition: transform .2s ease-in-out;
|
|
|
|
|
|
|
|
position: fixed;
|
|
|
|
width: 100%;
|
|
|
|
z-index: 99;
|
|
|
|
height: calc(100vh - var(--header-height));
|
|
|
|
|
|
|
|
&.showing {
|
|
|
|
transform: translateX(0);
|
|
|
|
}
|
|
|
|
}
|
2024-03-15 15:09:50 +00:00
|
|
|
|
2022-12-07 13:31:38 +00:00
|
|
|
}
|
|
|
|
</style>
|