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: {
|
2021-06-25 19:28:41 +02:00
|
|
|
template: "<router-view/>",
|
|
|
|
},
|
|
|
|
beforeEnter: (to, from, next) => {
|
2021-09-19 17:30:37 +02:00
|
|
|
if (store.state.token){
|
2021-06-25 19:28:41 +02:00
|
|
|
next()
|
2021-09-19 17:30:37 +02:00
|
|
|
} else {
|
2021-06-25 19:28:41 +02:00
|
|
|
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
|
|
|
|
},
|
|
|
|
{
|
2021-06-25 19:28:41 +02:00
|
|
|
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',
|
2021-09-24 17:51:37 +02:00
|
|
|
component: Index,
|
|
|
|
beforeEnter: (_to, _from, next) => {
|
|
|
|
if (store.state.token) {
|
|
|
|
next({name: 'Search'})
|
2021-10-03 17:56:52 +02:00
|
|
|
} else {
|
|
|
|
next()
|
2021-09-24 17:51:37 +02:00
|
|
|
}
|
|
|
|
}
|
2021-06-07 17:41:25 +02:00
|
|
|
},
|
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
|