2026-08-11 23:17:04 +07:00
|
|
|
<template>
|
2026-08-24 08:07:23 +07:00
|
|
|
<div
|
|
|
|
|
class="flex h-dvh flex-col lg:grid"
|
|
|
|
|
:class="sidebarOpen ? 'lg:grid-cols-[236px_1fr]' : 'lg:grid-cols-1'"
|
|
|
|
|
>
|
2026-08-11 23:17:04 +07:00
|
|
|
<div
|
|
|
|
|
v-if="sidebarOpen"
|
2026-08-24 08:07:23 +07:00
|
|
|
class="fixed inset-0 z-30 bg-slate-950/60 backdrop-blur-sm lg:hidden"
|
2026-08-11 23:17:04 +07:00
|
|
|
@click="sidebarOpen = false"
|
|
|
|
|
></div>
|
2026-08-24 08:07:23 +07:00
|
|
|
|
2026-08-11 23:17:04 +07:00
|
|
|
<aside
|
2026-08-24 08:07:23 +07:00
|
|
|
class="fixed inset-y-0 left-0 z-40 flex w-[236px] transform flex-col border-r px-3 py-4 transition-transform duration-200 lg:static"
|
2026-08-11 23:17:04 +07:00
|
|
|
:class="sidebarOpen ? 'translate-x-0' : '-translate-x-full lg:hidden'"
|
2026-08-24 08:07:23 +07:00
|
|
|
style="background: var(--panel); border-color: var(--hairline)"
|
2026-08-11 23:17:04 +07:00
|
|
|
>
|
2026-08-24 08:07:23 +07:00
|
|
|
<div class="mb-5 flex items-center justify-between px-2">
|
|
|
|
|
<router-link to="/dashboard" class="flex items-center gap-2.5">
|
|
|
|
|
<span
|
|
|
|
|
class="grid h-8 w-8 place-items-center rounded-[10px] font-display text-[15px] font-extrabold text-white"
|
|
|
|
|
style="background: var(--primary)"
|
|
|
|
|
>M</span
|
|
|
|
|
>
|
|
|
|
|
<span class="font-display text-[15px] font-extrabold tracking-[-0.01em]" style="color: var(--ink)">
|
|
|
|
|
Workspace
|
|
|
|
|
</span>
|
|
|
|
|
</router-link>
|
|
|
|
|
<button
|
|
|
|
|
class="text-slate-400 transition-colors hover:text-slate-900 dark:hover:text-white lg:hidden"
|
|
|
|
|
aria-label="Close menu"
|
|
|
|
|
@click="sidebarOpen = false"
|
|
|
|
|
>
|
|
|
|
|
<i class="pi pi-times text-base"></i>
|
2026-08-11 23:17:04 +07:00
|
|
|
</button>
|
|
|
|
|
</div>
|
2026-08-24 08:07:23 +07:00
|
|
|
|
|
|
|
|
<nav class="flex flex-col gap-0.5">
|
2026-08-11 23:17:04 +07:00
|
|
|
<router-link
|
|
|
|
|
v-for="item in visibleNavItems"
|
|
|
|
|
:key="item.key"
|
|
|
|
|
class="nav-link"
|
|
|
|
|
:to="item.to"
|
|
|
|
|
@click="handleNavClick"
|
|
|
|
|
>
|
|
|
|
|
<i :class="item.icon"></i> {{ item.label }}
|
|
|
|
|
</router-link>
|
|
|
|
|
<router-link class="nav-link" to="/settings" @click="handleNavClick">
|
|
|
|
|
<i class="pi pi-cog"></i> Settings
|
|
|
|
|
</router-link>
|
|
|
|
|
</nav>
|
2026-08-24 08:07:23 +07:00
|
|
|
|
2026-08-11 23:17:04 +07:00
|
|
|
<div class="flex-1"></div>
|
|
|
|
|
</aside>
|
|
|
|
|
|
|
|
|
|
<div class="flex min-w-0 flex-1 flex-col overflow-hidden">
|
2026-08-24 08:07:23 +07:00
|
|
|
<header
|
|
|
|
|
class="flex items-center justify-between gap-3 border-b px-4 py-2.5 lg:px-6"
|
|
|
|
|
style="background: var(--panel); border-color: var(--hairline)"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex min-w-0 items-center gap-2">
|
2026-08-11 23:17:04 +07:00
|
|
|
<Button
|
|
|
|
|
icon="pi pi-bars"
|
|
|
|
|
rounded
|
|
|
|
|
text
|
2026-08-24 08:07:23 +07:00
|
|
|
severity="secondary"
|
2026-08-11 23:17:04 +07:00
|
|
|
:aria-label="sidebarOpen ? 'Close menu' : 'Open menu'"
|
|
|
|
|
@click="sidebarOpen = !sidebarOpen"
|
|
|
|
|
/>
|
2026-08-24 08:07:23 +07:00
|
|
|
<nav class="flex min-w-0 items-center gap-1.5 text-[13px]" aria-label="Breadcrumb">
|
|
|
|
|
<span class="shrink-0 font-medium" style="color: var(--ink-muted)">
|
|
|
|
|
{{ pageTitle }}
|
|
|
|
|
</span>
|
|
|
|
|
<template v-if="currentProject">
|
|
|
|
|
<span style="color: var(--ink-muted)">/</span>
|
|
|
|
|
<router-link
|
|
|
|
|
:to="{ name: 'project-overview', params: { id: currentProject.id } }"
|
|
|
|
|
class="truncate font-medium transition-colors hover:text-slate-900 dark:hover:text-white"
|
|
|
|
|
style="color: var(--ink-muted)"
|
|
|
|
|
>
|
|
|
|
|
{{ currentProject.name }}
|
|
|
|
|
</router-link>
|
|
|
|
|
</template>
|
|
|
|
|
</nav>
|
2026-08-11 23:17:04 +07:00
|
|
|
</div>
|
2026-08-24 08:07:23 +07:00
|
|
|
<div class="flex min-w-0 items-center gap-2">
|
|
|
|
|
<span class="hidden shrink-0 text-[13px] font-semibold sm:block" style="color: var(--ink)">
|
|
|
|
|
Welcome back, {{ auth.user?.displayName ?? auth.user?.username }}
|
|
|
|
|
</span>
|
2026-08-11 23:17:04 +07:00
|
|
|
<Button
|
|
|
|
|
:icon="theme.isDark.value ? 'pi pi-sun' : 'pi pi-moon'"
|
|
|
|
|
rounded
|
|
|
|
|
text
|
2026-08-24 08:07:23 +07:00
|
|
|
severity="secondary"
|
2026-08-11 23:17:04 +07:00
|
|
|
:aria-label="theme.isDark.value ? 'Switch to light mode' : 'Switch to dark mode'"
|
|
|
|
|
@click="theme.toggle"
|
|
|
|
|
/>
|
2026-08-24 08:07:23 +07:00
|
|
|
<button
|
|
|
|
|
class="flex w-auto items-center gap-2.5 rounded-xl border px-2.5 py-1.5 text-left transition-colors hover:bg-slate-50 dark:hover:bg-white/5"
|
|
|
|
|
style="border-color: var(--hairline)"
|
|
|
|
|
aria-haspopup="true"
|
2026-08-11 23:17:04 +07:00
|
|
|
@click="toggleMenu"
|
2026-08-24 08:07:23 +07:00
|
|
|
>
|
|
|
|
|
<Avatar :label="initials" :style="{ background: 'var(--primary)', color: '#fff' }" size="normal" />
|
|
|
|
|
<span class="hidden min-w-0 sm:block">
|
|
|
|
|
<span class="block truncate text-[13px] font-semibold" style="color: var(--ink)">
|
|
|
|
|
{{ auth.user?.displayName ?? auth.user?.username }}
|
|
|
|
|
</span>
|
|
|
|
|
<span class="block truncate text-[11px]" style="color: var(--ink-muted)">
|
|
|
|
|
@{{ auth.user?.username }}
|
|
|
|
|
</span>
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<Menu ref="menu" :model="menuItems" popup />
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<main class="flex-1 overflow-auto">
|
|
|
|
|
<div class="mx-auto h-full w-full max-w-[1280px] p-4 sm:p-6 lg:px-8 lg:py-7">
|
|
|
|
|
<router-view />
|
|
|
|
|
</div>
|
2026-08-11 23:17:04 +07:00
|
|
|
</main>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { useAuthStore } from '../stores/auth'
|
|
|
|
|
import { useTheme } from '../composables/useTheme'
|
|
|
|
|
import { getProject } from '../services/backend'
|
|
|
|
|
import type { Project } from '../types'
|
|
|
|
|
|
|
|
|
|
const auth = useAuthStore()
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const menu = ref()
|
|
|
|
|
const theme = useTheme()
|
|
|
|
|
|
|
|
|
|
const desktopMq = window.matchMedia('(min-width: 1024px)')
|
|
|
|
|
const isDesktop = ref(desktopMq.matches)
|
2026-08-24 08:07:23 +07:00
|
|
|
const sidebarOpen = ref(isDesktop.value)
|
2026-08-11 23:17:04 +07:00
|
|
|
desktopMq.addEventListener('change', (e) => (isDesktop.value = e.matches))
|
|
|
|
|
|
|
|
|
|
function handleNavClick() {
|
|
|
|
|
if (!isDesktop.value) sidebarOpen.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const navItems = [
|
|
|
|
|
{ key: 'dashboard', label: 'Dashboard', icon: 'pi pi-home', to: '/dashboard' },
|
|
|
|
|
{ key: 'projects', label: 'Projects', icon: 'pi pi-folder-open', to: '/projects' },
|
2026-08-24 08:07:23 +07:00
|
|
|
{ key: 'users', label: 'Users', icon: 'pi pi-users', to: '/users' },
|
2026-08-11 23:17:04 +07:00
|
|
|
]
|
|
|
|
|
const visibleNavItems = computed(() => navItems.filter((item) => auth.canView(item.key)))
|
|
|
|
|
|
2026-08-24 08:07:23 +07:00
|
|
|
const pageTitle = computed(() => (route.meta.title as string | undefined) ?? 'Projects')
|
|
|
|
|
|
2026-08-11 23:17:04 +07:00
|
|
|
const currentProject = ref<Project | null>(null)
|
|
|
|
|
|
|
|
|
|
async function loadCurrentProject(id: string | string[]) {
|
|
|
|
|
try {
|
|
|
|
|
currentProject.value = await getProject(String(id))
|
|
|
|
|
} catch {
|
|
|
|
|
currentProject.value = null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => route.params.id,
|
|
|
|
|
(id) => {
|
|
|
|
|
if (id) void loadCurrentProject(id)
|
|
|
|
|
else currentProject.value = null
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const initials = computed(() => {
|
|
|
|
|
const name = auth.user?.displayName ?? auth.user?.username ?? '?'
|
|
|
|
|
return name.slice(0, 2).toUpperCase()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => route.fullPath,
|
|
|
|
|
() => {
|
|
|
|
|
if (!isDesktop.value) sidebarOpen.value = false
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const menuItems = computed(() => [
|
|
|
|
|
{
|
|
|
|
|
label: auth.user?.displayName ?? auth.user?.username,
|
|
|
|
|
items: [
|
2026-08-24 08:07:23 +07:00
|
|
|
{ label: 'Profile', icon: 'pi pi-user', command: () => router.push('/profile') },
|
2026-08-11 23:17:04 +07:00
|
|
|
{
|
|
|
|
|
label: 'Logout',
|
|
|
|
|
icon: 'pi pi-sign-out',
|
|
|
|
|
command: () => {
|
|
|
|
|
auth.logout()
|
|
|
|
|
window.location.href = '/login'
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
])
|
|
|
|
|
|
2026-08-24 08:07:23 +07:00
|
|
|
const router = useRouter()
|
|
|
|
|
|
2026-08-11 23:17:04 +07:00
|
|
|
function toggleMenu(event: Event) {
|
|
|
|
|
menu.value?.toggle(event)
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.nav-link {
|
2026-08-24 08:07:23 +07:00
|
|
|
position: relative;
|
2026-08-11 23:17:04 +07:00
|
|
|
display: flex;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
align-items: center;
|
2026-08-24 08:07:23 +07:00
|
|
|
gap: 0.65rem;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
padding: 0.5rem 0.875rem;
|
|
|
|
|
font-size: 0.875rem;
|
2026-08-11 23:17:04 +07:00
|
|
|
font-weight: 500;
|
2026-08-24 08:07:23 +07:00
|
|
|
color: var(--ink-muted);
|
|
|
|
|
transition: background-color 0.15s ease, color 0.15s ease;
|
|
|
|
|
}
|
|
|
|
|
.nav-link i {
|
|
|
|
|
font-size: 0.9rem;
|
2026-08-11 23:17:04 +07:00
|
|
|
}
|
|
|
|
|
.nav-link:hover {
|
2026-08-24 08:07:23 +07:00
|
|
|
background-color: var(--primary-soft);
|
|
|
|
|
color: var(--ink);
|
2026-08-11 23:17:04 +07:00
|
|
|
}
|
|
|
|
|
.nav-link.router-link-active {
|
2026-08-24 08:07:23 +07:00
|
|
|
background-color: var(--primary-soft);
|
|
|
|
|
color: var(--primary);
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
.app-dark .nav-link.router-link-active {
|
|
|
|
|
color: #9ba6f8;
|
|
|
|
|
}
|
|
|
|
|
/* Active marker: a magenta rail, the one place the second accent shows in the shell */
|
|
|
|
|
.nav-link.router-link-active::before {
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0;
|
|
|
|
|
top: 20%;
|
|
|
|
|
height: 60%;
|
|
|
|
|
width: 3px;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
background: var(--magenta);
|
2026-08-11 23:17:04 +07:00
|
|
|
}
|
|
|
|
|
</style>
|