created frontend with login, room listing and creation, and message page with all features
This commit is contained in:
25
src/router/index.ts
Normal file
25
src/router/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
|
||||
import LoginPage from '../pages/LoginPage.vue'
|
||||
import RoomsPage from '../pages/RoomsPage.vue'
|
||||
import ChatPage from '../pages/ChatPage.vue'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{ path: '/login', component: LoginPage },
|
||||
{ path: '/', component: RoomsPage },
|
||||
{ path: '/rooms/:uuid', component: ChatPage, props: true },
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const auth = useAuthStore()
|
||||
if (!auth.isAuthenticated && to.path !== '/login') {
|
||||
return '/login'
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user