Files
noctune-client/src/router/index.js
T
byntangxyz d82d91ea96 feat: add mobile navigation component and queue panel
- Implemented MobileNav.vue for mobile navigation with links to Home, Library, Playlist, and Profile.
- Added QueuePanel.vue to display the current queue of tracks with functionality to jump to a specific track.
- Created ArtistView.vue to show artist details and their tracks, including loading states and play functionality.
- Introduced NotFoundPage.vue for handling 404 errors with a user-friendly message and a link to return home.
2026-05-26 21:44:42 +07:00

53 lines
1.8 KiB
JavaScript

import { createRouter, createWebHistory } from 'vue-router'
import { useAuthStore } from '../stores/authStore.js'
import LoginPage from '../views/LoginPage.vue'
import RegisterPage from '../views/RegisterPage.vue'
import LandingPage from '../views/LandingPage.vue'
import LibraryPage from '../views/LibraryPage.vue'
import PlaylistPage from '../views/PlaylistPage.vue'
import PlaylistDetail from '../views/PlaylistDetail.vue'
import ProfilePage from '../views/ProfilePage.vue'
import AdminPage from '../views/AdminPage.vue'
import ArtistView from '../views/ArtistView.vue'
import NotFoundPage from '../views/NotFoundPage.vue'
const routes = [
{ path: '/', redirect: '/home' },
{ path: '/login', name: 'Login', component: LoginPage, meta: { guest: true } },
{ path: '/register', name: 'Register', component: RegisterPage, meta: { guest: true } },
{ path: '/home', name: 'Home', component: LandingPage },
{ path: '/library', name: 'Library', component: LibraryPage },
{ path: '/playlist', name: 'Playlist', component: PlaylistPage },
{ path: '/playlist/:id', name: 'PlaylistDetail', component: PlaylistDetail },
{ path: '/profile', name: 'Profile', component: ProfilePage },
{ path: '/artist/:name', name: 'Artist', component: ArtistView },
{ path: '/admin/tracks', name: 'AdminTracks', component: AdminPage, meta: { admin: true } },
{ path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFoundPage },
]
const router = createRouter({
history: createWebHistory(),
routes,
})
router.beforeEach((to, from, next) => {
const authStore = useAuthStore()
if (to.meta.admin && !authStore.isAdmin) {
return next('/home')
}
if (to.meta.guest && authStore.isLoggedIn) {
return next('/home')
}
next()
})
router.afterEach(() => {
window.scrollTo(0, 0)
})
export default router