Refactor code structure and remove redundant sections for improved readability and maintainability
This commit is contained in:
+8
-11
@@ -10,14 +10,15 @@ import ProfilePage from '../views/ProfilePage.vue'
|
||||
import AdminPage from '../views/AdminPage.vue'
|
||||
|
||||
const routes = [
|
||||
{ path: '/', name: 'Login', component: LoginPage, meta: { guest: true } },
|
||||
{ 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, meta: { auth: true } },
|
||||
{ path: '/library', name: 'Library', component: LibraryPage, meta: { auth: true } },
|
||||
{ path: '/playlist', name: 'Playlist', component: PlaylistPage, meta: { auth: true } },
|
||||
{ path: '/playlist/:id', name: 'PlaylistDetail', component: PlaylistPage, meta: { auth: true } },
|
||||
{ path: '/profile', name: 'Profile', component: ProfilePage, meta: { auth: true } },
|
||||
{ path: '/admin/tracks', name: 'AdminTracks', component: AdminPage, meta: { auth: true, admin: 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: PlaylistPage },
|
||||
{ path: '/profile', name: 'Profile', component: ProfilePage },
|
||||
{ path: '/admin/tracks', name: 'AdminTracks', component: AdminPage, meta: { admin: true } },
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
@@ -32,10 +33,6 @@ router.beforeEach((to, from, next) => {
|
||||
return next('/home')
|
||||
}
|
||||
|
||||
if (to.meta.auth && !authStore.isLoggedIn) {
|
||||
return next('/')
|
||||
}
|
||||
|
||||
if (to.meta.guest && authStore.isLoggedIn) {
|
||||
return next('/home')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user