ki-frontend/src/router/index.js

59 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-09-19 12:55:33 +02:00
// SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
//
2021-08-02 19:06:41 +02:00
// SPDX-License-Identifier: AGPL-3.0-or-later
2021-09-19 12:55:33 +02:00
2021-05-31 16:14:28 +02:00
import { createRouter, createWebHistory } from 'vue-router'
2021-09-19 17:30:37 +02:00
import store from '@/store'
2021-06-07 17:41:25 +02:00
import Index from '@/views/Index.vue'
import Search from '@/views/Search.vue'
import Edit from '@/views/profile/Edit.vue'
import View from '@/views/profile/View.vue'
2021-05-31 16:14:28 +02:00
const routes = [
{
2021-06-07 17:41:25 +02:00
path: '/s',
name: 's',
component: {
template: "<router-view/>",
},
beforeEnter: (to, from, next) => {
2021-09-19 17:30:37 +02:00
if (store.state.token){
next()
2021-09-19 17:30:37 +02:00
} else {
next({path: '/', query: {url: to.fullPath, access: false}})
}
2021-06-07 17:41:25 +02:00
},
children: [
{
path: 'search',
name: 'Search',
component: Search
},
{
2021-07-26 17:10:28 +02:00
path: 'profile/:memberId',
2021-06-07 17:41:25 +02:00
name: 'ProfileMember',
component: View
},
{
path: 'profile-edit',
2021-06-07 17:41:25 +02:00
name: 'ProfileEdit',
component: Edit
},
]
2021-05-31 16:14:28 +02:00
},
{
2021-06-07 17:41:25 +02:00
path: '/',
name: 'Index',
component: Index
},
2021-05-31 16:14:28 +02:00
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
2021-09-19 17:30:37 +02:00
export default router